context_drop 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +68 -11
- data/app/assets/javascripts/context_drop/context_drop.js +1263 -616
- data/app/controllers/context_drop/configs_controller.rb +3 -1
- data/app/javascript/context_drop/__tests__/api-client.test.ts +310 -0
- data/app/javascript/context_drop/__tests__/widget.test.ts +158 -3
- data/app/javascript/context_drop/api-client.ts +153 -48
- data/app/javascript/context_drop/element-picker.ts +894 -485
- data/app/javascript/context_drop/icons.ts +2 -0
- data/app/javascript/context_drop/screenshot.ts +7 -1
- data/app/javascript/context_drop/styles.ts +88 -39
- data/app/javascript/context_drop/types.ts +1 -0
- data/app/javascript/context_drop/widget.ts +150 -61
- data/lib/context_drop/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '0394c03321879ea6932385407d780bd83b72aba10125852c9f18cd2b651b7eff'
|
|
4
|
+
data.tar.gz: 9390087f363d608043fac36b4411785b7b29efa5c218b538eb740e48ffb80866
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9d5156ebd02703cfcd48db6644282d5848c263db7953765fb114479475fab1f1c8ca6ad2a08e293421db669940e4f71eee04bc3435edbc7878520bee1d4d4d9b
|
|
7
|
+
data.tar.gz: f0178c1ca71d1426d3587bce1318ccceccbf9707f43f1b8fbd0d060fc1bb8c5bcbceb9d787e1895e15c9bd421f1ae42ba68e5a6b949e1f940a968ec9cc32bc80
|
data/README.md
CHANGED
|
@@ -203,33 +203,88 @@ Real-world Rails interfaces have sticky navbars, floating promo ribbons, translu
|
|
|
203
203
|
|
|
204
204
|
ContextDrop ships with a built-in **Model Context Protocol (MCP)** server (`ContextDrop::MCP::Server`) so you or your AI coding agent can pull bug reports, inspect exact CSS selectors and DOM paths, view multimodal screenshots, and mark issues resolved without leaving your editor.
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
-
|
|
208
|
-
|
|
206
|
+
<p align="center">
|
|
207
|
+
<img src="docs/images/demo-mcp-agent.png" alt="ContextDrop MCP server tool calls (list_feedbacks and get_feedback) and root-cause diagnosis inside an AI coding agent" width="100%" />
|
|
208
|
+
</p>
|
|
209
|
+
|
|
210
|
+
> **Above:** Triage flow inside an AI coding agent connected to the `context-drop` MCP server on the live playground. The agent invokes `list_feedbacks` (`{ status: "new" }`) and `get_feedback` (`{ id: 12, include_images: true }`), inspects both the structured `ElementReference` geometry (`button#upgrade-cluster-btn`, `169.1×33px`) and the redacted multimodal `image/png` screenshot block, and pinpoints the exact overlapping CSS rule in `demo/index.html`.
|
|
211
|
+
|
|
212
|
+
### Exposed MCP Capabilities
|
|
213
|
+
|
|
214
|
+
| Type | Name / URI | Description |
|
|
215
|
+
|---|---|---|
|
|
216
|
+
| **Tool** | `list_feedbacks` | Filter & paginate submissions by `status` (`new`, `reviewed`, `resolved`, `dismissed`), `page_url`, or free-text `query` across messages, selectors, and DOM paths. |
|
|
217
|
+
| **Tool** | `get_feedback` | Fetch full `Feedback`, all `ElementReference` DOM snapshots, and inline base64 `image` blocks (`include_images: true` by default). |
|
|
218
|
+
| **Tool** | `get_feedback_attachment` | Retrieve an individual `Attachment` record and its binary screenshot/image as an MCP `image` content block. |
|
|
219
|
+
| **Tool** | `update_feedback_status` | Transition a feedback record between `new`, `reviewed`, `resolved`, and `dismissed`. |
|
|
220
|
+
| **Resource** | `contextdrop://feedbacks/new` | Live JSON feed of unresolved `new` feedback records (up to 50 most recent). |
|
|
221
|
+
| **Resource** | `contextdrop://feedbacks/{id}` | Full JSON snapshot of a specific feedback submission, its pinned elements, and attachment metadata. |
|
|
222
|
+
| **Prompt** | `investigate_feedback` | Generates a structured root-cause investigation brief (with attached screenshots) for a given `feedback_id`. |
|
|
223
|
+
|
|
224
|
+
---
|
|
209
225
|
|
|
210
|
-
### Option 1: Local `stdio`
|
|
226
|
+
### Option 1: Project-Scoped Local `stdio` (Inherited Shell Environment)
|
|
211
227
|
|
|
212
|
-
|
|
228
|
+
When using a workspace-scoped MCP file (e.g., `.mcp.json` in Claude Code or `.cursor/mcp.json` launched from a terminal) where your IDE already runs inside the Rails root and inherits your Ruby shell `PATH`:
|
|
213
229
|
|
|
214
230
|
```json
|
|
215
231
|
{
|
|
216
232
|
"mcpServers": {
|
|
217
233
|
"context-drop": {
|
|
218
|
-
"command": "
|
|
219
|
-
"args": ["context_drop:mcp"]
|
|
234
|
+
"command": "bundle",
|
|
235
|
+
"args": ["exec", "./bin/rails", "context_drop:mcp"]
|
|
220
236
|
}
|
|
221
237
|
}
|
|
222
238
|
}
|
|
223
239
|
```
|
|
224
240
|
|
|
225
|
-
### Option 2:
|
|
241
|
+
### Option 2: Strict Sandboxes, Global IDE Configs & Ruby Version Managers (`rbenv`, `mise`, `asdf`, `rvm`)
|
|
242
|
+
|
|
243
|
+
Strict sandboxed coding agents and GUI-launched desktop IDEs (such as **Antigravity** `mcp_config.json`, **Claude Desktop**, global `~/.cursor/mcp.json`, **Windsurf**, or VS Code launched from macOS Finder / Linux desktop) typically spawn MCP subprocesses with:
|
|
244
|
+
1. **A non-project working directory** (often `/` or `$HOME`, causing relative `./bin/rails` or `Gemfile` lookup to fail), and
|
|
245
|
+
2. **A stripped minimal `PATH`** (`/usr/bin:/bin:/usr/sbin:/sbin`) without sourcing `~/.zshrc` or `~/.bashrc`—causing `/usr/bin/env ruby` inside `bin/rails` to hit an outdated system Ruby (e.g., macOS Ruby `2.6`) or fail to locate `bundle` and Homebrew native libraries (`libpq`, `sqlite3`, `vips`).
|
|
226
246
|
|
|
227
|
-
|
|
247
|
+
To make `stdio` work reliably in strict sandboxes, wrap the launch command with `/bin/zsh -c` (or `/bin/bash -c` on Linux), `cd` into your Rails application root, `exec` your version manager's `bundle` binary directly, and declare an explicit absolute `PATH`:
|
|
228
248
|
|
|
229
249
|
```json
|
|
230
250
|
{
|
|
231
251
|
"mcpServers": {
|
|
232
|
-
"context-drop
|
|
252
|
+
"context-drop": {
|
|
253
|
+
"command": "/bin/zsh",
|
|
254
|
+
"args": [
|
|
255
|
+
"-c",
|
|
256
|
+
"cd /absolute/path/to/your-rails-app && exec /Users/<you>/.rbenv/shims/bundle exec ./bin/rails context_drop:mcp"
|
|
257
|
+
],
|
|
258
|
+
"env": {
|
|
259
|
+
"PATH": "/Users/<you>/.rbenv/shims:/Users/<you>/.rbenv/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
> [!TIP]
|
|
267
|
+
> **Adapting Option 2 to any machine or Ruby version manager:**
|
|
268
|
+
> - **Use literal absolute paths (avoid `~` or `$HOME` inside JSON `env`):** MCP hosts pass `env` directly to `execve` without shell expansion. Run `pwd`, `which bundle`, and `echo $PATH` in your Rails app terminal to get your exact paths.
|
|
269
|
+
> - **Keep `exec` before `bundle`:** `exec` replaces the `zsh`/`bash` wrapper in-place so `stdin`/`stdout` JSON-RPC frames remain unbuffered and IDE shutdown signals (`SIGTERM`) cleanly terminate the Ruby process without leaving orphans.
|
|
270
|
+
> - **Debug `stdio` boot issues:** Set `"CONTEXT_DROP_MCP_DEBUG": "1"` inside `"env"` to stream verbose Rails/ActiveRecord boot diagnostics to `stderr` (MCP `stdout` always stays strictly reserved for JSON-RPC frames).
|
|
271
|
+
|
|
272
|
+
| Ruby Environment / OS | `<bundle-path>` for `exec` | Directories to Prepend to `env.PATH` |
|
|
273
|
+
|---|---|---|
|
|
274
|
+
| **`rbenv`** (macOS / Linux) | `/Users/<you>/.rbenv/shims/bundle` | `/Users/<you>/.rbenv/shims:/Users/<you>/.rbenv/bin` |
|
|
275
|
+
| **`mise`** (macOS / Linux) | `/Users/<you>/.local/share/mise/shims/bundle` | `/Users/<you>/.local/share/mise/shims` |
|
|
276
|
+
| **`asdf`** (macOS / Linux) | `/Users/<you>/.asdf/shims/bundle` | `/Users/<you>/.asdf/shims:/Users/<you>/.asdf/bin` |
|
|
277
|
+
| **`rvm`** (macOS / Linux) | `/Users/<you>/.rvm/wrappers/default/bundle` | `/Users/<you>/.rvm/gems/default/bin:/Users/<you>/.rvm/bin` |
|
|
278
|
+
| **Homebrew / Linux `/usr/local`** | `/opt/homebrew/opt/ruby/bin/bundle` or `/usr/local/bin/bundle` | `/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/usr/local/bin` |
|
|
279
|
+
|
|
280
|
+
### Option 3: Streamable HTTP Transport (Docker, Isolated Sandboxes, Staging & Production)
|
|
281
|
+
|
|
282
|
+
If your Rails app runs inside **Docker / Devcontainers**, if your agent sandbox blocks host binary execution outside the workspace, or if you want to triage feedback directly from **staging or production**, enable the HTTP endpoint with a bearer token (`CONTEXT_DROP_MCP_ENABLED=true` and `CONTEXT_DROP_MCP_API_KEY=<your-secret-token>`) and point your MCP client to `POST /context_drop/mcp`:
|
|
283
|
+
|
|
284
|
+
```json
|
|
285
|
+
{
|
|
286
|
+
"mcpServers": {
|
|
287
|
+
"context-drop-http": {
|
|
233
288
|
"url": "https://staging.example.com/context_drop/mcp",
|
|
234
289
|
"headers": {
|
|
235
290
|
"Authorization": "Bearer <your-secret-token>"
|
|
@@ -239,8 +294,10 @@ Enable MCP on your staging or production server with a bearer token (`CONTEXT_DR
|
|
|
239
294
|
}
|
|
240
295
|
```
|
|
241
296
|
|
|
297
|
+
*(For local Docker or strict-sandbox setups, use `"url": "http://localhost:3000/context_drop/mcp"` against your running `bin/rails server`.)*
|
|
298
|
+
|
|
242
299
|
Once connected, prompt your coding agent directly in your IDE:
|
|
243
|
-
> *"
|
|
300
|
+
> *"Check the `context-drop` MCP server for new feedbacks, inspect the pinned element selector and screenshot, diagnose the root cause in our Rails views/CSS, and mark the feedback resolved."*
|
|
244
301
|
|
|
245
302
|
---
|
|
246
303
|
|