surfcad-mcp 0.3.0 → 0.3.1

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
@@ -27,7 +27,7 @@ Environment variables:
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
28
  4. Click **Allow** (the green check) in SurfCAD when prompted.
29
29
 
30
- The MCP server instructions start with `call register_webhook { url, bearer? } if you can receive https webhooks, otherwise poll read_messages.` and continue with a quick-start (under 2 KB) that points at the `guide` tool.
30
+ The MCP server instructions start with `call register_webhook { url, bearer? } if you can receive https webhooks, otherwise poll read_messages.` The next sentence tells the agent: when you finish a task started from the SurfCAD in-viewer prompt pane, send a closing reply with `reply_to_user` (`final: true`) summarising what was done, so the user gets confirmation. On failure or partial completion, say what was done, what failed and why, and what is left. The instructions continue with a quick-start (under 2 KB) that points at the `guide` tool. `guide { topic: "start" }` repeats that closing-reply rule.
31
31
 
32
32
  A successful `pair`, when no webhook is registered yet, returns an onboarding note as text content (a `type: "text"` block, not only `structuredContent` or `_meta`). The note asks the agent to request a webhook URL and key from the user. The key is the `bearer` argument. Suggested wording to relay: "To get SurfCAD messages instantly, send me your webhook URL and key. This only needs to be done once. Otherwise I'll check for SurfCAD messages between steps, so replies may lag." If the user declines, the agent polls `read_messages`. This process holds the URL and bearer in memory only, so the agent should save them in its own config or memory and call `register_webhook` again after every pair. If a webhook is already registered when `pair` succeeds, the result omits that note and says the webhook is active.
33
33
 
@@ -65,7 +65,7 @@ claude mcp add surfcad -- npx surfcad-mcp
65
65
 
66
66
  ## How to build
67
67
 
68
- `guide { topic: "start" }` carries the build guidance in full (the `pair` result and the initialize instructions point at it; `guide {}` lists the other topics: `features`, `selection`, `paint`, `limits`, `camera`, `assembly`), and the `insert_*` / `set_script` / `create_*` tool descriptions carry a one-line note of it: block out every part of the assembly as plain blocks first (within seconds, then a screenshot for the user), then Build and Shape, then Polish, then pattern and place; features first, with a `set_script` snippet only for one operation no feature can do, starting with `// FEATURE-GAP: <missing feature or option> | <why the existing feature did not work>`; one part per unique fastener type, one instance patterned to every place it goes. The full text is in [docs/agent/SKILL.md](../../docs/agent/SKILL.md).
68
+ `guide { topic: "start" }` carries the build guidance in full (the `pair` result and the initialize instructions point at it; `guide {}` lists the other topics: `features`, `selection`, `paint`, `limits`, `camera`, `assembly`), and the `insert_*` / `set_script` / `create_*` tool descriptions carry a one-line note of it: block out every part of the assembly as plain blocks first (within seconds, then a screenshot for the user), then Build and Shape, then Polish, then pattern and place; features first, with a `set_script` snippet only for one operation no feature can do, starting with `// FEATURE-GAP: <missing feature or option> | <why the existing feature did not work>`; one part per unique fastener type, one instance patterned to every place it goes. Fix one base part with a fixed joint, then place every part that touches or attaches to another with joint_create (one call creates the joint and solves placement). Use part_set_transform only for parts that touch nothing. Block-out positions are rough; joints set final positions. The full text is in [docs/agent/SKILL.md](../../docs/agent/SKILL.md).
69
69
 
70
70
  ## Tools
71
71
 
