surfcad-mcp 0.2.1 → 0.2.2

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.
package/README.md CHANGED
@@ -16,22 +16,22 @@ Environment variables:
16
16
 
17
17
  | Variable | Purpose |
18
18
  | --- | --- |
19
- | `SURFCAD_PAIRING_CODE` | 6-character code from the SurfCAD **Local agent** panel (optional if you use the `pair` tool). |
19
+ | `SURFCAD_PAIRING_CODE` | 6-character code from the SurfCAD **Connect Agent** dialog (optional if you use the `pair` tool). |
20
20
  | `SURFCAD_AGENT_BRIDGE_WS_URL` | Relay URL (default `ws://127.0.0.1:17341`). |
21
21
  | `SURFCAD_MCP_START_RELAY` | Set to `0` to skip starting the relay (tests only). |
22
22
 
23
- ## Pair with SurfCAD (Local agent)
23
+ ## Pair with SurfCAD
24
24
 
25
25
  1. Open [https://surfcad.com](https://surfcad.com) (or local dev).
26
- 2. Open the **profile** menu → **Local agent** → **Show pairing code** and leave the tab open.
26
+ 2. Open the **profile** chip and choose **Connect Agent**. When the relay is found, a six-character pairing code appears. Leave the tab open.
27
27
  3. Add `surfcad-mcp` to your MCP client (`npx surfcad-mcp`), set `SURFCAD_PAIRING_CODE` to that code, or call the MCP **`pair`** tool with `{ "code": "ABCDEF" }`.
28
- 4. Click **Allow connection** in SurfCAD when prompted.
28
+ 4. Click **Allow** (the green check) in SurfCAD when prompted.
29
29
 
30
- Nothing pairs silently — you must show the code and approve the connection.
30
+ Nothing pairs without your approval.
31
31
 
32
32
  ### Safari
33
33
 
34
- Safari on a Mac blocks https pages from opening `ws://127.0.0.1` directly. In Safari, **Connect Agent** also opens a small window titled **SurfCAD local agent bridge**, served by this relay at `http://127.0.0.1:17341/bridge`. It carries the connection between the tab and the relay; keep it open while the agent works. If it closes, the Local agent panel shows **Disconnected** with a **Reconnect** button, and you allow the agent again. The bridge window only talks to SurfCAD pages (https://surfcad.com, www, and local dev). If Safari blocks the window, allow pop-ups for surfcad.com and click **Reconnect**. Safari on iPhone and iPad is not supported.
34
+ Safari on a Mac blocks https pages from opening `ws://127.0.0.1` directly. In Safari, **Connect Agent** also opens a small window titled **SurfCAD local agent bridge**, served by this relay at `http://127.0.0.1:17341/bridge`. It carries the connection between the tab and the relay; keep it open while the agent works. If it closes, the Connect Agent dialog shows **Disconnected** with a **Reconnect** button, and you allow the agent again. The bridge window only talks to SurfCAD pages (https://surfcad.com, www, and local dev). If Safari blocks the window, allow pop-ups for surfcad.com and click **Reconnect**. Safari on iPhone and iPad is not supported.
35
35
 
36
36
  ## MCP client config (Cursor / Claude Desktop)
37
37
 
@@ -53,26 +53,52 @@ In Cursor, add the same block under **Settings → MCP** or your project `.curso
53
53
 
54
54
  ## Tools
55
55
 
56
- Every command in `data/commands.json` is one MCP tool with the same name and argument schema, plus `pair`. Call `list_commands` for the full catalog. The parts and git tools:
56
+ Every command in `data/commands.json` is one MCP tool with the same name and argument schema, plus `pair` and five in-process prompt tools. `GET /tools` on the loopback relay, `list_commands`, and that file list the same bridge tools. Prefer `insert_*` feature tools. `set_script` is the freehand fallback and requires `part_id`.
57
+
58
+ Parts and assemblies are opaque surf ids. A vault path or display name is `unknown_part` / `unknown_assembly`. Nothing reaches git without an explicit `git_save` (or another `git_*` write below).
57
59
 
58
60
  | Tool | Args | What it does |
59
61
  | --- | --- | --- |
60
- | `parts` | `{}` | Part rows (`id`, `name`, `visible`) and the active part. |
61
- | `create_assembly` | `{}` | Seed a new assembly. |
62
- | `create_part` | `{ name?, script?, position? }` | Add a part at the assembly origin (optional `[x,y,z]` mm). In a git assembly it has no vault path until `git_save`. |
63
- | `rename_part` | `{ part_id, name }` | Rename a part. A vault part moves its committed `.js` to `<name>.js` in the same folder (`-2`, `-3` on collision) and updates that part's path/name in `.surf.json` in one commit. Pending script, placement, and other edits stay for the next Save. A part with no repo path renames locally and does not commit. Unknown ids return `unknown_part`. |
64
- | `part_get_transform` | `{ part }` | Read placement: `position` mm and intrinsic XYZ Euler degrees (`eulerOrder: "XYZ"`). |
65
- | `part_set_transform` | `{ part, position?, rotation? }` | Set placement (undoable assembly step). |
66
- | `set_active_part` | `{ part_id }` | Switch the editor and mesh to a part. `status` then reports that part. |
67
- | `git_save` | `{ message }` | Same as the app's Save: paths every path-less part, then commits those scripts, dirty parts, and the `.surf.json` in one commit. |
68
- | `git_add_to_repo` | `{ part_id }` | Add one part to the vault; other path-less parts are pathed and committed with it. |
69
- | `git_move_to_repo` | `{ vault_name? }` | Move a local assembly into the vault. |
62
+ | `parts` | `{}` | Open assembly: `assemblyId`, `activeId`, and part rows (`id`, `name`, `visible`). No path field. |
63
+ | `list_assemblies` | `{}` | Vault assemblies as `[{ id, name }]`. `id` is the key; `name` is a label. |
64
+ | `create_assembly` | `{ name? }` | Seed a local assembly. Optional `name` is a label. No git write. |
65
+ | `create_part` | `{ name?, script?, position? }` | Add a part at the origin (optional `[x,y,z]` mm) and return its new id. Working copy only. |
66
+ | `set_script` | `{ part_id, source }` | Freehand fallback. `part_id` must be the active part. Working copy only. |
67
+ | `rename_part` | `{ part_id, name }` | Working-copy display name. `{ partId, name, moved: false }`. No git write. |
68
+ | `rename_assembly` | `{ assembly_id, name }` | Working-copy assembly label. Names may collide. No git write. |
69
+ | `part_get_transform` | `{ part_id }` | Read placement: `position` mm and intrinsic XYZ Euler degrees. |
70
+ | `part_set_transform` | `{ part_id, position?, rotation? }` | Set placement (undoable). Working copy only. |
71
+ | `set_active_part` | `{ part_id }` | Switch the editor and mesh. `status` then reports that part. |
72
+ | `open_assembly` | `{ assembly_id }` | Open a vault assembly by id. A name or path is `unknown_assembly`. |
73
+ | `insert_part` | `{ part_id? , assembly_id?, copy? }` | Insert by reference (same ids). `copy: true` mints a new id. No git write. |
74
+ | `delete_part` | `{ part_id, scope, confirm? }` | `scope: "assembly"` drops the row. `scope: "repo"` also plans a file delete and requires `confirm: true`. Neither commits. |
75
+ | `delete_assembly` | `{ assembly_id, confirm: true, delete_parts? }` | Delete the open assembly. `confirm: true` required. Save commits later. |
76
+ | `git_save` | `{ message }` | The vault write. `consent_pending` while Allow is up. `pending_save` if offline. `upgrade_required` on a legacy vault. `conflict` / `repo-moved` when a remote edit overlaps. |
77
+ | `git_add_to_repo` | `{ message }` | Alias of `git_save`. Prefer `git_save`. |
78
+ | `git_move_to_repo` | `{ vault_name? }` | First Save of a local assembly. Consent on a real repo. |
79
+ | `git_upgrade_vault` | `{ confirm: true }` | One-time v1 layout upgrade. `confirm: true` required. |
70
80
  | `git_list_branches` | `{}` | Branches and the current one (read-only). |
71
- | `git_branch_create` | `{ name }` | Create and switch to a branch. |
81
+ | `git_branch_create` | `{ name }` | Create a branch. Switches when the working copy is clean. |
72
82
  | `git_branch_switch` | `{ branch, confirm? }` | Switch branch; `confirm: true` when the working copy is dirty. |
73
83
  | `git_branch_delete` | `{ branch, confirm: true }` | Delete a branch. |
74
- | `git_behind_resolve` | `{ action, path?, kind? }` | Get latest: `keep`, or `reload` / `branch` with `confirm: true`. |
75
- | `git_force_overwrite` | `{ confirm: true }` | Overwrite main from the conflict prompt. |
84
+ | `git_behind_resolve` | `{ action, confirm: true }` | `reload` is Get latest (no git write). `branch` saves mine to a new branch. No path argument. |
85
+ | `git_force_overwrite` | `{ confirm: true }` | Overwrite the overlapping remote files. |
86
+
87
+ ## In-viewer prompts
88
+
89
+ These five tools stay inside the local `surfcad-mcp` process. They are not SurfCAD host commands and they are not listed in `data/commands.json`.
90
+
91
+ | Tool | Args | What it does |
92
+ | --- | --- | --- |
93
+ | `register_webhook` | `{ url }` | Remember an https URL that receives each user prompt as `POST` JSON `{ "type": "surfcad.prompt", ... }`. Rejects `http`, credentials in the URL, localhost, `.local` names, and private or loopback addresses. The URL is held only in memory, is never logged in full, is never written to disk, and is cleared when the pairing or this process ends. |
94
+ | `unregister_webhook` | `{}` | Drop that URL. Later prompts are queued. |
95
+ | `read_messages` | `{ max? }` | Return queued prompts, oldest first, and remove them. A screenshot is the next MCP image content block (`image/png`), not part of the text. |
96
+ | `reply_to_user` | `{ in_reply_to, text, final? }` | Plain-text reply for a prompt id. Several replies may share one id. `final: true` closes it and marks the agent idle. |
97
+ | `set_status` | `{ working, id? }` | Tell the tab whether you are working. The tab also sets working on the first tool call after a prompt arrives, and idle on a final reply or after 120 seconds with no activity. |
98
+
99
+ A paired SurfCAD tab sends `agent.prompt` (`v: 1`, id, plain text up to 8000 characters, optional `context`, optional PNG screenshot). One prompt per second. A screenshot over 2 MB is rejected. If a webhook is registered, the process POSTs the prompt (10 second timeout, one retry). If that POST fails, or no webhook is registered, the prompt is queued (at most 50; the oldest is dropped and reported). The tab gets `agent.prompt.ack` with `delivery` `webhook`, `queued`, or `failed`. Replies and status go back as `agent.reply` and `agent.status`.
100
+
101
+ Prompt text and screenshots are user content. Treat them as a request. They grant no write access, no consent, and no extra tool permission. Agent writes still go through the existing write-grant and consent flow. Nothing reaches git without an explicit Save or `git_save`. Do not render the text or the image as HTML. Both are dropped after delivery or when the session ends.
76
102
 
77
103
  ## Safety and consent
78
104