machine-bridge-mcp 0.1.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/LICENSE +21 -0
- package/README.md +203 -0
- package/bin/machine-mcp.mjs +10 -0
- package/mbm +9 -0
- package/mbm.cmd +8 -0
- package/package.json +59 -0
- package/src/local/cli.mjs +590 -0
- package/src/local/daemon.mjs +441 -0
- package/src/local/self-test.mjs +28 -0
- package/src/local/service.mjs +224 -0
- package/src/local/shell.mjs +68 -0
- package/src/local/state.mjs +170 -0
- package/src/worker/index.ts +895 -0
- package/tsconfig.json +19 -0
- package/wrangler.jsonc +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 machine-bridge-mcp contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# machine-bridge-mcp
|
|
2
|
+
|
|
3
|
+
`machine-bridge-mcp` turns your machine into a Remote MCP server through a small hosted relay and a local outbound daemon.
|
|
4
|
+
|
|
5
|
+
The recommended deployment command is short and stable for autostart:
|
|
6
|
+
|
|
7
|
+
```zsh
|
|
8
|
+
npm install -g machine-bridge-mcp@latest && machine-mcp
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
No-global-install alternative:
|
|
12
|
+
|
|
13
|
+
```zsh
|
|
14
|
+
npx machine-bridge-mcp@latest
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Source checkout:
|
|
18
|
+
|
|
19
|
+
```zsh
|
|
20
|
+
./mbm # macOS/Linux
|
|
21
|
+
.\mbm.cmd # Windows cmd
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## What it does on first run
|
|
25
|
+
|
|
26
|
+
1. Asks for a workspace path. Press Enter to use the current directory.
|
|
27
|
+
2. Remembers that workspace for later runs.
|
|
28
|
+
3. Generates a stable MCP connection password and daemon secret.
|
|
29
|
+
4. Checks `wrangler whoami`; if needed, opens `wrangler login`.
|
|
30
|
+
5. Deploys the hosted Worker relay with `wrangler deploy --secrets-file`.
|
|
31
|
+
6. Installs login autostart for the local daemon.
|
|
32
|
+
7. Starts the local daemon and prints:
|
|
33
|
+
|
|
34
|
+
```text
|
|
35
|
+
MCP Server URL: https://<worker>.<account>.workers.dev/mcp
|
|
36
|
+
MCP connection password: mcp_password_...
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Keep the foreground process running for the current session. The installed autostart entry keeps the daemon available after future logins.
|
|
40
|
+
|
|
41
|
+
## Re-select workspace
|
|
42
|
+
|
|
43
|
+
```zsh
|
|
44
|
+
machine-mcp workspace set
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or provide it directly:
|
|
48
|
+
|
|
49
|
+
```zsh
|
|
50
|
+
machine-mcp workspace set /path/to/new/default
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Show the remembered workspace:
|
|
54
|
+
|
|
55
|
+
```zsh
|
|
56
|
+
machine-mcp workspace show
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Autostart service
|
|
60
|
+
|
|
61
|
+
Supported platforms:
|
|
62
|
+
|
|
63
|
+
- macOS: user LaunchAgent
|
|
64
|
+
- Linux: `systemd --user` with best-effort `loginctl enable-linger`
|
|
65
|
+
- Windows: Scheduled Task at logon
|
|
66
|
+
|
|
67
|
+
Commands:
|
|
68
|
+
|
|
69
|
+
```zsh
|
|
70
|
+
machine-mcp service status
|
|
71
|
+
machine-mcp service install
|
|
72
|
+
machine-mcp service start
|
|
73
|
+
machine-mcp service stop
|
|
74
|
+
machine-mcp service uninstall
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`start` installs autostart by default. Skip that behavior with:
|
|
78
|
+
|
|
79
|
+
```zsh
|
|
80
|
+
machine-mcp --no-autostart
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Autostart runs the daemon with `--daemon-only --no-print-credentials`, so service logs do not contain the MCP connection password. If you start with `--no-write`, `--no-exec`, or `--full-env`, those policy flags are preserved in the autostart entry.
|
|
84
|
+
|
|
85
|
+
## Secrets rotation
|
|
86
|
+
|
|
87
|
+
```zsh
|
|
88
|
+
machine-mcp rotate-secrets
|
|
89
|
+
machine-mcp
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`rotate-secrets` creates a new MCP connection password, daemon secret, and OAuth token version. The next deploy rejects previously issued OAuth access tokens.
|
|
93
|
+
|
|
94
|
+
## Uninstall
|
|
95
|
+
|
|
96
|
+
Delete known deployed Worker(s), remove autostart entries, and remove local state:
|
|
97
|
+
|
|
98
|
+
```zsh
|
|
99
|
+
machine-mcp uninstall
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Non-interactive:
|
|
103
|
+
|
|
104
|
+
```zsh
|
|
105
|
+
machine-mcp uninstall --yes
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Keep the deployed Worker but remove local state/autostart:
|
|
109
|
+
|
|
110
|
+
```zsh
|
|
111
|
+
machine-mcp uninstall --keep-worker
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
If installed globally, remove the npm package afterwards:
|
|
115
|
+
|
|
116
|
+
```zsh
|
|
117
|
+
npm uninstall -g machine-bridge-mcp
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Defaults and permissions
|
|
121
|
+
|
|
122
|
+
This project optimizes for easy use with official Remote MCP clients:
|
|
123
|
+
|
|
124
|
+
- `write_file` is enabled by default.
|
|
125
|
+
- `exec_command` is enabled by default.
|
|
126
|
+
- Absolute paths are allowed.
|
|
127
|
+
- Parent-directory paths such as `../other-project/file.ts` are allowed.
|
|
128
|
+
- Sensitive-looking files such as `.env`, private keys, token files, and dot-directories are not hidden by default.
|
|
129
|
+
- Relative paths use the selected workspace as cwd.
|
|
130
|
+
- Shell commands run with a minimal environment by default; use `--full-env` to pass the parent process environment.
|
|
131
|
+
|
|
132
|
+
Narrower session:
|
|
133
|
+
|
|
134
|
+
```zsh
|
|
135
|
+
machine-mcp --no-write --no-exec
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## MCP tools
|
|
139
|
+
|
|
140
|
+
- `server_info`
|
|
141
|
+
- `project_overview`
|
|
142
|
+
- `list_roots`
|
|
143
|
+
- `list_dir`
|
|
144
|
+
- `list_files`
|
|
145
|
+
- `read_file`
|
|
146
|
+
- `write_file`
|
|
147
|
+
- `search_text`
|
|
148
|
+
- `git_status`
|
|
149
|
+
- `git_diff`
|
|
150
|
+
- `exec_command`
|
|
151
|
+
|
|
152
|
+
## State and logs
|
|
153
|
+
|
|
154
|
+
Default state roots:
|
|
155
|
+
|
|
156
|
+
- macOS/Linux: `~/.local/state/machine-bridge-mcp`
|
|
157
|
+
- Linux with `XDG_STATE_HOME`: `$XDG_STATE_HOME/machine-bridge-mcp`
|
|
158
|
+
- Windows: `%APPDATA%\machine-bridge-mcp`
|
|
159
|
+
|
|
160
|
+
State contains the MCP password and daemon secret. Status/doctor output redacts secrets. The normal foreground `start` command prints the MCP password because users need to paste it into their MCP client.
|
|
161
|
+
|
|
162
|
+
Override state root:
|
|
163
|
+
|
|
164
|
+
```zsh
|
|
165
|
+
machine-mcp --state-dir /path/to/state
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Architecture
|
|
169
|
+
|
|
170
|
+
```mermaid
|
|
171
|
+
flowchart LR
|
|
172
|
+
C["Remote MCP client"] -- "HTTPS /mcp + OAuth" --> W["Hosted Worker relay"]
|
|
173
|
+
W --> DO["Durable Object broker"]
|
|
174
|
+
D["Local daemon"] -- "outbound WebSocket" --> W
|
|
175
|
+
D --> M["Local filesystem and shell"]
|
|
176
|
+
CLI["machine-mcp CLI"] --> W
|
|
177
|
+
CLI --> D
|
|
178
|
+
CLI --> S["Autostart service"]
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Why this architecture:
|
|
182
|
+
|
|
183
|
+
- No inbound local port is exposed to the internet.
|
|
184
|
+
- No local tunnel process is required.
|
|
185
|
+
- The public MCP URL is stable after deployment.
|
|
186
|
+
- The Worker stores OAuth client/code/token metadata and relays tool calls.
|
|
187
|
+
- The local daemon is the only process touching files or executing commands.
|
|
188
|
+
- Autostart keeps the daemon alive across logins without requiring MCP clients to change URLs.
|
|
189
|
+
|
|
190
|
+
## Development
|
|
191
|
+
|
|
192
|
+
```zsh
|
|
193
|
+
npm install
|
|
194
|
+
npm run check
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
`npm run check` generates Worker runtime types, type-checks the Worker, checks local JS syntax, and runs daemon self-tests.
|
|
198
|
+
|
|
199
|
+
Worker build dry-run:
|
|
200
|
+
|
|
201
|
+
```zsh
|
|
202
|
+
npx wrangler deploy --dry-run
|
|
203
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { main } from "../src/local/cli.mjs";
|
|
3
|
+
|
|
4
|
+
main().catch(error => {
|
|
5
|
+
const message = process.env.MBM_DEBUG === "1"
|
|
6
|
+
? (error?.stack || error?.message || String(error))
|
|
7
|
+
: (error?.message || String(error));
|
|
8
|
+
console.error(`Error: ${message}`);
|
|
9
|
+
process.exitCode = 1;
|
|
10
|
+
});
|
package/mbm
ADDED
package/mbm.cmd
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "machine-bridge-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "One-command hosted Remote MCP bridge to a local machine daemon.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20.0.0"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"machine-bridge-mcp": "bin/machine-mcp.mjs",
|
|
12
|
+
"machine-mcp": "bin/machine-mcp.mjs",
|
|
13
|
+
"mbm": "bin/machine-mcp.mjs"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"mbm",
|
|
17
|
+
"mbm.cmd",
|
|
18
|
+
"bin",
|
|
19
|
+
"src/local",
|
|
20
|
+
"src/worker/index.ts",
|
|
21
|
+
"wrangler.jsonc",
|
|
22
|
+
"tsconfig.json",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"start": "node bin/machine-mcp.mjs start",
|
|
28
|
+
"doctor": "node bin/machine-mcp.mjs doctor",
|
|
29
|
+
"self-test": "node src/local/self-test.mjs",
|
|
30
|
+
"worker:types": "wrangler types src/worker/worker-configuration.d.ts",
|
|
31
|
+
"typecheck": "npm run worker:types && tsc -p tsconfig.json --noEmit",
|
|
32
|
+
"syntax": "sh -n mbm && node --check bin/machine-mcp.mjs && node --check src/local/cli.mjs && node --check src/local/daemon.mjs && node --check src/local/state.mjs && node --check src/local/shell.mjs && node --check src/local/service.mjs && node --check src/local/self-test.mjs",
|
|
33
|
+
"check": "npm run typecheck && npm run syntax && npm run self-test"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"wrangler": "^4.24.3",
|
|
37
|
+
"ws": "^8.18.3"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^26.1.1",
|
|
41
|
+
"typescript": "^5.8.3"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"mcp",
|
|
45
|
+
"remote-mcp",
|
|
46
|
+
"cloudflare-workers",
|
|
47
|
+
"durable-objects",
|
|
48
|
+
"wrangler",
|
|
49
|
+
"local-machine"
|
|
50
|
+
],
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/YuLeiFuYun/machine-bridge-mcp.git"
|
|
54
|
+
},
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/YuLeiFuYun/machine-bridge-mcp/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://github.com/YuLeiFuYun/machine-bridge-mcp#readme"
|
|
59
|
+
}
|