@@ -77,19 +77,20 @@ Results are compact JSON. Every tool whose result carries `status` (the model-ch
77
77
 
78
78
  | Tool | Args | What it does |
79
79
  | --- | --- | --- |
80
- | `parts` | `{}` | Open assembly: `assemblyId`, `activeId`, and part rows (`id`, `name`, `visible`). No path field. |
80
+ | `parts` | `{}` | Open assembly: `assemblyId`, `activeId`, `unjointedParts` (ids in no joint when there are two or more parts; empty for one part), and part rows (`id`, `name`, `visible`). No path field. |
81
81
  | `list_assemblies` | `{}` | Vault assemblies as `[{ id, name }]`. `id` is the key; `name` is a label. |
82
82
  | `create_assembly` | `{ name? }` | Seed a local assembly. Optional `name` is a label. No git write. |
83
- | `create_part` | `{ name?, script?, position? }` | Add a part at the origin (optional `[x,y,z]` mm) and return its new id. Working copy only. |
83
+ | `create_part` | `{ name?, script?, position? }` | Add a part and return its new id. `position` is a rough block-out `[x,y,z]` mm (default: the origin). In an assembly of two or more parts, a position on a part in no joint adds `warning` `unjointed_part` and the call still succeeds. Working copy only. |
84
84
  | `set_script` | `{ part_id, source }` | Freehand fallback. `part_id` must be the active part. Working copy only. |
85
85
  | `geometry_workers` | `{}` | Debug status of the geometry workers: the device cap, live and busy counts, crashes, the primary and the pool. Read-only. |
86
86
  | `rename_part` | `{ part_id, name }` | Working-copy display name. `{ partId, name, moved: false }`. No git write. |
87
87
  | `rename_assembly` | `{ assembly_id, name }` | Working-copy assembly label. Names may collide. No git write. |
88
88
  | `part_get_transform` | `{ part_id }` | Read placement: `position` mm and intrinsic XYZ Euler degrees. |
89
- | `part_set_transform` | `{ part_id, position?, rotation? }` | Set placement (undoable). Working copy only. |
89
+ | `part_set_transform` | `{ part_id, position?, rotation? }` | Set placement (undoable). Only for a part that touches nothing. In an assembly of two or more parts, a part in no joint adds `warning` `unjointed_part` and the call still succeeds. Working copy only. |
90
+ | `joint_create` | `{ type, picks }` | Default assembly placement. One call creates the joint and solves placement. Fix one base part with `type: "fixed"` and one pick, then mate every part that touches another. |
90
91
  | `set_active_part` | `{ part_id }` | Switch the editor and mesh. `status` then reports that part. |
91
92
  | `open_assembly` | `{ assembly_id }` | Open a vault assembly by id. A name or path is `unknown_assembly`. |
92
- | `insert_part` | `{ part_id? , assembly_id?, copy? }` | Insert by reference (same ids). `copy: true` mints a new id. No git write. |
93
+ | `insert_part` | `{ part_id?, assembly_id?, copy?, instance?, position? }` | Insert by reference (same ids). `copy: true` mints a new id. `instance: true` adds another placement; `position` is a rough block-out. A position on an unjointed row in a multi-part assembly adds `warning` `unjointed_part`. No git write. |
93
94
  | `delete_part` | `{ part_id, scope, confirm? }` | `scope: "assembly"` drops the row. `scope: "repo"` also plans a file delete and requires `confirm: true`. Neither commits. |
94
95
  | `delete_assembly` | `{ assembly_id, confirm: true, delete_parts? }` | Delete the open assembly. `confirm: true` required. Save commits later. |
95
96
  | `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. |
@@ -115,12 +116,14 @@ These five tools stay inside the local `surfcad-mcp` process. They are not SurfC
115
116
  | --- | --- | --- |
116
117
  | `register_webhook` | `{ url, bearer? }` | Remember an https URL that receives each user prompt as `POST` JSON `{ "type": "surfcad.prompt", ... }`. Optional `bearer` is sent as `Authorization: Bearer <bearer>` (non-empty, at most 4096 characters, no CR or LF). Rejects `http`, credentials in the URL, localhost, `.local` names, and private or loopback addresses. The URL and bearer are held only in memory, are never logged, are never written to disk, are never returned or put in status, are never sent to the SurfCAD tab, and are cleared on `unregister_webhook` and when the pairing session ends. A cancel of a prompt that was already delivered is POSTed as `{ "type": "cancel", "id" }` with the same bearer and timeout. Stop work on that id. |
117
118
  | `unregister_webhook` | `{}` | Drop that URL and bearer. Later prompts are queued. |
118
- | `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. A cancel item `{ "type": "cancel", "id" }` means the user stopped a prompt you already received and no webhook is registered. Stop work on that id. |
119
- | `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. A cancelled id returns `{ "ok": false, "error": "cancelled" }` and is not shown in the tab. |
120
- | `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. A cancelled id returns `{ "ok": false, "error": "cancelled" }`. |
119
+ | `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. A cancel item `{ "type": "cancel", "id" }` means the user stopped a prompt you already received and no webhook is registered. Stop work on that id. When you finish the task from a prompt you received, close that chat with `reply_to_user`. |
120
+ | `reply_to_user` | `{ in_reply_to, text, final? }` | Plain-text reply for a prompt id. The final reply is expected and closes the task: when you finish a task started from the in-viewer prompt pane, send `reply_to_user` with `final: true` summarising what was done, so the user gets confirmation. On failure or partial completion, say what was done, what failed and why, and what is left. Several replies may share one id. `final: true` marks the agent idle. A cancelled id returns `{ "ok": false, "error": "cancelled" }` and is not shown in the tab. |
121
+ | `set_status` | `{ working, id? }` | Progress only. Tell the tab whether you are working. It does not close the task; a closing `reply_to_user` does. 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. A cancelled id returns `{ "ok": false, "error": "cancelled" }`. |
121
122
 
122
123
  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). When `bearer` was set, that POST includes `Authorization: Bearer <bearer>`. 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 working state go back as `agent.reply` and `agent.status`.
123
124
 
125
+ When you finish a task started from the in-viewer prompt pane, send a closing reply with `reply_to_user` (`final: true`) summarising what was done, so the user gets confirmation. On failure or partial completion, say what was done, what failed and why, and what is left. `set_status` is for progress and does not close the task.
126
+
124
127
  Stop in the prompt card sends `agent.prompt.cancel` (`v: 1`, the current prompt id) over the same paired connection. Each prompt is `queued`, `delivered` (webhook POST succeeded, or `read_messages` returned it), `replied` (a final reply), or `cancelled`. A prompt that is still queued is removed and is not returned by `read_messages`. A prompt that was already delivered is marked `cancelled`. If a webhook is registered, the process POSTs `{ "type": "cancel", "id" }` with the same bearer, https, and timeout rules; if that POST fails, or no webhook is registered, the next `read_messages` returns `{ "type": "cancel", "id" }`. Stop work on that id. `reply_to_user` and `set_status` for a cancelled id return `{ "ok": false, "error": "cancelled" }` and nothing is sent to the tab. The tab clears its working state. Cancelling a prompt that already has a final reply returns `already_final`. An unknown id returns `not_found`.
125
128
 
126
129
  The bridge `status` tool returns the active part plus fields from this process: `webhookRegistered` (`true` or `false`; the URL is not included), `queued` (prompt messages waiting for `read_messages`; cancelled prompts are not counted), `counts` (`{ queued, delivered, replied, cancelled }`), and `last` (`{ id, state }` of the latest prompt, or `null`). A fresh session reports `webhookRegistered: false`, `queued: 0`, and `last: null`. After one prompt and no webhook, `queued` is `1` and `last.state` is `queued`. After Stop, `last.state` is `cancelled` and `queued` does not include that prompt.