surfcad-mcp 0.3.1 → 0.3.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.
- package/README.md +67 -16
- package/bin/surfcad-mcp.js +12 -3
- package/data/commands.json +4618 -244
- package/data/helpers.json +35 -11
- package/package.json +2 -2
- package/src/bridge/bridgePopup.mjs +28 -1
- package/src/bridge/localAddress.mjs +43 -5
- package/src/bridge/relayHub.mjs +31 -9
- package/src/cli.mjs +229 -0
- package/src/commandProtocol.mjs +126 -0
- package/src/errors.mjs +80 -1
- package/src/helpers.mjs +1 -1
- package/src/listCommandsMerge.mjs +62 -0
- package/src/pairWait.mjs +34 -0
- package/src/prompt/errorHints.mjs +25 -6
- package/src/prompt/guide.mjs +11 -11
- package/src/prompt/promptSession.mjs +79 -17
- package/src/prompt/promptStall.mjs +14 -2
- package/src/prompt/promptTools.mjs +19 -11
- package/src/relay.mjs +10 -6
- package/src/remote/config.mjs +177 -0
- package/src/remote/httpFallback.mjs +289 -0
- package/src/remote/login.mjs +192 -0
- package/src/remote/logout.mjs +67 -0
- package/src/remote/session.mjs +502 -0
- package/src/remote/tokenStore.mjs +109 -0
- package/src/server.mjs +110 -45
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# surfcad-mcp
|
|
2
2
|
|
|
3
|
-
Stdio [Model Context Protocol](https://modelcontextprotocol.io/) server for the SurfCAD browser agent bridge. Each tool maps to one `window.surfcad` command from the shipped command catalog (`data/commands.json`). The server pairs to your open SurfCAD tab through the **M1** loopback WebSocket relay (`ws://127.0.0.1:17341` by default).
|
|
3
|
+
Stdio [Model Context Protocol](https://modelcontextprotocol.io/) server for the SurfCAD browser agent bridge. Each tool maps to one `window.surfcad` command from the shipped command catalog (`data/commands.json`). The server pairs to your open SurfCAD tab through the **M1** loopback WebSocket relay (`ws://127.0.0.1:17341` by default). A saved login uses the server relay instead; the tool list does not change.
|
|
4
4
|
|
|
5
5
|
## Install and run
|
|
6
6
|
|
|
@@ -16,15 +16,63 @@ Environment variables:
|
|
|
16
16
|
|
|
17
17
|
| Variable | Purpose |
|
|
18
18
|
| --- | --- |
|
|
19
|
-
| `SURFCAD_PAIRING_CODE` |
|
|
20
|
-
| `SURFCAD_AGENT_BRIDGE_WS_URL` |
|
|
21
|
-
| `
|
|
19
|
+
| `SURFCAD_PAIRING_CODE` | 8-character code from the SurfCAD **Connect Agent** dialog (optional if you use the `pair` tool). When set, the local relay stays selected even if a remote login is saved. |
|
|
20
|
+
| `SURFCAD_AGENT_BRIDGE_WS_URL` | Loopback relay URL (default `ws://127.0.0.1:17341`). When set, the local relay stays selected even if a remote login is saved. |
|
|
21
|
+
| `SURFCAD_AGENT_BRIDGE_WS_PORT` | Loopback relay port. When set, the local relay stays selected even if a remote login is saved. |
|
|
22
|
+
| `SURFCAD_MCP_START_RELAY` | Set to `0` to skip starting the local relay (tests only). |
|
|
23
|
+
| `SURFCAD_AGENT_SERVER` | Origin for remote login and the remote client (default `https://surfcad.com`). Dev and staging only. `--server` wins. |
|
|
24
|
+
| `SURFCAD_AGENT_NAME` | Agent name when `--name` is omitted. The MCP client name is used after that, when the stdio server is connected. |
|
|
25
|
+
| `SURFCAD_MCP_TRANSPORT` | `local` or `remote`. Same as `--local` / `--remote`. |
|
|
26
|
+
| `SURFCAD_MCP_CONFIG_DIR` | Directory for the saved remote token. Default `$XDG_CONFIG_HOME/surfcad-mcp` or `~/.config/surfcad-mcp`. |
|
|
27
|
+
|
|
28
|
+
## Which relay
|
|
29
|
+
|
|
30
|
+
The local loopback relay is the default. `npx surfcad-mcp` starts it and pairs with the 8-character code.
|
|
31
|
+
|
|
32
|
+
A saved login selects the server relay at `https://surfcad.com/agent`. `--remote` selects it too, and exits with a message to run `login` when no token is saved.
|
|
33
|
+
|
|
34
|
+
These keep the local relay even when a login is saved, so an existing local MCP config and the in-repo goldens stay on the loopback relay:
|
|
35
|
+
|
|
36
|
+
- `--local` or `SURFCAD_MCP_TRANSPORT=local`
|
|
37
|
+
- `SURFCAD_AGENT_BRIDGE_WS_URL` or `SURFCAD_AGENT_BRIDGE_WS_PORT`
|
|
38
|
+
- a non-empty `SURFCAD_PAIRING_CODE`
|
|
39
|
+
|
|
40
|
+
`--remote` and `SURFCAD_MCP_TRANSPORT=remote` win over that list.
|
|
41
|
+
|
|
42
|
+
## Remote login
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx surfcad-mcp login
|
|
46
|
+
npx surfcad-mcp login --name "Cursor"
|
|
47
|
+
npx surfcad-mcp login --code ABCD-EFGH
|
|
48
|
+
npx surfcad-mcp status
|
|
49
|
+
npx surfcad-mcp logout
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
On Safari, iOS, or a phone-width page, SurfCAD shows a join code. `login --code ABCD-EFGH` redeems it, writes the token the same way device-code login does, and does not print the token. Add `--server` for a dev or staging origin. Cleartext `http://` is still only allowed for localhost, 127.0.0.1, and ::1. Desktop Chrome and the local bridge keep the device-code flow below.
|
|
53
|
+
|
|
54
|
+
`login` without `--code` runs device-code pairing against `https://surfcad.com/agent`. It generates 32 random bytes, sends only their SHA-256, prints an `ABCD-EFGH` code and the approval URL (`https://surfcad.com/agent`), then polls with the secret until you approve, deny, or the code expires. The token is written to the config directory at mode 0600 (the directory is 0700). It is not printed and it is not logged. `status` shows the server, name, machine, and saved time, never the token. `logout` calls `DELETE /agent/tokens/self` with that token, then deletes the file. If the server cannot be reached, the file is still deleted and the command says the login may stay valid until it expires.
|
|
55
|
+
|
|
56
|
+
Sign in on the approval page and enter the code. Leave the SurfCAD tab open. The client connects out over WebSocket (`wss://surfcad.com/agent`) with `Authorization: Bearer`. The first frame is `{ "type": "hello", "v": 1 }`. If WebSocket is blocked, commands fall back to `POST /agent/commands` and then Server-Sent Events, or a long-poll `GET` if the event stream fails. In-viewer prompts travel on the WebSocket.
|
|
57
|
+
|
|
58
|
+
`--server https://staging.example` or `SURFCAD_AGENT_SERVER` overrides the origin for dev and staging. https becomes `wss://`. `http://` and `ws://` are accepted only for localhost, 127.0.0.1, and ::1.
|
|
59
|
+
|
|
60
|
+
The approval name is `--name`, then `SURFCAD_AGENT_NAME`, then the name stored at login. `login` runs before any MCP client exists, so it cannot see `clientInfo`. When none of those is set, the stdio server sends the MCP client name (`clientInfo.name`) on hello. With no name the server says "an agent".
|
|
61
|
+
|
|
62
|
+
Clear failures:
|
|
63
|
+
|
|
64
|
+
| What happened | What you see |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| No SurfCAD tab for about 30 seconds | `SurfCAD tab is asleep` |
|
|
67
|
+
| Token revoked or expired (socket close 4001) | Run `npx surfcad-mcp login` again |
|
|
68
|
+
| Too many commands already waiting | `Too many commands are waiting` |
|
|
69
|
+
| This package is older than the server | `please update surfcad-mcp` |
|
|
22
70
|
|
|
23
71
|
## Pair with SurfCAD
|
|
24
72
|
|
|
25
73
|
1. Open [https://surfcad.com](https://surfcad.com) (or local dev).
|
|
26
|
-
2. Open the **profile** chip and choose **Connect Agent**. When the relay is found,
|
|
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": "
|
|
74
|
+
2. Open the **profile** chip and choose **Connect Agent**. When the relay is found, an eight-character pairing code appears. Leave the tab open.
|
|
75
|
+
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": "BCDFGHJK" }`.
|
|
28
76
|
4. Click **Allow** (the green check) in SurfCAD when prompted.
|
|
29
77
|
|
|
30
78
|
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.
|
|
@@ -46,7 +94,7 @@ Safari on a Mac blocks https pages from opening `ws://127.0.0.1` directly. In Sa
|
|
|
46
94
|
"command": "npx",
|
|
47
95
|
"args": ["-y", "surfcad-mcp"],
|
|
48
96
|
"env": {
|
|
49
|
-
"SURFCAD_PAIRING_CODE": "
|
|
97
|
+
"SURFCAD_PAIRING_CODE": "BCDFGHJK"
|
|
50
98
|
}
|
|
51
99
|
}
|
|
52
100
|
}
|
|
@@ -69,11 +117,11 @@ claude mcp add surfcad -- npx surfcad-mcp
|
|
|
69
117
|
|
|
70
118
|
## Tools
|
|
71
119
|
|
|
72
|
-
Every command in `data/commands.json` is one MCP tool with the same name and argument schema, plus `pair`, `guide` (plain-text agent guidance by topic, no pairing needed; `dialect` is every script helper by signature; `errors.<code>` topics carry the recovery for an error code), `list_helpers` (the helper registry as JSON: `{ names?, group?, match?, page? }`, full doc and examples with `names`), and five in-process prompt tools. Every `insert_*` description ends with the code its block carries at default arguments. The guide topics are also MCP resources (`surfcad://guide/<topic>`, versioned with this package). Every error payload carries `hint` (the next call to make) and, where a topic exists, `see`. `GET /tools` on the loopback relay
|
|
120
|
+
Every command in `data/commands.json` is one MCP tool with the same name and argument schema, plus `pair`, `guide` (plain-text agent guidance by topic, no pairing needed; `dialect` is every script helper by signature; `errors.<code>` topics carry the recovery for an error code), `list_helpers` (the helper registry as JSON: `{ names?, group?, match?, page? }`, full doc and examples with `names`), and five in-process prompt tools. Every `insert_*` description ends with the code its block carries at default arguments. The guide topics are also MCP resources (`surfcad://guide/<topic>`, versioned with this package). Every error payload carries `hint` (the next call to make) and, where a topic exists, `see`. `GET /tools` on the loopback relay and that file list the bridge tools. `list_commands` returns those plus every other tool this server registers (`pair`, `guide`, `list_helpers`, and the prompt tools, including `reply_to_user` and `set_status`), in the `agent` group. Prefer `insert_*` feature tools. `set_script` is the freehand fallback and requires `part_id`.
|
|
73
121
|
|
|
74
122
|
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).
|
|
75
123
|
|
|
76
|
-
Results are compact JSON. Every tool whose result carries `status` (the model-changing tools, `undo`, `redo`, and `status`) takes `return: "status" | "summary" | "full"`; this server sends `"status"` when you leave it out, so `status.script` is omitted and a result stays small. `"summary"` adds `status.features` (the feature strip); `"full"` echoes the script. `get_script` reads the script, and `get_script { range: { fromFeature, toFeature } }` reads one span of feature blocks. The lists are filtered in the tab: `list_faces { filter: { kind, normalWithin: { n, deg }, minArea, maxArea, bbox }, page: { offset, limit } }`, `list_edges` / `list_feature_edges { filter: { between: [faceKeyA, faceKeyB], minLength, maxLength, bbox }, page }`; every list result carries `total` and `returned`. `list_commands { group }` returns one group of tools (`core`, `feature`, `insert`, `pick`, `sketch`, `document`, `joint`, `paint`, `measure`, `fea`, `sheet`, `git`, `export`, `view`, `agent`) instead of the whole
|
|
124
|
+
Results are compact JSON. Every tool whose result carries `status` (the model-changing tools, `undo`, `redo`, and `status`) takes `return: "status" | "summary" | "full"`; this server sends `"status"` when you leave it out, so `status.script` is omitted and a result stays small. `"summary"` adds `status.features` (the feature strip); `"full"` echoes the script. `get_script` reads the script, and `get_script { range: { fromFeature, toFeature } }` reads one span of feature blocks. The lists are filtered in the tab: `list_faces { filter: { kind, normalWithin: { n, deg }, minArea, maxArea, bbox }, page: { offset, limit } }`, `list_edges` / `list_feature_edges { filter: { between: [faceKeyA, faceKeyB], minLength, maxLength, bbox }, page }`; every list result carries `total` and `returned`. `list_commands { group }` returns one group of tools (`core`, `feature`, `insert`, `pick`, `sketch`, `document`, `joint`, `paint`, `measure`, `fea`, `sheet`, `git`, `export`, `view`, `agent`) instead of the whole catalog, and `list_commands { names }` returns just those. With no filter it includes the MCP-only tools as well as the bridge catalog.
|
|
77
125
|
|
|
78
126
|
| Tool | Args | What it does |
|
|
79
127
|
| --- | --- | --- |
|
|
@@ -87,12 +135,13 @@ Results are compact JSON. Every tool whose result carries `status` (the model-ch
|
|
|
87
135
|
| `rename_assembly` | `{ assembly_id, name }` | Working-copy assembly label. Names may collide. No git write. |
|
|
88
136
|
| `part_get_transform` | `{ part_id }` | Read placement: `position` mm and intrinsic XYZ Euler degrees. |
|
|
89
137
|
| `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. |
|
|
138
|
+
| `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. A `face_id` axis pick is never ambiguous; a real tie returns `details.candidates`. |
|
|
139
|
+
| `joint_delete` | `{ joint_id }` | Remove one joint. One assembly undo step. A part move that joint does not name stays. |
|
|
91
140
|
| `set_active_part` | `{ part_id }` | Switch the editor and mesh. `status` then reports that part. |
|
|
92
141
|
| `open_assembly` | `{ assembly_id }` | Open a vault assembly by id. A name or path is `unknown_assembly`. |
|
|
93
142
|
| `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. |
|
|
94
|
-
| `delete_part` | `{ part_id, scope, confirm? }` | `scope: "assembly"` drops the row. `scope: "repo"`
|
|
95
|
-
| `delete_assembly` | `{ assembly_id, confirm: true, delete_parts? }` | Delete
|
|
143
|
+
| `delete_part` | `{ part_id, scope, confirm? }` | `scope: "assembly"` drops the row and does not commit. `scope: "repo"` deletes `parts/<id>.js` in one commit after `confirm: true` and returns the assemblies that use the part. A failed scan is `delete_refused`. |
|
|
144
|
+
| `delete_assembly` | `{ assembly_id, confirm: true, delete_parts? }` | Delete that assembly whether it is open or not. `confirm: true` required. A committed assembly is one commit; a never-saved open assembly leaves the working copy only. |
|
|
96
145
|
| `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. |
|
|
97
146
|
| `git_add_to_repo` | `{ message }` | Alias of `git_save`. Prefer `git_save`. |
|
|
98
147
|
| `git_move_to_repo` | `{ vault_name? }` | First Save of a local assembly. Consent on a real repo. |
|
|
@@ -116,13 +165,15 @@ These five tools stay inside the local `surfcad-mcp` process. They are not SurfC
|
|
|
116
165
|
| --- | --- | --- |
|
|
117
166
|
| `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. |
|
|
118
167
|
| `unregister_webhook` | `{}` | Drop that URL and bearer. Later prompts are queued. |
|
|
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` | `{
|
|
168
|
+
| `read_messages` | `{ max?, wait_ms? }` | 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. Every response includes `recent`: the last 50 prompts this session received, oldest first, each `{ id, state }`, in memory only. `acked` is only the ids this call removed. A later `read_messages {}` with an empty queue still lists those ids, so you can recover one after the ack. `status.last` is only the newest. When you finish the task from a prompt you received, close that chat with `reply_to_user`. |
|
|
169
|
+
| `reply_to_user` | `{ in_reply_to, text, final? }` | Plain-text reply for a prompt id this session received. 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, including after `read_messages` has acked it. `final: true` marks the agent idle. An `in_reply_to` that was never delivered to this session is `unknown_prompt` and nothing is sent to the tab. A cancelled id returns `{ "ok": false, "error": "cancelled" }` and is not shown in the tab. |
|
|
170
|
+
| `set_status` | `{ state, label?, id? }` | Progress only. It does not close the task; a closing `reply_to_user` does. `state: "responding"` (alias `typing`) keeps the chat open with bouncing dots. `state: "building"` (alias `working`) means you are creating or editing geometry: the chat collapses and the field shows "Agent is working...". Call `building` only once you have everything you need and are actually modeling. Listing parts, faces, edges, or transforms, `status`, and `read_messages` must not use `building`. The legacy boolean `working: true` is `building`. A model-changing tool also enters building if you skip the call. Building stays until the final reply, Stop, or disconnect. No activity for 15 minutes, while responding or building, shows the stall notice and leaves Stop up. A cancelled id returns `{ "ok": false, "error": "cancelled" }`. |
|
|
122
171
|
|
|
123
172
|
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`.
|
|
124
173
|
|
|
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.
|
|
174
|
+
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. Call `set_status { state: "building" }` only once you have everything you need and are actually creating or editing geometry. Reads stay on responding.
|
|
175
|
+
|
|
176
|
+
`reply_to_user` only accepts an `in_reply_to` that this session received (queued, delivered by webhook or `read_messages`, or already replied). Any other id is an error `unknown_prompt` and no `agent.reply` is sent. The page also drops a reply whose id is not a prompt the user sent, so it is not drawn in the chat. `read_messages` includes `recent`, the last 50 prompts in this session (`{ id, state }`, oldest first, memory only). That list stays after the ack, including when the queue is empty. `status.last` is only the newest id.
|
|
126
177
|
|
|
127
178
|
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`.
|
|
128
179
|
|
package/bin/surfcad-mcp.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { runCli } from '../src/cli.mjs';
|
|
2
3
|
import { runSurfcadMcpServer } from '../src/server.mjs';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
try {
|
|
6
|
+
const outcome = await runCli(process.argv.slice(2));
|
|
7
|
+
if (outcome.action === 'exit') process.exit(outcome.code);
|
|
8
|
+
await runSurfcadMcpServer({
|
|
9
|
+
mode: outcome.mode,
|
|
10
|
+
server: outcome.server,
|
|
11
|
+
name: outcome.name,
|
|
12
|
+
});
|
|
13
|
+
} catch (err) {
|
|
14
|
+
console.error(err?.stack || err?.message || err);
|
|
6
15
|
process.exit(1);
|
|
7
|
-
}
|
|
16
|
+
}
|