machine-bridge-mcp 0.16.2 → 0.17.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/CONTRIBUTING.md +14 -0
  3. package/README.md +11 -1
  4. package/SECURITY.md +9 -1
  5. package/browser-extension/manifest.json +2 -2
  6. package/browser-extension/service-worker.js +52 -29
  7. package/docs/ARCHITECTURE.md +4 -2
  8. package/docs/CLIENTS.md +2 -0
  9. package/docs/ENGINEERING.md +3 -1
  10. package/docs/GETTING_STARTED.md +400 -0
  11. package/docs/MULTI_ACCOUNT.md +406 -0
  12. package/docs/PROJECT_STANDARDS.md +143 -0
  13. package/docs/RELEASING.md +12 -0
  14. package/docs/TESTING.md +7 -5
  15. package/docs/TOOL_REFERENCE.md +2836 -0
  16. package/package.json +13 -4
  17. package/scripts/commit-message-check.mjs +63 -0
  18. package/scripts/coverage-check.mjs +9 -1
  19. package/scripts/generate-policy-reference.mjs +1 -4
  20. package/scripts/generate-tool-reference.mjs +87 -0
  21. package/scripts/generate-worker-types.mjs +19 -0
  22. package/scripts/markdown.mjs +9 -0
  23. package/src/local/agent-context.mjs +8 -15
  24. package/src/local/cli.mjs +1 -107
  25. package/src/local/daemon-process.mjs +16 -4
  26. package/src/local/default-instructions.mjs +2 -45
  27. package/src/local/git-service.mjs +4 -9
  28. package/src/local/managed-job-plan.mjs +2 -7
  29. package/src/local/managed-jobs.mjs +2 -7
  30. package/src/local/numbers.mjs +9 -0
  31. package/src/local/process-execution.mjs +4 -9
  32. package/src/local/process-sessions.mjs +5 -10
  33. package/src/local/project-metadata.mjs +50 -0
  34. package/src/local/project-package.mjs +2 -45
  35. package/src/local/records.mjs +5 -0
  36. package/src/local/runtime.mjs +5 -12
  37. package/src/local/state-inventory.mjs +139 -0
  38. package/src/local/workspace-file-service.mjs +6 -12
  39. package/src/worker/index.ts +33 -17
  40. package/tsconfig.json +1 -1
  41. package/src/worker/worker-configuration.d.ts +0 -14716
