machine-bridge-mcp 0.5.0 → 0.6.0
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/CHANGELOG.md +27 -0
- package/README.md +93 -5
- package/SECURITY.md +33 -3
- package/docs/ARCHITECTURE.md +41 -8
- package/docs/CLIENTS.md +13 -2
- package/docs/LOGGING.md +3 -1
- package/docs/MANAGED_JOBS.md +274 -0
- package/docs/OPERATIONS.md +55 -4
- package/docs/TESTING.md +6 -1
- package/package.json +5 -4
- package/src/local/cli.mjs +192 -5
- package/src/local/daemon.mjs +101 -1
- package/src/local/job-runner.mjs +470 -0
- package/src/local/managed-jobs.mjs +854 -0
- package/src/local/state.mjs +51 -8
- package/src/local/stdio.mjs +2 -2
- package/src/shared/server-metadata.json +8 -1
- package/src/shared/tool-catalog.json +498 -0
- package/src/worker/index.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0 - 2026-07-10
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Add `diagnose_runtime`, a fixed-input layered diagnostic that distinguishes requests reaching the daemon from Machine Bridge policy, local filesystem, process-spawn, shell, managed-job storage, and registered-resource failures. `machine-mcp doctor` runs the same local probes.
|
|
8
|
+
- Add operator-registered local file resources. Credentials and other local-only files can be referenced by alias and injected into managed steps through a private copied path, stdin, or an environment variable without sending file contents or source paths through MCP.
|
|
9
|
+
- Add durable managed jobs with ordered argv steps, bounded output, job-scoped temporary files, detached execution, cancellation, idempotent `finally_steps`, dead-runner detection, bounded recovery, and local CLI inspection/cancellation.
|
|
10
|
+
- Add two-phase handoff: `stage_job` persists a validated non-running plan for operator review, and `machine-mcp job approve JOB_ID` provides explicit local authorization when a host blocks execution-class tools.
|
|
11
|
+
- Add a local JSON fallback with `machine-mcp job submit plan.json` for situations where the MCP host cannot deliver an execution request.
|
|
12
|
+
|
|
13
|
+
### Security and privacy
|
|
14
|
+
|
|
15
|
+
- Keep resource values out of MCP plans and results. Referenced files are reopened, bounded, hashed at acceptance, verified before use, copied with owner-only permissions, and removed after cleanup.
|
|
16
|
+
- Redact exact resource paths, exact UTF-8 values, and bounded exact base64/hex forms from retained output. Add `capture_output: "discard"` for credential-consuming commands where output must not be retained.
|
|
17
|
+
- Delete active job plans, runner PID files, temporary helper contents, argv, stdin, environment overrides, resource source paths, and hashes after terminal commit. Retain only bounded status/redacted results for up to seven days and 50 jobs.
|
|
18
|
+
- Enforce canonical managed-job cwd containment in restricted profiles, bounded per-job resources/temporary files/output, no-follow plan/resource reads, owner-only job state, bounded runner diagnostics, recovery mutual exclusion, and a three-attempt automatic recovery limit.
|
|
19
|
+
- Refuse uninstall while detached jobs remain active. Later profile changes affect new submissions; accepted running jobs require explicit cancellation.
|
|
20
|
+
- Clarify that managed jobs are durability and local-authorization mechanisms, not a bypass for MCP-host, operating-system, or endpoint-security policy.
|
|
21
|
+
|
|
22
|
+
### Operations and tests
|
|
23
|
+
|
|
24
|
+
- Add local resource commands: `resource add`, `list`, `check`, and `remove`.
|
|
25
|
+
- Add local managed-job commands: `job submit`, `inspect`, `approve`, `list`, `read`, and `cancel`. Approval is interactive by default; `--yes` is required for non-interactive JSON approval.
|
|
26
|
+
- Add state schema version 5 for resource registry metadata while redacting resource source paths from normal status output.
|
|
27
|
+
- Add regression coverage for staging/approval/cancel-before-start, stdio disconnect survival, resource replacement races and output redaction, job-scoped helper cleanup, failure/timeout/cancellation finally paths, concurrent recovery, corrupt plans, output budgets, local CLI fallback, uninstall refusal, and cross-profile tool exposure.
|
|
28
|
+
- Add a dedicated managed-jobs/resource operations and threat-model guide.
|
|
29
|
+
|
|
3
30
|
## 0.5.0 - 2026-07-10
|
|
4
31
|
|
|
5
32
|
### Changed
|
package/README.md
CHANGED
|
@@ -21,13 +21,13 @@ Local clients such as Claude Desktop, Cursor, and Codex CLI
|
|
|
21
21
|
local runtime
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
The remote Worker authenticates and relays calls. It cannot directly read local files or start local processes. File, Git, image, patch, and
|
|
24
|
+
The remote Worker authenticates and relays calls. It cannot directly read local files or start local processes. File, Git, image, patch, process, diagnostic, and managed-job operations execute in the local runtime.
|
|
25
25
|
|
|
26
26
|
## Default behavior and policy profiles
|
|
27
27
|
|
|
28
28
|
A newly selected workspace starts with the maximum-permission `full` profile for low-friction operation:
|
|
29
29
|
|
|
30
|
-
- all read, write, edit, patch, image, Git, direct-process, process-session, and shell tools are available;
|
|
30
|
+
- all read, write, edit, patch, image, Git, diagnostic, direct-process, process-session, managed-job, and shell tools are available;
|
|
31
31
|
- direct filesystem tools may use paths outside the selected workspace;
|
|
32
32
|
- tool results may return absolute paths;
|
|
33
33
|
- child processes inherit the complete parent environment.
|
|
@@ -134,6 +134,80 @@ Important distinctions:
|
|
|
134
134
|
- The server has no filename blacklist. Under `full`, direct read tools may read any UTF-8 regular file that the local OS user can access, including files outside the workspace and names such as `.env`, `passwords.txt`, or private-key files.
|
|
135
135
|
- Maximum local policy does not override operating-system permissions, macOS TCC/SIP, Windows ACLs, container boundaries, or independent safety rules imposed by the MCP host/platform. A host-generated “sensitive file” denial is outside this server's enforcement layer.
|
|
136
136
|
|
|
137
|
+
## Diagnose host, bridge, and local execution failures
|
|
138
|
+
|
|
139
|
+
A displayed `full` policy proves only that Machine Bridge has enabled its own capabilities. Execution can still be denied by the MCP host/connector, macOS TCC/SIP, Unix permissions, Windows ACLs, shell policy, or endpoint-security software.
|
|
140
|
+
|
|
141
|
+
Use:
|
|
142
|
+
|
|
143
|
+
```text
|
|
144
|
+
diagnose_runtime
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
or locally:
|
|
148
|
+
|
|
149
|
+
```sh
|
|
150
|
+
machine-mcp doctor
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
A successful `diagnose_runtime` response proves that request reached the local daemon. It then reports fixed probes for Machine Bridge policy, private filesystem access, direct process spawning, shell execution, managed-job storage, and registered resources. If the host blocks the tool call before any structured response, the server cannot diagnose that request because it never received it.
|
|
154
|
+
|
|
155
|
+
## Managed jobs and local resources
|
|
156
|
+
|
|
157
|
+
Long, remote, multi-step, or cleanup-sensitive work should not depend on a sequence of later MCP calls remaining available. `start_job` durably accepts ordered argv steps plus `finally_steps`, then launches an independent local runner. It continues after MCP disconnects or later host-side tool refusals.
|
|
158
|
+
|
|
159
|
+
When the host blocks execution-class tools but still permits state mutation, `stage_job` stores the same validated plan without starting any process. The operator can review it with `machine-mcp job inspect JOB_ID` and explicitly authorize execution with `machine-mcp job approve JOB_ID`. Cancelling a staged plan does not run main or finally steps.
|
|
160
|
+
|
|
161
|
+
Register credential/key files locally without sending their contents through MCP:
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
chmod 600 ~/.ssh/racknerd_ed25519
|
|
165
|
+
machine-mcp resource add racknerd-key ~/.ssh/racknerd_ed25519
|
|
166
|
+
machine-mcp resource list
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
A job refers to the alias rather than the value:
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"name": "remote maintenance",
|
|
174
|
+
"steps": [
|
|
175
|
+
{
|
|
176
|
+
"argv": [
|
|
177
|
+
"ssh",
|
|
178
|
+
"-i",
|
|
179
|
+
"{{resource:racknerd-key}}",
|
|
180
|
+
"root@example",
|
|
181
|
+
"sh",
|
|
182
|
+
"-s"
|
|
183
|
+
],
|
|
184
|
+
"stdin": "set -eu\n# remote repair commands\n"
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
"finally_steps": [
|
|
188
|
+
{
|
|
189
|
+
"argv": ["ssh", "-i", "{{resource:racknerd-key}}", "root@example", "rm", "-f", "/tmp/helper"],
|
|
190
|
+
"allow_failure": true
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Prefer sending a remote script through stdin so no remote helper file is created. For local helpers, use job-scoped `temporary_files` and `{{temp:name}}`; the private job runtime is removed after cleanup.
|
|
197
|
+
|
|
198
|
+
Resources can be injected by private copied path (`{{resource:name}}`), `stdin_resource`, or `env_resources`. Use `capture_output: "discard"` for commands that may echo credentials. Exact resource values and common exact encodings are redacted from retained results, but transformed or partial-secret detection is not guaranteed.
|
|
199
|
+
|
|
200
|
+
If the MCP host later blocks all execution tools, use the local fallback:
|
|
201
|
+
|
|
202
|
+
```sh
|
|
203
|
+
machine-mcp job list
|
|
204
|
+
machine-mcp job read JOB_ID
|
|
205
|
+
machine-mcp job cancel JOB_ID
|
|
206
|
+
machine-mcp job submit plan.json
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Finally steps and restart recovery are best effort and should be idempotent. See [docs/MANAGED_JOBS.md](docs/MANAGED_JOBS.md) for lifecycle, security limits, plan format, and diagnosis guidance.
|
|
210
|
+
|
|
137
211
|
## Tools
|
|
138
212
|
|
|
139
213
|
The exact `tools/list` response reflects the active local policy. Definitions come from one shared catalog used by both Worker and stdio transports.
|
|
@@ -164,6 +238,18 @@ The exact `tools/list` response reflects the active local policy. Definitions co
|
|
|
164
238
|
|
|
165
239
|
Repository-configured external diff, text conversion, and filesystem-monitor helpers are disabled for bridge Git inspection.
|
|
166
240
|
|
|
241
|
+
### Diagnostics and durable work
|
|
242
|
+
|
|
243
|
+
- `diagnose_runtime` — fixed layered probes; no user-controlled command input
|
|
244
|
+
- `list_local_resources` — aliases and validation status without paths or values
|
|
245
|
+
- `stage_job` — persist a validated plan for later local approval without executing it
|
|
246
|
+
- `start_job` — detached ordered argv steps, private temporary files, and finally steps
|
|
247
|
+
- `list_jobs`
|
|
248
|
+
- `read_job`
|
|
249
|
+
- `cancel_job`
|
|
250
|
+
|
|
251
|
+
Managed jobs are non-interactive and persist independently of the MCP connection. Process sessions remain interactive and memory-only.
|
|
252
|
+
|
|
167
253
|
### Processes
|
|
168
254
|
|
|
169
255
|
- `run_process` — one-shot argv execution without a shell
|
|
@@ -194,6 +280,8 @@ machine-mcp service status|install|start|stop|uninstall
|
|
|
194
280
|
machine-mcp status
|
|
195
281
|
machine-mcp doctor
|
|
196
282
|
machine-mcp rotate-secrets
|
|
283
|
+
machine-mcp resource add|list|check|remove
|
|
284
|
+
machine-mcp job submit|inspect|approve|list|read|cancel
|
|
197
285
|
machine-mcp --print-mcp-credentials
|
|
198
286
|
machine-mcp uninstall [--keep-worker] [--yes]
|
|
199
287
|
```
|
|
@@ -227,7 +315,7 @@ Default state roots:
|
|
|
227
315
|
- Linux with `XDG_STATE_HOME`: `$XDG_STATE_HOME/machine-bridge-mcp`
|
|
228
316
|
- Windows: `%APPDATA%\machine-bridge-mcp`
|
|
229
317
|
|
|
230
|
-
State/config writes use owner-only temporary files, flushes, and atomic rename. Malformed state is retained as a bounded corrupt backup before reconstruction. Uninstall validates markers, canonical paths, active locks, workspace/source exclusions, and known contents before recursive deletion.
|
|
318
|
+
State/config writes use owner-only temporary files, flushes, and atomic rename. Malformed state is retained as a bounded corrupt backup before reconstruction. Resource source paths are redacted from `status` output. Active managed-job plans are owner-only and are deleted after a terminal result; bounded redacted results are retained temporarily. Uninstall validates markers, canonical paths, active locks, workspace/source exclusions, and known contents before recursive deletion.
|
|
231
319
|
|
|
232
320
|
Default foreground logs show startup/deployment transitions, relay connectivity, warnings/errors, and successful calls that exceed 30 seconds. Routine successful tool calls and correlation IDs appear only at `--log-level debug` or `--verbose`. Background services use `warn`. Log messages and structured fields are bounded, secret-like keys and known token formats are redacted, and tool arguments/results are not written. See [docs/LOGGING.md](docs/LOGGING.md) and [docs/OPERATIONS.md](docs/OPERATIONS.md).
|
|
233
321
|
|
|
@@ -242,9 +330,9 @@ npm audit --omit=dev --audit-level=high
|
|
|
242
330
|
npm pack --dry-run
|
|
243
331
|
```
|
|
244
332
|
|
|
245
|
-
`npm run check` covers generated Worker types, TypeScript, JavaScript syntax, the shared tool catalog, local path/write/process/state/log/service invariants, a live stdio MCP flow, and a live local OAuth/Worker/WebSocket/MCP flow. GitHub Actions runs the suite on Linux, macOS, and Windows with supported Node versions.
|
|
333
|
+
`npm run check` covers generated Worker types, TypeScript, JavaScript syntax, the shared tool catalog, local path/write/process/state/log/service invariants, managed-job detachment/resource redaction/finally/cancellation/recovery, a live stdio MCP flow, and a live local OAuth/Worker/WebSocket/MCP flow. GitHub Actions runs the suite on Linux, macOS, and Windows with supported Node versions.
|
|
246
334
|
|
|
247
|
-
See [docs/TESTING.md](docs/TESTING.md), [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md), and [SECURITY.md](SECURITY.md).
|
|
335
|
+
See [docs/MANAGED_JOBS.md](docs/MANAGED_JOBS.md), [docs/TESTING.md](docs/TESTING.md), [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md), and [SECURITY.md](SECURITY.md).
|
|
248
336
|
|
|
249
337
|
## Uninstall
|
|
250
338
|
|
package/SECURITY.md
CHANGED
|
@@ -53,7 +53,7 @@ The default `full` profile returns absolute paths. Narrower profiles return work
|
|
|
53
53
|
|
|
54
54
|
The server does not maintain a sensitive-filename blacklist. Under `full`, direct read tools may access any UTF-8 regular file available to the local OS user, including files outside the selected workspace and names such as `.env`, password stores, private keys, credentials, database dumps, and production configuration. Narrower profiles confine direct filesystem tools but do not classify names inside that boundary.
|
|
55
55
|
|
|
56
|
-
Maximum local policy does not bypass Unix permissions, Windows ACLs, macOS TCC/SIP, container/VM boundaries, or security decisions made by the MCP host/platform. A host-side
|
|
56
|
+
Maximum local policy does not bypass Unix permissions, Windows ACLs, macOS TCC/SIP, container/VM boundaries, endpoint-security controls, shell restrictions, or security decisions made by the MCP host/platform. A host-side refusal is independent of Machine Bridge and cannot be disabled by local policy configuration. `diagnose_runtime` and `machine-mcp doctor` use fixed probes to distinguish requests that reached the daemon from local filesystem/process/shell failures; they cannot inspect a call blocked before delivery.
|
|
57
57
|
|
|
58
58
|
Processes are not confined by the filesystem-tool resolver. They can access paths, networks, processes, credential stores, and devices available to the local user.
|
|
59
59
|
|
|
@@ -73,6 +73,32 @@ First-run or explicit reconnect output can intentionally display the MCP connect
|
|
|
73
73
|
|
|
74
74
|
The default `full` profile passes the complete parent environment. Narrower profiles replace HOME, temp, and common cache paths and do not pass arbitrary parent variables. The isolated mode reduces accidental environment-secret leakage; it does not prevent code from explicitly accessing known resources.
|
|
75
75
|
|
|
76
|
+
## Local resources and managed jobs
|
|
77
|
+
|
|
78
|
+
Local resources are registered only through the operator-controlled CLI. State stores canonical paths and metadata, not file contents. Unix-like registration rejects group/other-readable files unless explicitly overridden. Portable mode checks do not fully describe Windows ACLs or extended Unix ACLs; the operator remains responsible for platform permissions.
|
|
79
|
+
|
|
80
|
+
At job acceptance, referenced resources are bounded and hashed. The detached runner reopens and verifies each hash before copying it to a private `0600` runtime file. Resource copies are removed after the finally phase. A changed or unavailable resource fails closed.
|
|
81
|
+
|
|
82
|
+
Resource injection modes have different exposure:
|
|
83
|
+
|
|
84
|
+
- private file-path substitution is generally preferred;
|
|
85
|
+
- stdin avoids process arguments and environment variables;
|
|
86
|
+
- environment injection can be visible to same-user process inspection and inherited child processes.
|
|
87
|
+
|
|
88
|
+
Managed jobs accept arbitrary argv and therefore retain local-user authority. They are a durability mechanism, not a sandbox or an authorization bypass. A running job snapshots execution authority and environment mode at acceptance. Later profile changes affect new jobs but do not silently revoke an accepted running job; explicitly cancel active jobs when revoking authority. The initial job submission remains subject to MCP-host approval and platform safety policy; each child remains subject to local OS and endpoint-security policy.
|
|
89
|
+
|
|
90
|
+
`stage_job` is non-executing and requires write capability. Local `machine-mcp job approve` is a separate operator authorization and may launch a staged plan even when the MCP profile itself has no execution capability. Operators must review the stored plan before approval. Cancelling before approval runs neither main nor finally steps.
|
|
91
|
+
|
|
92
|
+
Active plans are owner-only and may temporarily contain argv, non-secret stdin, temporary helper content, environment overrides, and resource source paths for crash recovery. A terminal runner deletes the full plan. Status and bounded results remain for up to seven days/50 jobs. If a runner crashes before terminal commit, the plan remains until recovery or retention cleanup.
|
|
93
|
+
|
|
94
|
+
Exact resource paths, exact resource bytes interpreted as text, and bounded exact base64/hex forms are redacted from retained output. This cannot detect partial, transformed, encrypted, compressed, or application-specific encodings. It also cannot redact unrelated secrets inherited through the full parent environment. Use `capture_output: "discard"` whenever a process may echo credentials, and never place a secret directly in argv, ordinary env, stdin, temporary-file content, or a JSON plan.
|
|
95
|
+
|
|
96
|
+
`finally_steps` run after ordinary success, failure, timeout, and cancellation. Cancellation uses an owner-only marker rather than signaling the runner process itself, so the coordinator remains alive to execute cleanup consistently across platforms. A dead runner is detected on the next daemon or local job-CLI start; stale private resource copies are removed and cleanup is retried. This is best effort. Power loss, disk failure, permanent loss of credentials/network access, SIGKILL without later recovery, or security software denying the cleanup executable can prevent cleanup. Finally steps must be idempotent and safe to repeat. Automatic recovery is capped at three attempts so persistent endpoint-security or executable-policy denial cannot create an endless launch loop. Uninstall refuses to remove local state while managed jobs are active; operators must inspect or cancel them first.
|
|
97
|
+
|
|
98
|
+
Job-scoped `temporary_files` should be used instead of loose helper scripts. They are materialized only below the private job runtime. Remote scripts should preferably be sent through a process stdin instead of written to the remote filesystem.
|
|
99
|
+
|
|
100
|
+
Runner diagnostic logs are owner-only and do not receive child stdout/stderr. Step output is stored only in bounded job results according to the selected capture mode.
|
|
101
|
+
|
|
76
102
|
## OAuth and public endpoints
|
|
77
103
|
|
|
78
104
|
Remote mode uses authorization code flow with PKCE S256, exact redirect/resource/client binding, expiring authorization codes and access tokens, hashed token storage, token-version revocation, and bounded dynamic client registration.
|
|
@@ -97,6 +123,8 @@ Process-session IDs are random and valid only inside one runtime. Output buffers
|
|
|
97
123
|
|
|
98
124
|
Sessions use pipes, not a PTY. Do not assume terminal-oriented programs will behave safely or correctly. Process output may contain secrets; it is returned to the authorized client but is not intentionally written to operational logs.
|
|
99
125
|
|
|
126
|
+
Process sessions are interactive and intentionally die with runtime disconnect/replacement. Managed jobs are separate detached processes with owner-only persistent state and best-effort finally/recovery semantics.
|
|
127
|
+
|
|
100
128
|
## Images and rich content
|
|
101
129
|
|
|
102
130
|
`view_image` accepts only signature-validated PNG, JPEG, GIF, and WebP under the size cap. SVG is intentionally excluded because it is active document content rather than a simple raster image. Image bytes pass through the Worker in remote mode and are visible to the authorized MCP client.
|
|
@@ -105,7 +133,7 @@ Sessions use pipes, not a PTY. Do not assume terminal-oriented programs will beh
|
|
|
105
133
|
|
|
106
134
|
Default operational logs record startup/connection transitions, failed calls, slow-call duration, and coarse error classes. Routine successful calls and shortened correlation IDs are debug-only. Tool arguments, command text, stdin, file/patch contents, and outputs are omitted. Messages and fields are bounded; unexpected daemon and Worker exceptions are reduced to error classes. Git author email is omitted from `git_log` unless explicitly requested.
|
|
107
135
|
|
|
108
|
-
No logging policy can prevent data from being returned to a client that explicitly invokes an enabled tool. The Worker necessarily relays remote tool arguments and results; this is not end-to-end encryption against the user's Cloudflare execution environment.
|
|
136
|
+
No logging policy can prevent data from being returned to a client that explicitly invokes an enabled tool. The Worker necessarily relays remote tool arguments and results; this is not end-to-end encryption against the user's Cloudflare execution environment. Managed-job result files may contain remote command output and are owner-only local data, not operational logs.
|
|
109
137
|
|
|
110
138
|
## Hardening checklist
|
|
111
139
|
|
|
@@ -130,9 +158,11 @@ Also:
|
|
|
130
158
|
- inspect client names and OAuth redirect URIs;
|
|
131
159
|
- rotate secrets after suspected disclosure;
|
|
132
160
|
- inspect `status`, `doctor`, and service status;
|
|
161
|
+
- register credential files as local resources instead of reading them into a model conversation;
|
|
162
|
+
- use `capture_output: "discard"` for credential-consuming steps and idempotent finally steps for cleanup;
|
|
133
163
|
- remove the Worker and state when remote access is no longer needed;
|
|
134
164
|
- use external OS isolation for untrusted code.
|
|
135
165
|
|
|
136
166
|
## Out of scope
|
|
137
167
|
|
|
138
|
-
The project cannot prevent an authorized client from requesting data accessible to enabled tools, make arbitrary local executables safe, identify all sensitive content, or neutralize model prompt injection. Operator approval and narrow capability selection remain primary controls.
|
|
168
|
+
The project cannot prevent an authorized client from requesting data accessible to enabled tools, make arbitrary local executables safe, identify all sensitive content, guarantee cleanup across every power/storage/security failure, override MCP-host or endpoint-security policy, or neutralize model prompt injection. Operator approval, local resource hygiene, idempotent cleanup, and narrow capability selection remain primary controls.
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -20,7 +20,7 @@ No transport is treated as a sandbox. Both transports invoke the same local runt
|
|
|
20
20
|
|
|
21
21
|
The CLI canonicalizes workspaces, resolves policy profiles, maintains per-workspace state and credentials, serializes startup/deploy/rotation with locks, deploys the Worker, installs optional platform-native autostart, and starts either remote daemon or stdio mode.
|
|
22
22
|
|
|
23
|
-
A canonical workspace receives an independent profile, Worker name, secret set, daemon/startup locks, and state file. State schema version
|
|
23
|
+
A canonical workspace receives an independent profile, Worker name, secret set, resource registry, managed-job directory, daemon/startup locks, and state file. State schema version 5 records policy origin/revision and local resource metadata in addition to the capability fields.
|
|
24
24
|
|
|
25
25
|
### Local runtime
|
|
26
26
|
|
|
@@ -30,12 +30,34 @@ A canonical workspace receives an independent profile, Worker name, secret set,
|
|
|
30
30
|
- file, text search, image, patch, and Git operations;
|
|
31
31
|
- direct and shell process execution;
|
|
32
32
|
- process-session buffers and stdin lifecycle;
|
|
33
|
+
- layered fixed runtime diagnostics;
|
|
34
|
+
- local resource aliases and detached managed-job coordination;
|
|
33
35
|
- mutation serialization;
|
|
34
36
|
- child-process tracking and cancellation;
|
|
35
37
|
- output, traversal, concurrency, and time limits.
|
|
36
38
|
|
|
37
39
|
Remote mode attaches WebSocket connection/reconnect behavior. Stdio mode invokes the same runtime directly.
|
|
38
40
|
|
|
41
|
+
### Managed job runner
|
|
42
|
+
|
|
43
|
+
`ManagedJobManager` persists bounded per-workspace job envelopes below the owner-only profile directory. `start_job` validates the complete plan, snapshots referenced resource metadata/hashes, writes an owner-only plan/status, and launches `job-runner.mjs` as a detached process with runner-level logs redirected to owner-only files. `stage_job` performs the same acceptance validation but writes a non-running `staged` envelope; only local `job approve` transitions it to queued and launches the runner.
|
|
44
|
+
|
|
45
|
+
The runner:
|
|
46
|
+
|
|
47
|
+
- materializes registered resources as private `0600` copies after hash verification;
|
|
48
|
+
- materializes bounded job-scoped temporary files;
|
|
49
|
+
- substitutes resource/temp/runtime/workspace placeholders;
|
|
50
|
+
- executes ordered argv steps with bounded output and timeout/process-tree termination;
|
|
51
|
+
- polls an owner-only cancellation marker, terminates the current child tree, and keeps the runner alive for finally steps;
|
|
52
|
+
- attempts ordered finally steps after success, failure, timeout, or cancellation;
|
|
53
|
+
- removes private runtime copies;
|
|
54
|
+
- writes bounded redacted results and terminal status;
|
|
55
|
+
- deletes the full execution plan and runner PID file after terminal commit.
|
|
56
|
+
|
|
57
|
+
Running managed jobs do not belong to an MCP socket or daemon call ID and snapshot the accepted environment mode/resources. Later profile changes govern new direct submissions; accepted running jobs require explicit cancellation. Staged plans launch no process and require explicit local approval. Daemon disconnect/replacement does not terminate them. Dead runner PIDs are detected on the next daemon or local job-CLI start; stale private runtime data is removed and the finally phase is retried in recovery mode. Recovery deliberately reruns all finally steps, so cleanup must be idempotent.
|
|
58
|
+
|
|
59
|
+
Local resource registrations remain in owner-only state and are reloaded for every new job. MCP-visible resource inventory includes aliases and validation status but never source paths, hashes, or contents.
|
|
60
|
+
|
|
39
61
|
### Stdio MCP server
|
|
40
62
|
|
|
41
63
|
The stdio server implements newline-delimited JSON-RPC over stdin/stdout. It negotiates supported MCP versions, advertises policy-filtered tools, returns text plus structured content, supports native image content, maps cancellation notifications to runtime call IDs, and sends level-filtered logs only to stderr.
|
|
@@ -66,8 +88,12 @@ flowchart LR
|
|
|
66
88
|
L[Local MCP client] -->|stdio JSON-RPC| R
|
|
67
89
|
R -->|canonical workspace tools| F[Selected workspace]
|
|
68
90
|
R -->|optional direct/shell processes| P[Local user / OS / network]
|
|
69
|
-
|
|
91
|
+
R -->|durable accepted plan| J[Detached managed-job runner]
|
|
92
|
+
J -->|private copies| LR[Local resource files]
|
|
93
|
+
J -->|argv/stdin/env| P
|
|
94
|
+
CLI[CLI + owner-only state] --> W
|
|
70
95
|
CLI --> R
|
|
96
|
+
CLI --> J
|
|
71
97
|
CLI --> S[Autostart provider]
|
|
72
98
|
```
|
|
73
99
|
|
|
@@ -86,7 +112,8 @@ Remote OAuth determines which client may call tools. Local stdio access relies o
|
|
|
86
112
|
9. `tools/call` receives a random relay call ID and is bound to the current socket and authenticated client request key.
|
|
87
113
|
10. The runtime validates policy and arguments, executes the tool, and returns a bounded result.
|
|
88
114
|
11. The Durable Object accepts a result only from the socket that received that call.
|
|
89
|
-
12. A matching cancellation notification removes the pending call, tells the daemon to cancel, and terminates any child processes bound to it.
|
|
115
|
+
12. A matching cancellation notification removes the pending call, tells the daemon to cancel, and terminates any ordinary child processes bound to it.
|
|
116
|
+
13. `start_job` is different: after durable acceptance, the detached runner is no longer bound to the relay call or socket. Later cancellation uses `cancel_job` or the local CLI.
|
|
90
117
|
|
|
91
118
|
Duplicate in-flight JSON-RPC IDs for the same access token are rejected so cancellation cannot ambiguously target multiple calls.
|
|
92
119
|
|
|
@@ -98,7 +125,7 @@ Duplicate in-flight JSON-RPC IDs for the same access token are rejected so cance
|
|
|
98
125
|
4. Each call receives an internal random call ID used only for cancellation and process tracking.
|
|
99
126
|
5. Results are emitted as JSON-RPC on stdout; logs remain on stderr.
|
|
100
127
|
6. Duplicate in-flight request IDs are rejected.
|
|
101
|
-
7. Closing stdin cancels pending calls, terminates active processes, and removes the
|
|
128
|
+
7. Closing stdin cancels pending calls, terminates ordinary active processes/process sessions, and removes the transport runtime directory. Previously accepted managed jobs continue in their persistent per-workspace job directories.
|
|
102
129
|
|
|
103
130
|
## Filesystem resolution and privacy
|
|
104
131
|
|
|
@@ -136,7 +163,9 @@ The default `full` profile passes the complete parent environment. Isolated envi
|
|
|
136
163
|
|
|
137
164
|
One-shot calls have bounded output and timeouts. Process sessions retain bounded byte buffers with monotonic offsets, accept bounded stdin, support short output/exit waits, and are capped per runtime. Valid UTF-8 is returned as text; byte slices that are not valid UTF-8 also include lossless base64 data. Session IDs are random. Sessions are memory-only and are killed on runtime stop, remote disconnect, or daemon replacement.
|
|
138
165
|
|
|
139
|
-
Child processes run in a separate process group where supported. Timeout, cancellation, disconnect, and replacement send termination to
|
|
166
|
+
Child processes run in a separate process group where supported. Timeout, cancellation, disconnect, and replacement send termination to ordinary process trees, with forced escalation for timeout/disconnect paths.
|
|
167
|
+
|
|
168
|
+
Managed jobs use the same argv/environment primitives but a different lifecycle. Each job is capped at 16 main and 16 finally steps, 50 retained jobs, 64 registered resources, 8 MiB of referenced resource bytes, 512 KiB of temporary-file content, and bounded per-step output. They are non-interactive. Resource paths/stdin/environment are injected only inside the runner. Exact resource output redaction is defense in depth; discard capture is the strong option when a command may echo credentials.
|
|
140
169
|
|
|
141
170
|
## Daemon reconnect and replacement
|
|
142
171
|
|
|
@@ -146,7 +175,9 @@ Pending calls retain their originating socket reference. A stale socket cannot c
|
|
|
146
175
|
|
|
147
176
|
## Persistence
|
|
148
177
|
|
|
149
|
-
Local state and global config are owner-only, versioned, size-bounded, and written through temporary files, flushes, and atomic rename. Reads reject symbolic links and use no-follow descriptors where supported. Malformed or oversized state becomes a bounded-count `.corrupt-*` backup. Custom roots are adopted only when empty or recognizable as legacy Machine Bridge state.
|
|
178
|
+
Local state and global config are owner-only, versioned, size-bounded, and written through temporary files, flushes, and atomic rename. Reads reject symbolic links and use no-follow descriptors where supported. Malformed or oversized state becomes a bounded-count `.corrupt-*` backup. Resource paths are omitted from redacted status output. Custom roots are adopted only when empty or recognizable as legacy Machine Bridge state.
|
|
179
|
+
|
|
180
|
+
Active managed jobs persist an owner-only plan, status, runner PID, and bounded runner diagnostics. Terminal jobs delete the full plan and retain only bounded status/redacted results for up to seven days. This balances crash cleanup with minimization of scripts, stdin, argv, environment overrides, and resource source paths.
|
|
150
181
|
|
|
151
182
|
Removal validates the state marker, canonical target, known contents, active locks, filesystem root/home/current/package/workspace/source exclusions, and Worker deletion outcome before recursive deletion.
|
|
152
183
|
|
|
@@ -154,7 +185,7 @@ OAuth metadata is pruned on access. Expired codes/tokens, old throttling records
|
|
|
154
185
|
|
|
155
186
|
## Observability
|
|
156
187
|
|
|
157
|
-
Public health exposes only server identity and version. Authenticated `server_info` exposes bounded runtime status
|
|
188
|
+
Public health exposes only server identity and version. Authenticated `server_info` exposes bounded runtime status, policy origin/revision, managed-job counts, and resource alias names without paths or values. `diagnose_runtime` runs fixed local probes and explicitly reports that its own request reached the daemon.
|
|
158
189
|
|
|
159
190
|
Foreground logging defaults to `info`; autostart uses `warn`. Routine successful calls and shortened random correlation IDs are debug-only. `info` retains deployment/connection transitions and successful calls slower than 30 seconds. Failures log tool name, duration, and coarse error class without arguments or outputs. Unexpected local and Worker errors are reduced to classes in normal logs. Messages, strings, arrays, object depth/key counts, and serialized fields are bounded.
|
|
160
191
|
|
|
@@ -165,7 +196,9 @@ Cloudflare sampling is size control rather than an audit log. The project intent
|
|
|
165
196
|
- operating-system sandboxing of arbitrary executables;
|
|
166
197
|
- preventing an authorized client from requesting data available to enabled tools;
|
|
167
198
|
- automatically deciding which local files are sensitive or overriding MCP-host/platform safety policy;
|
|
168
|
-
- surviving daemon restart with process sessions;
|
|
199
|
+
- surviving daemon restart with process sessions (managed jobs are the separate durable mechanism);
|
|
200
|
+
- guaranteed finally cleanup across permanent power, disk, credential, network, or endpoint-security failure;
|
|
201
|
+
- bypassing MCP-host, connector, operating-system, or endpoint-security policy;
|
|
169
202
|
- PTY/terminal emulation;
|
|
170
203
|
- model-level prompt-injection prevention;
|
|
171
204
|
- multi-user tenancy in one Worker deployment.
|
package/docs/CLIENTS.md
CHANGED
|
@@ -35,7 +35,8 @@ The stdio mode exists for narrower cases:
|
|
|
35
35
|
2. **Transport parity.** The local client can use essentially the same Machine Bridge runtime that remote ChatGPT access uses, without maintaining a second implementation.
|
|
36
36
|
3. **No remote relay for same-machine use.** The host launches the server directly, so no Cloudflare Worker, public URL, OAuth flow, or network round trip is needed.
|
|
37
37
|
4. **Capabilities missing from a particular host.** Exact edit semantics, transactional multi-file patches, retained process sessions, image results, or the project's policy profiles may be useful even when the host has basic shell tools.
|
|
38
|
-
5. **
|
|
38
|
+
5. **Durable managed jobs.** The same detached job/resource/finally semantics are available to local and remote hosts, while local CLI remains an operator fallback.
|
|
39
|
+
6. **Testing and interoperability.** stdio is a standard MCP transport and provides a direct way to validate the runtime independently of the Worker.
|
|
39
40
|
|
|
40
41
|
It is therefore an optional compatibility and reuse surface, not a replacement for the native agent tooling in Claude Desktop, Cursor, or Codex.
|
|
41
42
|
|
|
@@ -128,4 +129,14 @@ A client configuration is an authorization decision. Anyone who controls an auth
|
|
|
128
129
|
|
|
129
130
|
The local `full` profile controls Machine Bridge's own tool catalog, path resolver, path display, process environment, and shell availability. It does not control the MCP host's model policy, approval UI, connector gateway, or platform execution filters.
|
|
130
131
|
|
|
131
|
-
Machine Bridge itself does not block files because their names look sensitive. If `server_info` reports `full` and a direct
|
|
132
|
+
Machine Bridge itself does not block files because their names look sensitive. If `server_info` reports `full` and a direct call is still rejected before a structured tool result, the host/connector may have blocked delivery. If `diagnose_runtime` responds but its fixed process or shell probe fails, the likely source is local OS policy, endpoint-security software, permissions, or shell configuration. Changing `--profile`, `--unrestricted-paths`, or `--absolute-paths` cannot override either layer.
|
|
133
|
+
|
|
134
|
+
Do not attempt to evade a host refusal by renaming, encoding, or switching to another arbitrary execution tool. Instead:
|
|
135
|
+
|
|
136
|
+
1. register credentials locally as resource aliases so their values never enter MCP arguments;
|
|
137
|
+
2. submit a complete `start_job` plan before the workflow depends on later cleanup calls, or use `stage_job` plus local `job approve` when execution-class tools are unavailable;
|
|
138
|
+
3. use job-scoped temporary files or remote stdin scripts;
|
|
139
|
+
4. put idempotent cleanup in `finally_steps`;
|
|
140
|
+
5. inspect/cancel through `machine-mcp job ...` if the host later denies tools.
|
|
141
|
+
|
|
142
|
+
The initial `start_job` request is still subject to host approval. If it is blocked, the operator can review and submit the same JSON plan locally with `machine-mcp job submit plan.json`. See [MANAGED_JOBS.md](MANAGED_JOBS.md).
|
package/docs/LOGGING.md
CHANGED
|
@@ -73,8 +73,10 @@ logs/daemon.err.log
|
|
|
73
73
|
|
|
74
74
|
They are owner-only where the platform supports Unix-style permissions. Existing files are tail-trimmed on UTF-8/line boundaries before daemon startup. Because background services use `warn`, normal successful tool traffic should not cause sustained log growth.
|
|
75
75
|
|
|
76
|
+
Each managed job also has owner-only `runner.out.log` and `runner.err.log` files for runner startup/crash diagnostics. Child-step stdout and stderr are captured into bounded job results according to `capture_output`; they are not copied into runner or daemon operational logs. Runner logs are retained with the bounded job directory and removed by job retention cleanup.
|
|
77
|
+
|
|
76
78
|
## MCP host boundary
|
|
77
79
|
|
|
78
|
-
Machine Bridge does not classify filenames as sensitive and does not block `.env`, password, key, or credential-looking names. The active local policy and
|
|
80
|
+
Machine Bridge does not classify filenames as sensitive and does not block `.env`, password, key, or credential-looking names. The active local policy, local OS permissions, and endpoint-security controls determine what the server itself can read or execute.
|
|
79
81
|
|
|
80
82
|
An MCP host, model provider, desktop application, or platform execution layer may independently deny a request involving credentials or sensitive files. Such a denial occurs before or outside Machine Bridge's file resolver and cannot be disabled by selecting the local `full` profile. Use `server_info`, `machine-mcp status`, and `machine-mcp doctor` to distinguish the active local policy from host-side enforcement.
|