machine-bridge-mcp 0.4.0 → 0.5.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 +51 -0
- package/README.md +48 -39
- package/SECURITY.md +14 -10
- package/docs/ARCHITECTURE.md +14 -12
- package/docs/CLIENTS.md +82 -23
- package/docs/LOGGING.md +80 -0
- package/docs/OPERATIONS.md +25 -17
- package/docs/TESTING.md +7 -4
- package/package.json +4 -4
- package/src/local/cli.mjs +157 -79
- package/src/local/daemon.mjs +83 -48
- package/src/local/log.mjs +56 -15
- package/src/local/service.mjs +40 -21
- package/src/local/state.mjs +45 -20
- package/src/local/stdio.mjs +13 -37
- package/src/local/tools.mjs +28 -13
- package/src/shared/server-metadata.json +17 -0
- package/src/shared/tool-catalog.json +2 -2
- package/src/worker/index.ts +13 -11
- package/docs/examples/github-actions-ci.yml +0 -53
package/docs/LOGGING.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Logging and observability
|
|
2
|
+
|
|
3
|
+
## Goals
|
|
4
|
+
|
|
5
|
+
Operational logs should answer four questions without becoming a transcript of user activity:
|
|
6
|
+
|
|
7
|
+
1. Did deployment and relay connection succeed?
|
|
8
|
+
2. Is the daemon reconnecting, superseded, or unhealthy?
|
|
9
|
+
3. Did a tool call fail, time out, or become unusually slow?
|
|
10
|
+
4. Which component and coarse error class should be investigated?
|
|
11
|
+
|
|
12
|
+
Logs are not a command history, content audit trail, or substitute for MCP client approvals.
|
|
13
|
+
|
|
14
|
+
## Levels
|
|
15
|
+
|
|
16
|
+
The CLI accepts:
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
--log-level error|warn|info|debug
|
|
20
|
+
--quiet # alias for error
|
|
21
|
+
--verbose # alias for debug
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The default foreground level is `info`. Platform autostart services use `warn`.
|
|
25
|
+
|
|
26
|
+
| Level | Intended events |
|
|
27
|
+
|---|---|
|
|
28
|
+
| `error` | Broken request handlers, relay transport errors, unrecoverable local failures |
|
|
29
|
+
| `warn` | Failed tool calls, disconnections, malformed/oversized relay messages, superseded daemons |
|
|
30
|
+
| `info` | Deployment/startup transitions, successful relay connection, successful calls slower than 30 seconds |
|
|
31
|
+
| `debug` | Routine successful calls, shortened correlation IDs, reconnect timing, cancellation correlation |
|
|
32
|
+
|
|
33
|
+
Routine successful calls are deliberately absent from `info`. A normal sequence of hundreds of tool invocations should not fill the user's terminal or service logs.
|
|
34
|
+
|
|
35
|
+
## Event fields
|
|
36
|
+
|
|
37
|
+
Default warning/error and slow-call events may include:
|
|
38
|
+
|
|
39
|
+
- component;
|
|
40
|
+
- tool name;
|
|
41
|
+
- duration in milliseconds;
|
|
42
|
+
- coarse error class;
|
|
43
|
+
- relay close code;
|
|
44
|
+
- bounded reconnect delay.
|
|
45
|
+
|
|
46
|
+
Shortened random call identifiers are debug-only. They are useful only for correlating adjacent local events and are not stable audit identifiers.
|
|
47
|
+
|
|
48
|
+
The implementation intentionally omits:
|
|
49
|
+
|
|
50
|
+
- tool arguments;
|
|
51
|
+
- command text or argv;
|
|
52
|
+
- stdin, stdout, and stderr;
|
|
53
|
+
- file, patch, or image content;
|
|
54
|
+
- OAuth request bodies;
|
|
55
|
+
- connection passwords, daemon secrets, authorization codes, and access tokens.
|
|
56
|
+
|
|
57
|
+
Unexpected daemon and Worker failures are reduced to coarse error classes in normal logs. Client-facing tool errors may contain more detail according to the active path-display policy, but those details are not copied into normal operational logs.
|
|
58
|
+
|
|
59
|
+
## Bounding and redaction
|
|
60
|
+
|
|
61
|
+
Messages, strings, object depth, object key counts, array item counts, and serialized field payloads are bounded. Control characters are neutralized. Fields with secret-like names and known token formats are recursively redacted.
|
|
62
|
+
|
|
63
|
+
This is defense in depth, not content classification. A previously unknown secret format embedded in an ordinary non-secret-named field may evade pattern redaction. For that reason, tool arguments and outputs are omitted rather than merely filtered.
|
|
64
|
+
|
|
65
|
+
## Files
|
|
66
|
+
|
|
67
|
+
Autostart logs are stored below the state root:
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
logs/daemon.out.log
|
|
71
|
+
logs/daemon.err.log
|
|
72
|
+
```
|
|
73
|
+
|
|
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
|
+
|
|
76
|
+
## MCP host boundary
|
|
77
|
+
|
|
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 operating-system permissions determine what the server itself can read.
|
|
79
|
+
|
|
80
|
+
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.
|
package/docs/OPERATIONS.md
CHANGED
|
@@ -14,24 +14,20 @@ machine-mcp service status
|
|
|
14
14
|
|
|
15
15
|
Remote autostart logs are stored under the state root in `logs/daemon.out.log` and `logs/daemon.err.log`. Files are owner-only where supported and tail-trimmed before daemon startup.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Logging is level-based:
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
```text
|
|
20
|
+
error unrecoverable local/transport failures
|
|
21
|
+
warn failed calls, disconnects, malformed relay events
|
|
22
|
+
info startup/deploy/connect transitions and calls slower than 30 seconds
|
|
23
|
+
debug routine successful calls, shortened correlation IDs, cancellation/reconnect details
|
|
24
|
+
```
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
Foreground mode defaults to `info`; autostart uses `warn`. Use `--verbose` or `--log-level debug` only for diagnosis. `--quiet` is an alias for `--log-level error`.
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
- write, edit, or patch payloads;
|
|
30
|
-
- command argv, shell text, stdin, stdout, and stderr;
|
|
31
|
-
- MCP connection passwords, daemon secrets, authorization codes, and access tokens;
|
|
32
|
-
- full request bodies.
|
|
28
|
+
Normal logs intentionally omit tool arguments, file/patch/image content, command text and argv, stdin/stdout/stderr, OAuth request bodies, connection credentials, authorization codes, and tokens. Unexpected daemon and Worker failures use coarse error classes rather than raw exception messages. Messages and structured fields are bounded and secret-like fields/token formats are redacted.
|
|
33
29
|
|
|
34
|
-
|
|
30
|
+
See [LOGGING.md](LOGGING.md) for the event contract and MCP-host boundary. Cloudflare observability is sampled and is not a complete audit log.
|
|
35
31
|
|
|
36
32
|
## Reconnect and replacement
|
|
37
33
|
|
|
@@ -62,20 +58,32 @@ Defense-in-depth limits include:
|
|
|
62
58
|
|
|
63
59
|
## Upgrade behavior
|
|
64
60
|
|
|
65
|
-
Version 0.
|
|
61
|
+
Version 0.5 records policy origin and revision. A state entry matching the exact legacy implicit-default shape—write enabled, shell enabled, workspace-confined paths, isolated environment, and relative output—is migrated once to the current `full` default. Explicit named profiles and identified custom policies are preserved.
|
|
62
|
+
|
|
63
|
+
`full` enables writes, direct processes, process sessions, shell execution, unrestricted direct filesystem paths, absolute path output, and the complete parent environment. It does not override operating-system access controls or independent MCP-host/platform policy.
|
|
64
|
+
|
|
65
|
+
Inspect effective policy with:
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
machine-mcp status
|
|
69
|
+
machine-mcp doctor
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Select a policy explicitly with:
|
|
66
73
|
|
|
67
74
|
```sh
|
|
75
|
+
machine-mcp --workspace /path/to/project --profile full
|
|
68
76
|
machine-mcp --workspace /path/to/project --profile agent
|
|
69
77
|
```
|
|
70
78
|
|
|
71
|
-
A remote policy change is saved locally, propagated in the daemon handshake, and
|
|
79
|
+
A remote policy change is saved locally, propagated in the daemon handshake, and loaded by autostart from owner-only state.
|
|
72
80
|
|
|
73
81
|
## Incident response
|
|
74
82
|
|
|
75
83
|
After suspected credential or client compromise:
|
|
76
84
|
|
|
77
85
|
1. stop foreground and autostart daemons;
|
|
78
|
-
2. run `machine-mcp rotate-secrets
|
|
86
|
+
2. run `machine-mcp rotate-secrets`;
|
|
79
87
|
3. restart without broad flags and redeploy;
|
|
80
88
|
4. inspect Cloudflare account access, Worker configuration, local state permissions, and service logs;
|
|
81
89
|
5. remove the Worker and local state if continued remote access is unnecessary.
|
package/docs/TESTING.md
CHANGED
|
@@ -24,8 +24,9 @@ The suite includes:
|
|
|
24
24
|
- isolated command HOME/temp/cache behavior;
|
|
25
25
|
- one-shot timeout, descendant termination, cancellation, and process-session interaction;
|
|
26
26
|
- daemon/startup locking and state corruption recovery;
|
|
27
|
-
- guarded state-root removal and legacy-
|
|
28
|
-
-
|
|
27
|
+
- guarded state-root removal, schema migration, policy-origin persistence, and legacy implicit-default migration;
|
|
28
|
+
- no filename-based sensitive-file denial under unrestricted policy;
|
|
29
|
+
- log redaction, control-character handling, message/field bounds, default success-log suppression, and service warning-level configuration;
|
|
29
30
|
- CLI parsing, policy profiles, and client configuration boundaries;
|
|
30
31
|
- live stdio MCP initialization, discovery, calls, rich content, sessions, cancellation, and continued responsiveness;
|
|
31
32
|
- live local Worker OAuth registration, consent, PKCE, token replay rejection, throttling, CORS, protocol negotiation, dynamic tool advertisement, rich content, daemon replacement, and cancellation.
|
|
@@ -34,12 +35,13 @@ The suite includes:
|
|
|
34
35
|
|
|
35
36
|
```sh
|
|
36
37
|
npm run worker:dry-run
|
|
38
|
+
npm audit --audit-level=high
|
|
37
39
|
npm audit --omit=dev --audit-level=high
|
|
38
40
|
npm pack --dry-run
|
|
39
41
|
npm run version:check
|
|
40
42
|
```
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
GitHub Actions executes the main suite on Linux, macOS, and Windows. Node 22 and 24 are covered on Linux; Node 22 is covered on macOS and Windows. A separate package-audit job audits both the complete dependency graph and the production-only graph, then performs a dry-run package build. Dependency and GitHub Actions updates are monitored by Dependabot.
|
|
43
45
|
|
|
44
46
|
## Test design rules
|
|
45
47
|
|
|
@@ -48,4 +50,5 @@ The repository includes `docs/examples/github-actions-ci.yml`, a ready-to-enable
|
|
|
48
50
|
- Every bounded resource needs an over-limit test.
|
|
49
51
|
- Every multi-stage mutation needs a no-partial-commit test.
|
|
50
52
|
- Every remote call correlation change needs daemon replacement and cancellation coverage.
|
|
51
|
-
- Logs and public metadata should be tested for absence of sensitive fields, not only presence of expected fields.
|
|
53
|
+
- Logs and public metadata should be tested for absence of sensitive fields, arguments, outputs, and routine success noise—not only presence of expected fields.
|
|
54
|
+
- Cross-platform tests must avoid shell syntax, URL-path conversion, and executable-shim assumptions specific to one operating system.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "machine-bridge-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Cross-client MCP bridge for policy-controlled local files, Git, images, patches, and processes over stdio or OAuth-protected remote relay.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"catalog:test": "node tests/catalog-test.mjs"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"wrangler": "
|
|
54
|
-
"ws": "
|
|
53
|
+
"wrangler": "4.110.0",
|
|
54
|
+
"ws": "8.21.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^22.20.1",
|
|
58
|
-
"typescript": "^
|
|
58
|
+
"typescript": "^7.0.2"
|
|
59
59
|
},
|
|
60
60
|
"keywords": [
|
|
61
61
|
"mcp",
|