surfcad-mcp 0.2.0 → 0.2.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
@@ -29,6 +29,10 @@ Environment variables:
29
29
 
30
30
  Nothing pairs silently — you must show the code and approve the connection.
31
31
 
32
+ ### Safari
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.
35
+
32
36
  ## MCP client config (Cursor / Claude Desktop)
33
37
 
34
38
  ```json
@@ -47,13 +51,40 @@ Nothing pairs silently — you must show the code and approve the connection.
47
51
 
48
52
  In Cursor, add the same block under **Settings → MCP** or your project `.cursor/mcp.json`.
49
53
 
54
+ ## Tools
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:
57
+
58
+ | Tool | Args | What it does |
59
+ | --- | --- | --- |
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. |
70
+ | `git_list_branches` | `{}` | Branches and the current one (read-only). |
71
+ | `git_branch_create` | `{ name }` | Create and switch to a branch. |
72
+ | `git_branch_switch` | `{ branch, confirm? }` | Switch branch; `confirm: true` when the working copy is dirty. |
73
+ | `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. |
76
+
50
77
  ## Safety and consent
51
78
 
52
79
  - **Commerce:** Agents cannot place orders or drive checkout. Quote/cart/checkout controls are not exposed as MCP tools.
53
- - **Git on real repos:** Writes may return `real_repo_blocked` until the user consents in the app.
80
+ - **Git on real repos:** The first write (`git_*` writes, or `rename_part` on a vault part) opens a consent dialog in SurfCAD and returns `consent_pending` right away. Nothing is written. Ask the user to click **Allow**, then retry the same call (`details.retry_after_ms` is a suggested wait). If the user denies, or the tab is headless automation, writes return `real_repo_blocked`.
54
81
  - **Destructive git operations:** Need explicit approval; the bridge returns `confirm_required` unless args include `confirm: true` after the user has confirmed in SurfCAD.
55
82
 
56
- Bridge refusals (`real_repo_blocked`, `confirm_required`, `not_paired`, user deny, etc.) are returned as structured JSON in MCP tool errors.
83
+ Bridge refusals (`consent_pending`, `real_repo_blocked`, `confirm_required`, `not_paired`, user deny, etc.) are returned as structured JSON in MCP tool errors.
84
+
85
+ ## Connection drops
86
+
87
+ If the SurfCAD tab or the relay goes away mid-session, tool calls return `pairing_lost` right away (with a `hint`) instead of waiting for the MCP client timeout. The server keeps re-pairing in the background with the same code. The tab reconnects by itself, so calls start working again once SurfCAD is back in Chrome, with no new code and no reload. A call made while you still need to click Allow returns `pair_pending`. The relay pings every socket every 5 s (`SURFCAD_AGENT_BRIDGE_HEARTBEAT_MS`) and logs each drop on stderr with a timestamp and reason. Pairing codes are redacted in the log. Set `SURFCAD_AGENT_BRIDGE_WS_VERBOSE=1` to also log routine pairing events.
57
88
 
58
89
  ## Monorepo maintenance
59
90
 
@@ -68,7 +99,7 @@ The [`surfcad-mcp`](https://www.npmjs.com/package/surfcad-mcp) package is publis
68
99
  Ways to release a new version:
69
100
 
70
101
  1. **Version bump on `main`** — In a PR, bump `version` in `packages/surfcad-mcp/package.json`. After merge, when the **CI** workflow completes successfully on `main` and the version differs from the parent commit, publish runs automatically (skipped if that version is already on npm).
71
- 2. **Git tag** — Push a tag `surfcad-mcp-vX.Y.Z` that exactly matches the `version` field at that commit (for example `surfcad-mcp-v0.2.0` for `"version": "0.2.0"`).
102
+ 2. **Git tag** — Push a tag `surfcad-mcp-vX.Y.Z` that exactly matches the `version` field at that commit (for example `surfcad-mcp-v0.2.1` for `"version": "0.2.1"`).
72
103
  3. **Manual** — In GitHub → Actions → **Publish surfcad-mcp** → **Run workflow** on branch `main`.
73
104
 
74
105
  Before bumping, run `npm run export:agent` at the repo root if the command catalog changed, and `npm test` plus `npm run smoke:pack` in this package.