@@ -0,0 +1,400 @@
1
+ # Installation and first-use guide
2
+
3
+ This guide covers a clean installation, the first remote ChatGPT connection, local stdio clients, browser setup, routine operation, upgrades, troubleshooting, and removal.
4
+
5
+ ## 1. Decide which connection mode you need
6
+
7
+ Machine Bridge has two transports. Choose one before installing:
8
+
9
+ | Requirement | Use | Cloudflare required | Process that must remain available |
10
+ |---|---|---:|---|
11
+ | ChatGPT web, a hosted agent, or another device must reach this computer | Remote HTTPS/OAuth | Yes | Machine Bridge daemon or installed login service |
12
+ | Claude Desktop, Cursor, Codex, ChatGPT Desktop, or another local host runs on this computer | Local stdio | No | The MCP host launches Machine Bridge as a subprocess |
13
+ | The local coding client already has equivalent file, Git, patch, and terminal tools | Neither | No | None |
14
+
15
+ Remote and stdio modes use the same local runtime and policy model. The remote Worker authenticates and relays calls; it does not read files or execute processes by itself.
16
+
17
+ ## 2. Understand the authority you are granting
18
+
19
+ A new workspace uses the `full` profile unless another profile is selected explicitly. `full` exposes the complete tool catalog, shell execution, paths outside the selected workspace, absolute paths, and the complete parent process environment. It is intended for a trusted owner using a trusted MCP host.
20
+
21
+ For a first connection to an unfamiliar host, start with a narrower profile:
22
+
23
+ ```sh
24
+ machine-mcp --workspace /path/to/project --profile review
25
+ ```
26
+
27
+ Profiles:
28
+
29
+ | Profile | Reads | File changes | Direct processes | Shell | Direct filesystem scope |
30
+ |---|---:|---:|---:|---:|---|
31
+ | `full` | Yes | Yes | Yes | Yes | Unrestricted |
32
+ | `agent` | Yes | Yes | Yes | No | Selected workspace |
33
+ | `edit` | Yes | Yes | No | No | Selected workspace |
34
+ | `review` | Yes | No | No | No | Selected workspace |
35
+
36
+ A profile is a Machine Bridge policy ceiling. The MCP host, operating system, endpoint-security software, container, and cloud platform may impose additional restrictions.
37
+
38
+ ## 3. Prerequisites
39
+
40
+ Required for every installation:
41
+
42
+ - Node.js 26 or newer;
43
+ - npm 12 or newer;
44
+ - macOS, Linux, or Windows;
45
+ - a local user account permitted to read or modify the selected workspace.
46
+
47
+ Remote mode additionally requires:
48
+
49
+ - a Cloudflare account permitted to deploy Workers and Durable Objects;
50
+ - a browser available for Wrangler sign-in;
51
+ - outbound HTTPS and WebSocket access from the computer running the daemon.
52
+
53
+ Browser automation additionally requires:
54
+
55
+ - a Chromium-based browser that can load an unpacked Manifest V3 extension;
56
+ - the extension loaded into the browser profile whose tabs and login state should be controlled.
57
+
58
+ Check the installed runtimes:
59
+
60
+ ```sh
61
+ node --version
62
+ npm --version
63
+ ```
64
+
65
+ Do not continue with an older runtime. This repository intentionally rejects unsupported Node/npm versions.
66
+
67
+ ## 4. Install the released package
68
+
69
+ Use a temporary package-free directory. An older npm front-end can inspect metadata in the current directory before it launches npm 12; the isolated bootstrap prevents an unrelated project configuration from breaking installation.
70
+
71
+ ### macOS and Linux
72
+
73
+ ```sh
74
+ install_dir="$(mktemp -d)"
75
+ (
76
+ cd "$install_dir"
77
+ npx --yes npm@12.0.1 install --global npm@12.0.1
78
+ npx --yes npm@12.0.1 install --global --omit=optional --allow-scripts=esbuild,workerd,sharp,fsevents machine-bridge-mcp@latest
79
+ )
80
+ rm -rf "$install_dir"
81
+
82
+ npm --version
83
+ machine-mcp doctor
84
+ ```
85
+
86
+ ### Windows Command Prompt
87
+
88
+ ```bat
89
+ set "MBM_INSTALL_DIR=%TEMP%\machine-bridge-mcp-install-%RANDOM%-%RANDOM%"
90
+ mkdir "%MBM_INSTALL_DIR%"
91
+ pushd "%MBM_INSTALL_DIR%"
92
+ npx --yes npm@12.0.1 install --global npm@12.0.1
93
+ npx --yes npm@12.0.1 install --global --omit=optional --allow-scripts=esbuild,workerd,sharp,fsevents machine-bridge-mcp@latest
94
+ popd
95
+ rmdir /s /q "%MBM_INSTALL_DIR%"
96
+
97
+ npm --version
98
+ machine-mcp doctor
99
+ ```
100
+
101
+ Reopen the terminal if `npm --version` still resolves to an older global installation.
102
+
103
+ ### Run from a source checkout
104
+
105
+ macOS/Linux:
106
+
107
+ ```sh
108
+ git clone https://github.com/YuLeiFuYun/machine-bridge-mcp.git
109
+ cd machine-bridge-mcp
110
+ npm install
111
+ ./mbm
112
+ ```
113
+
114
+ Windows Command Prompt:
115
+
116
+ ```bat
117
+ git clone https://github.com/YuLeiFuYun/machine-bridge-mcp.git
118
+ cd machine-bridge-mcp
119
+ npm install
120
+ .\mbm.cmd
121
+ ```
122
+
123
+ Source installs are for development or review. Released installations should normally use the global package command above.
124
+
125
+ ## 5. Interpret the initial doctor result
126
+
127
+ Run:
128
+
129
+ ```sh
130
+ machine-mcp doctor
131
+ ```
132
+
133
+ The command checks the local runtime, package layout, Wrangler availability, Cloudflare login state, and known Worker health. Before the first remote deployment, a missing Cloudflare login or Worker is expected; local runtime failures are not.
134
+
135
+ Common installation failures:
136
+
137
+ | Message or symptom | Meaning | Corrective action |
138
+ |---|---|---|
139
+ | `Unknown cli config "--allow-scripts"` | npm 11 or older executed the install | Repeat the isolated npm 12 bootstrap |
140
+ | `Invalid property "node"` or `Invalid property "devEngines.node"` | An old npm parser inspected incompatible project metadata | Run the install from a new empty temporary directory |
141
+ | `machine-mcp: command not found` | The global npm binary directory is not on `PATH` | Reopen the terminal, inspect `npm prefix -g`, and add its binary directory to `PATH` |
142
+ | Native package install warning | npm did not approve reviewed native build scripts | Use the documented `--allow-scripts` and `--omit=optional` command exactly |
143
+
144
+ ## 6. First remote start
145
+
146
+ Choose the exact workspace to expose. Prefer an explicit path rather than relying on the current directory:
147
+
148
+ ```sh
149
+ machine-mcp --workspace /path/to/project
150
+ ```
151
+
152
+ For a narrower first run:
153
+
154
+ ```sh
155
+ machine-mcp --workspace /path/to/project --profile review
156
+ ```
157
+
158
+ The first start performs these operations:
159
+
160
+ 1. canonicalizes and remembers the workspace;
161
+ 2. creates owner-only per-workspace state and credentials;
162
+ 3. opens the Wrangler/Cloudflare sign-in flow when required;
163
+ 4. deploys a Worker and Durable Object for that workspace;
164
+ 5. installs a platform-native login service unless `--no-autostart` is supplied;
165
+ 6. starts an outbound authenticated WebSocket from the local daemon to the Worker;
166
+ 7. prints the remote `/mcp` URL and a connection password.
167
+
168
+ The foreground command remains attached to the terminal. Keep it running while testing. The remote Worker cannot execute local tools when no authenticated daemon is connected.
169
+
170
+ To run only in the background after setup:
171
+
172
+ ```sh
173
+ machine-mcp service start
174
+ machine-mcp service status
175
+ ```
176
+
177
+ To avoid installing autostart during a temporary test:
178
+
179
+ ```sh
180
+ machine-mcp --workspace /path/to/project --no-autostart
181
+ ```
182
+
183
+ ## 7. Connect ChatGPT
184
+
185
+ Machine Bridge prints values in this form:
186
+
187
+ ```text
188
+ MCP Server URL: https://<worker>.<account>.workers.dev/mcp
189
+ MCP connection password: mcp_password_...
190
+ ```
191
+
192
+ Treat the connection password as a credential. Do not place it in a repository, issue, screenshot, chat message, shell history note, or shared document.
193
+
194
+ Current ChatGPT developer-mode flow, as documented in OpenAI's [Connect from ChatGPT](https://developers.openai.com/apps-sdk/deploy/connect-chatgpt) guide:
195
+
196
+ 1. Open ChatGPT settings.
197
+ 2. Under **Security and login**, enable **Developer mode** if the account or workspace permits it.
198
+ 3. Open **Plugins** and create a developer-mode app.
199
+ 4. Enter a descriptive name and the exact printed `/mcp` URL.
200
+ 5. Start the connection.
201
+ 6. On the Machine Bridge authorization page, verify the displayed client name, redirect URI, and resource.
202
+ 7. Enter the printed connection password only after those values are recognized.
203
+ 8. Create a new chat and enable the app for that conversation.
204
+
205
+ ChatGPT navigation labels can change. The invariant is that the client must connect to the public `/mcp` endpoint and complete the OAuth authorization page served by the Worker.
206
+
207
+ ## 8. Verify the first connection
208
+
209
+ Ask the MCP host to call these tools in order:
210
+
211
+ 1. `server_info` — proves the request reached the Worker and reports whether a daemon is authenticated;
212
+ 2. `project_overview` — proves the relay reached the selected local runtime;
213
+ 3. `diagnose_runtime` — runs fixed policy, filesystem, process, shell, managed-job, and resource probes permitted by the active profile.
214
+
215
+ For an explicit local acceptance test of the canonical `full` profile:
216
+
217
+ ```sh
218
+ machine-mcp full-test --workspace /path/to/project
219
+ ```
220
+
221
+ A successful local test does not prove that a hosted MCP client exposes every advertised tool. Hosts can independently hide tools or require approvals.
222
+
223
+ ## 9. Configure a local stdio client
224
+
225
+ Generate configurations rather than manually guessing the Node path or package entrypoint:
226
+
227
+ ```sh
228
+ machine-mcp client-config --client all --workspace /path/to/project
229
+ ```
230
+
231
+ Use a narrower policy when appropriate:
232
+
233
+ ```sh
234
+ machine-mcp client-config --client all --workspace /path/to/project --profile agent
235
+ machine-mcp client-config --client all --workspace /path/to/project --profile edit
236
+ machine-mcp client-config --client all --workspace /path/to/project --profile review
237
+ ```
238
+
239
+ The generated command uses absolute executable paths so GUI applications do not depend on a shell-specific `PATH`.
240
+
241
+ A generic stdio invocation is:
242
+
243
+ ```sh
244
+ machine-mcp stdio --workspace /path/to/project --profile full
245
+ ```
246
+
247
+ The host owns the model, conversation, tool-selection loop, and approvals. Machine Bridge supplies tools; it is not a model provider.
248
+
249
+ ## 10. Enable existing-browser automation
250
+
251
+ Run once after installation:
252
+
253
+ ```sh
254
+ machine-mcp browser setup
255
+ machine-mcp browser status
256
+ ```
257
+
258
+ Then:
259
+
260
+ 1. Open the extensions page in the Chromium profile you actually use.
261
+ 2. Enable Developer mode.
262
+ 3. Load the unpacked extension directory printed by `browser setup`.
263
+ 4. Complete the local pairing page.
264
+ 5. Confirm that `machine-mcp browser status` reports the expected packaged version, protocol, and an authenticated connection.
265
+
266
+ Machine Bridge does not launch a separate browser profile. The extension controls the profile into which it was loaded, including its open tabs and logged-in sessions. Reload the unpacked extension after every Machine Bridge upgrade.
267
+
268
+ ## 11. Routine commands
269
+
270
+ ```sh
271
+ machine-mcp status
272
+ machine-mcp doctor
273
+ machine-mcp workspace show
274
+ machine-mcp service status
275
+ machine-mcp browser status
276
+ machine-mcp --print-mcp-credentials
277
+ ```
278
+
279
+ Useful operational actions:
280
+
281
+ ```sh
282
+ machine-mcp service stop
283
+ machine-mcp service start
284
+ machine-mcp rotate-secrets
285
+ machine-mcp resource list
286
+ machine-mcp job list
287
+ ```
288
+
289
+ `rotate-secrets` invalidates previously issued OAuth access tokens and requires clients to reconnect. It is a whole-workspace revocation mechanism in the current release.
290
+
291
+ ## 12. Work with more than one workspace
292
+
293
+ Each canonical workspace receives independent state, policy, credentials, Worker name, resource registry, job directory, startup lock, and daemon lock. Select workspaces explicitly:
294
+
295
+ ```sh
296
+ machine-mcp --workspace /path/to/project-a
297
+ machine-mcp --workspace /path/to/project-b
298
+ ```
299
+
300
+ Do not point two logical trust domains at one broad parent directory merely to reduce configuration. A workspace is an authorization boundary for confined profiles and an operational identity even when `full` permits paths outside it.
301
+
302
+ ## 13. Upgrade
303
+
304
+ Repeat the isolated global installation, then start Machine Bridge in the target workspace:
305
+
306
+ ```sh
307
+ install_dir="$(mktemp -d)"
308
+ (
309
+ cd "$install_dir"
310
+ npx --yes npm@12.0.1 install --global npm@12.0.1
311
+ npx --yes npm@12.0.1 install --global --omit=optional --allow-scripts=esbuild,workerd,sharp,fsevents machine-bridge-mcp@latest
312
+ )
313
+ rm -rf "$install_dir"
314
+
315
+ machine-mcp --workspace /path/to/project --verbose
316
+ ```
317
+
318
+ The foreground start performs bounded takeover of an old verified daemon when safe. If it refuses:
319
+
320
+ ```sh
321
+ machine-mcp service status
322
+ machine-mcp service stop
323
+ machine-mcp --workspace /path/to/project --verbose
324
+ ```
325
+
326
+ After upgrading, reload the unpacked browser extension before relying on browser tools.
327
+
328
+ ## 14. Troubleshooting by layer
329
+
330
+ Use the first failing layer rather than changing unrelated settings.
331
+
332
+ ### Package or runtime layer
333
+
334
+ ```sh
335
+ node --version
336
+ npm --version
337
+ which machine-mcp # macOS/Linux
338
+ where machine-mcp # Windows
339
+ machine-mcp doctor
340
+ ```
341
+
342
+ ### Cloudflare/deployment layer
343
+
344
+ ```sh
345
+ machine-mcp doctor
346
+ machine-mcp status
347
+ machine-mcp --workspace /path/to/project --force-worker --verbose
348
+ ```
349
+
350
+ A forced deployment changes cloud state. Use it only when the normal deployment hash/health reconciliation is insufficient.
351
+
352
+ ### Local service/daemon layer
353
+
354
+ ```sh
355
+ machine-mcp service status
356
+ machine-mcp service stop
357
+ machine-mcp service start
358
+ ```
359
+
360
+ A connected Worker with no authenticated daemon can authorize OAuth successfully but cannot execute local tools.
361
+
362
+ ### MCP-host layer
363
+
364
+ If `server_info` or `project_overview` never returns a structured Machine Bridge result, the host may not have delivered the call. Check the host's plugin/app enablement, tool permissions, approval UI, and connection status.
365
+
366
+ ### Operating-system layer
367
+
368
+ If `diagnose_runtime` reaches the daemon but a probe fails, inspect filesystem permissions, macOS TCC/SIP, Windows ACLs, endpoint-security policy, shell availability, or container restrictions. Changing Machine Bridge to `full` cannot override the operating system.
369
+
370
+ ### Browser layer
371
+
372
+ ```sh
373
+ machine-mcp browser status
374
+ machine-mcp browser setup
375
+ ```
376
+
377
+ Verify that the extension is loaded in the intended profile, its version matches the installed package, and its badge reports authenticated readiness.
378
+
379
+ For detailed recovery procedures, see [OPERATIONS.md](OPERATIONS.md).
380
+
381
+ ## 15. Remove Machine Bridge
382
+
383
+ Remove the selected deployment, service, and local state:
384
+
385
+ ```sh
386
+ machine-mcp uninstall
387
+ npm uninstall -g machine-bridge-mcp
388
+ ```
389
+
390
+ Keep the deployed Worker while removing local state and autostart:
391
+
392
+ ```sh
393
+ machine-mcp uninstall --keep-worker
394
+ ```
395
+
396
+ Uninstall is fail-closed. If a verified daemon, active managed job, unreadable lock, or service removal cannot be resolved safely, Machine Bridge retains state for diagnosis instead of deleting only part of the installation.
397
+
398
+ ## 16. Before sharing access
399
+
400
+ The current release supports multiple OAuth client registrations but not isolated multi-user tenancy. Different ChatGPT accounts can technically authorize against the same Worker if they know the shared connection password, but they receive the same workspace authority and cannot be managed as independent principals. Read [MULTI_ACCOUNT.md](MULTI_ACCOUNT.md) before sharing a deployment.