local-mcp-bridge-server 0.7.0 → 0.8.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.
Files changed (3) hide show
  1. package/README.md +10 -28
  2. package/dist/cli.js +9 -195
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -11,7 +11,7 @@ npx local-mcp-bridge-server
11
11
  Node.js 20 or later. The first start creates the config file with a random token, then prints what to enter in the extension's options:
12
12
 
13
13
  ```
14
- local-mcp-bridge-server 0.7.0
14
+ local-mcp-bridge-server 0.8.0
15
15
  URL: http://127.0.0.1:7341/mcp
16
16
  Token: 3q2-...
17
17
  Config: /home/you/.config/local-mcp-bridge-server/config.json (new)
@@ -21,35 +21,15 @@ local-mcp-bridge-server 0.7.0
21
21
 
22
22
  Leave the window open while you use the extension. Every request shows up there as it comes (see *Log* below).
23
23
 
24
- ## Start it when you log in
25
-
26
- Install it once, then let your system start it:
27
-
28
- ```bash
29
- npm install -g local-mcp-bridge-server
30
- local-mcp-bridge-server install-service
31
- ```
32
-
33
- It starts at once and at every login: a LaunchAgent on macOS (log: `~/Library/Logs/local-mcp-bridge-server.log`), a systemd user service on Linux (log: `journalctl --user -u local-mcp-bridge-server`), a hidden script in the Startup folder on Windows (log: `%LOCALAPPDATA%\local-mcp-bridge-server\server.log`). No administrator rights are needed. `--port`, `--no-shell` and `--no-files` given here are saved in the config.
34
-
35
- - `local-mcp-bridge-server token` shows the URL and the token again (the service does not write the token into its log).
36
- - `local-mcp-bridge-server perf-log` shows the extension's performance log (below).
37
- - `local-mcp-bridge-server uninstall-service` stops it and removes it.
38
- - The service runs the Node.js that installed it, with the `PATH` of the terminal you installed it from (so that `npx` and your tools are found): after removing that Node.js version (with nvm, say) or changing your `PATH`, run `install-service` again.
39
-
40
24
  ## From gemini-mcp-bridge-server
41
25
 
42
- Until 0.6.0 this server was called `gemini-mcp-bridge-server`. The new name takes over what the old one left, so the URL and the token in the extension stay as they are:
26
+ Until 0.6.0 this server was called `gemini-mcp-bridge-server`. Without `--config`, the first start (or `token`) copies the old config file (`~/.config/gemini-mcp-bridge-server/config.json`, on Windows `%APPDATA%\gemini-mcp-bridge-server\config.json`) to the new place, with its token, port and servers: the URL and the token in the extension stay as they are.
43
27
 
44
- - **The config:** without `--config`, the first start (or `token`, `install-service`) copies the old config file (`~/.config/gemini-mcp-bridge-server/config.json`, on Windows `%APPDATA%\gemini-mcp-bridge-server\config.json`) to the new place, with its token, port and servers.
45
- - **The service:** `install-service` removes the service of the old name before it installs its own, and `uninstall-service` removes both. When the old service still holds the port, the message of a start that fails says so.
46
-
47
- If you had installed the old one:
28
+ A service that an earlier version installed (`install-service`, until 0.7.0) starts that version at every login and holds the port. Remove it once:
48
29
 
49
30
  ```bash
50
- npm install -g local-mcp-bridge-server
51
- local-mcp-bridge-server install-service # replaces the service of the old name
52
- npm uninstall -g gemini-mcp-bridge-server
31
+ npx local-mcp-bridge-server@0.7.0 uninstall-service # removes the service of either name
32
+ npm uninstall -g gemini-mcp-bridge-server # if you had installed it
53
33
  ```
54
34
 
55
35
  ## Tools
@@ -67,9 +47,11 @@ Paths may be absolute, start with `~`, or be relative to your home folder. The s
67
47
 
68
48
  ```
69
49
  local-mcp-bridge-server [--port <n>] [--config <file>] [--no-shell] [--no-files] [--new-token]
70
- local-mcp-bridge-server token | perf-log | install-service | uninstall-service
50
+ local-mcp-bridge-server token | perf-log
71
51
  ```
72
52
 
53
+ `token` shows the URL and the token again, `perf-log` the extension's performance log (below).
54
+
73
55
  The config file is `~/.config/local-mcp-bridge-server/config.json` (on Windows `%APPDATA%\local-mcp-bridge-server\config.json`). Only your user can read it.
74
56
 
75
57
  ```json
@@ -90,7 +72,7 @@ The server writes this file only on the first start and with a new token; keys i
90
72
 
91
73
  ## Log
92
74
 
93
- While it runs, the server writes to stdout (the service: to its log, above) each request as it comes, each step of the work, and the reply as it goes out, all under the number of the request. Something going wrong is a `WARN` or `ERROR` line at once: a tool that failed (with why), wrong arguments, a body that is not JSON (HTTP 400), any reply with an error status (with what it said), a refused request, a file tool still running after 5 seconds, a call the extension gave up on, a reply that had nowhere to go.
75
+ While it runs, the server writes to stdout each request as it comes, each step of the work, and the reply as it goes out, all under the number of the request. Something going wrong is a `WARN` or `ERROR` line at once: a tool that failed (with why), wrong arguments, a body that is not JSON (HTTP 400), any reply with an error status (with what it said), a refused request, a file tool still running after 5 seconds, a call the extension gave up on, a reply that had nowhere to go.
94
76
 
95
77
  ```
96
78
  14:33:50.923 INFO #1 ← tools/call run_command {"command":"mkdir -p /tmp/job && cat > /tmp/job/main.py <<'GMB_EOF' && python3 /tmp/job/main.py\nprint(\"hello\")\nGMB_EOF"} · 215 bytes from 127.0.0.1
@@ -124,7 +106,7 @@ The lines say which clicks, keys and frames took long on the page and how much o
124
106
 
125
107
  ```bash
126
108
  npm install
127
- npm run check # types, lint, tests (tools, HTTP checks, pass-through servers, config, command line, service files)
109
+ npm run check # types, lint, tests (tools, HTTP checks, pass-through servers, config, command line)
128
110
  npm run smoke # build, then run dist/cli.js as users do: --version, token, start, tools/list
129
111
  npm start # build and run dist/cli.js
130
112
  ```
package/dist/cli.js CHANGED
@@ -1,9 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
- import { realpathSync } from "node:fs";
5
4
  import { resolve as resolve2 } from "node:path";
6
- import { fileURLToPath } from "node:url";
7
5
  import { parseArgs } from "node:util";
8
6
 
9
7
  // src/builtin.ts
@@ -19,8 +17,8 @@ function stamp(d = /* @__PURE__ */ new Date()) {
19
17
  const p = (n, w = 2) => String(n).padStart(w, "0");
20
18
  return `${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}.${p(d.getMilliseconds(), 3)}`;
21
19
  }
22
- function consoleLogger(write2 = (t) => void process.stdout.write(t)) {
23
- const at = (level) => (line) => write2(`${stamp()} ${level} ${line}
20
+ function consoleLogger(write = (t) => void process.stdout.write(t)) {
21
+ const at = (level) => (line) => write(`${stamp()} ${level} ${line}
24
22
  `);
25
23
  return { info: at("INFO "), warn: at("WARN "), error: at("ERROR") };
26
24
  }
@@ -334,7 +332,7 @@ import { dirname as dirname2, join as join2 } from "node:path";
334
332
  // package.json
335
333
  var package_default = {
336
334
  name: "local-mcp-bridge-server",
337
- version: "0.7.0",
335
+ version: "0.8.0",
338
336
  description: "Local MCP server for the Gemini MCP Bridge Chrome extension: your computer's shell and files, plus the MCP servers you list",
339
337
  type: "module",
340
338
  license: "MIT",
@@ -789,11 +787,11 @@ function watchReply(res) {
789
787
  bytes += b.length;
790
788
  if (bytes <= REPLY_KEEP) kept.push(b);
791
789
  };
792
- const write2 = res.write.bind(res);
790
+ const write = res.write.bind(res);
793
791
  const end = res.end.bind(res);
794
792
  res.write = ((...a) => {
795
793
  take(a[0], a[1]);
796
- return write2(...a);
794
+ return write(...a);
797
795
  });
798
796
  res.end = ((...a) => {
799
797
  take(a[0], a[1]);
@@ -916,155 +914,6 @@ Connection: close\r
916
914
  });
917
915
  }
918
916
 
919
- // src/service.ts
920
- import { execFileSync as execFileSync2 } from "node:child_process";
921
- import { existsSync as existsSync2, mkdirSync as mkdirSync2, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
922
- import { homedir as homedir3 } from "node:os";
923
- import { dirname as dirname4, posix, win32 } from "node:path";
924
- var label = (name) => `io.github.somebodil.${name}`;
925
- var LABEL = label(NAME);
926
- var xml = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
927
- var agentPath = (home = homedir3(), name = NAME) => posix.join(home, "Library", "LaunchAgents", `${label(name)}.plist`);
928
- var unitPath = (home = homedir3(), name = NAME) => posix.join(process.env.XDG_CONFIG_HOME || posix.join(home, ".config"), "systemd", "user", `${name}.service`);
929
- var startupPath = (appData = process.env.APPDATA ?? win32.join(homedir3(), "AppData", "Roaming"), name = NAME) => win32.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "Startup", `${name}.vbs`);
930
- var fileOf = (name) => process.platform === "darwin" ? agentPath(homedir3(), name) : process.platform === "win32" ? startupPath(void 0, name) : unitPath(homedir3(), name);
931
- function launchAgent(spec, home) {
932
- const args = spec.command.map((a) => ` <string>${xml(a)}</string>`).join("\n");
933
- return {
934
- path: agentPath(home),
935
- content: `<?xml version="1.0" encoding="UTF-8"?>
936
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
937
- <plist version="1.0">
938
- <dict>
939
- <key>Label</key>
940
- <string>${LABEL}</string>
941
- <key>ProgramArguments</key>
942
- <array>
943
- ${args}
944
- </array>
945
- <key>EnvironmentVariables</key>
946
- <dict>
947
- <key>PATH</key>
948
- <string>${xml(spec.path)}</string>
949
- </dict>
950
- <key>RunAtLoad</key>
951
- <true/>
952
- <key>KeepAlive</key>
953
- <dict>
954
- <key>SuccessfulExit</key>
955
- <false/>
956
- </dict>
957
- <key>StandardOutPath</key>
958
- <string>${xml(spec.log)}</string>
959
- <key>StandardErrorPath</key>
960
- <string>${xml(spec.log)}</string>
961
- </dict>
962
- </plist>
963
- `
964
- };
965
- }
966
- var systemdQuote = (a) => `"${a.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/%/g, "%%").replace(/\$/g, "$$$$")}"`;
967
- function systemdUnit(spec, home) {
968
- return {
969
- path: unitPath(home),
970
- content: `[Unit]
971
- Description=Local MCP server for the Gemini MCP Bridge Chrome extension
972
-
973
- [Service]
974
- ExecStart=${spec.command.map(systemdQuote).join(" ")}
975
- Environment=${systemdQuote(`PATH=${spec.path}`)}
976
- Restart=on-failure
977
- RestartSec=5
978
-
979
- [Install]
980
- WantedBy=default.target
981
- `
982
- };
983
- }
984
- function startupCommand(spec) {
985
- const q = (a) => `"${a}"`;
986
- return `cmd /d /s /c "${spec.command.map(q).join(" ")} >> ${q(spec.log)} 2>&1"`;
987
- }
988
- function startupScript(spec, appData) {
989
- return {
990
- path: startupPath(appData),
991
- content: `' Starts ${NAME} at logon, without a window. Remove this file to stop that.\r
992
- CreateObject("WScript.Shell").Run "${startupCommand(spec).replace(/"/g, '""')}", 0, False\r
993
- `
994
- };
995
- }
996
- function logPath(home = homedir3()) {
997
- if (process.platform === "win32") return win32.join(process.env.LOCALAPPDATA ?? win32.join(home, "AppData", "Local"), NAME, "server.log");
998
- return posix.join(home, "Library", "Logs", `${NAME}.log`);
999
- }
1000
- function fromNpxCache(script) {
1001
- return /[\\/]_npx[\\/]/.test(script);
1002
- }
1003
- function run(cmd, args, quiet = false) {
1004
- try {
1005
- execFileSync2(cmd, args, { stdio: quiet ? "ignore" : ["ignore", "inherit", "inherit"] });
1006
- return true;
1007
- } catch {
1008
- return false;
1009
- }
1010
- }
1011
- function write(f) {
1012
- mkdirSync2(dirname4(f.path), { recursive: true });
1013
- writeFileSync2(f.path, f.content);
1014
- }
1015
- var uid = () => process.getuid?.() ?? 0;
1016
- function remove(name) {
1017
- const systemd = process.platform !== "darwin" && process.platform !== "win32";
1018
- if (process.platform === "darwin") run("launchctl", ["bootout", `gui/${uid()}/${label(name)}`], true);
1019
- if (systemd) run("systemctl", ["--user", "disable", "--now", name], true);
1020
- const f = fileOf(name);
1021
- if (!existsSync2(f)) return void 0;
1022
- rmSync(f);
1023
- if (systemd) run("systemctl", ["--user", "daemon-reload"], true);
1024
- return f;
1025
- }
1026
- function formerService() {
1027
- const f = fileOf(FORMER_NAME);
1028
- return existsSync2(f) ? f : void 0;
1029
- }
1030
- function install(spec) {
1031
- const former = remove(FORMER_NAME);
1032
- const note = process.platform === "win32" ? " (the server it started runs until you log out; this one starts at your next logon)" : "";
1033
- return [...former ? [`Removed the service of the former name, ${FORMER_NAME}: ${former}${note}`] : [], ...installOwn(spec)];
1034
- }
1035
- function installOwn(spec) {
1036
- if (process.platform === "darwin") {
1037
- mkdirSync2(dirname4(spec.log), { recursive: true });
1038
- const f2 = launchAgent(spec);
1039
- run("launchctl", ["bootout", `gui/${uid()}/${LABEL}`], true);
1040
- write(f2);
1041
- if (!run("launchctl", ["bootstrap", `gui/${uid()}`, f2.path], true)) {
1042
- execFileSync2("sleep", ["1"]);
1043
- if (!run("launchctl", ["bootstrap", `gui/${uid()}`, f2.path])) throw new Error(`launchctl could not load ${f2.path}`);
1044
- }
1045
- return [`Installed: ${f2.path}`, `It starts now and whenever you log in. Log: ${spec.log}`];
1046
- }
1047
- if (process.platform === "win32") {
1048
- mkdirSync2(dirname4(spec.log), { recursive: true });
1049
- const f2 = startupScript(spec);
1050
- write(f2);
1051
- run("wscript", [f2.path]);
1052
- return [`Installed: ${f2.path}`, `It starts now and whenever you log in. Log: ${spec.log}`];
1053
- }
1054
- const f = systemdUnit(spec);
1055
- write(f);
1056
- if (!run("systemctl", ["--user", "daemon-reload"]) || !run("systemctl", ["--user", "enable", "--now", NAME])) {
1057
- return [`Wrote ${f.path}, but systemctl --user did not work here.`, "Start the server another way (for example from your desktop's autostart)."];
1058
- }
1059
- return [`Installed: ${f.path}`, `It starts now and whenever you log in. Log: journalctl --user -u ${NAME}`];
1060
- }
1061
- function uninstall() {
1062
- const removed = [remove(NAME), remove(FORMER_NAME)].filter((f) => f !== void 0);
1063
- if (!removed.length) return ["No service was installed."];
1064
- const after = process.platform === "win32" ? ". A server started by it keeps running until you log out." : "; the server is stopped.";
1065
- return removed.map((f) => `Removed ${f}${after}`);
1066
- }
1067
-
1068
917
  // src/cli.ts
1069
918
  var HELP = `${NAME} ${VERSION}: your computer's tools for chats on the web, through the Gemini MCP Bridge extension
1070
919
 
@@ -1072,8 +921,6 @@ Usage:
1072
921
  ${NAME} [options] Start the server
1073
922
  ${NAME} token [--config <file>] Show the URL and the token for the extension
1074
923
  ${NAME} perf-log [--config <file>] Show the extension's performance log (an option of the extension)
1075
- ${NAME} install-service [options] Start the server whenever you log in (and now)
1076
- ${NAME} uninstall-service Stop doing that
1077
924
 
1078
925
  Options:
1079
926
  --port <n> Port (default: from the config, 7341)
@@ -1090,9 +937,8 @@ work, and the reply; WARN and ERROR lines when something goes wrong.
1090
937
  The config file also lists MCP servers to pass through, in the usual "mcpServers" shape:
1091
938
  "mcpServers": { "playwright": { "command": "npx", "args": ["@playwright/mcp@latest"] } }
1092
939
 
1093
- Until 0.6.0 its name was ${FORMER_NAME}: without --config, the first start (or token, install-service) copies
1094
- that name's config file (the token, the port, the servers), and install-service and uninstall-service remove that
1095
- name's service.
940
+ Until 0.6.0 its name was ${FORMER_NAME}: without --config, the first start (or token) copies that name's config
941
+ file (the token, the port, the servers).
1096
942
  `;
1097
943
  function port(value, fallback) {
1098
944
  if (value === void 0) return fallback;
@@ -1120,8 +966,6 @@ async function main() {
1120
966
  `);
1121
967
  const path = values.config ? resolve2(values.config) : defaultConfigPath();
1122
968
  if (command === "perf-log") return void process.stdout.write(showPerf(perfLogPath(path)));
1123
- if (command === "uninstall-service") return void process.stdout.write(`${uninstall().join("\n")}
1124
- `);
1125
969
  const copied = values.config ? void 0 : takeOverFormerConfig(path);
1126
970
  if (command === "token") {
1127
971
  const { config: config2 } = loadConfig(path);
@@ -1129,30 +973,6 @@ async function main() {
1129
973
  Token: ${config2.token}
1130
974
  `);
1131
975
  }
1132
- if (command === "install-service") {
1133
- const script = realpathSync(fileURLToPath(import.meta.url));
1134
- if (fromNpxCache(script)) {
1135
- throw new Error(`npx runs ${NAME} from a cache that npm may clean. Install it first, then install the service:
1136
- npm install -g ${NAME}
1137
- ${NAME} install-service`);
1138
- }
1139
- const { config: config2, raw } = loadConfig(path, { newToken: values["new-token"] });
1140
- config2.port = port(values.port, config2.port);
1141
- if (values["no-shell"]) config2.tools.shell = false;
1142
- if (values["no-files"]) config2.tools.files = false;
1143
- saveConfig(path, { ...raw, ...config2 });
1144
- const lines = [
1145
- ...copied ? [`Copied the config of ${FORMER_NAME}: ${copied} to ${path}`] : [],
1146
- ...install({ command: [process.execPath, script, "--config", path], path: process.env.PATH ?? "", log: logPath() })
1147
- ];
1148
- process.stdout.write(`${lines.join("\n")}
1149
-
1150
- For the extension's options:
1151
- URL: http://127.0.0.1:${config2.port}/mcp
1152
- Token: ${config2.token}
1153
- `);
1154
- return;
1155
- }
1156
976
  if (command !== "serve") throw new Error(`Unknown command: ${command}. See ${NAME} --help`);
1157
977
  const { config, created } = loadConfig(path, { newToken: values["new-token"] });
1158
978
  const listenPort = port(values.port, config.port);
@@ -1165,12 +985,8 @@ For the extension's options:
1165
985
  const perfLog = perfLogPath(path);
1166
986
  const http = await listen(hub, { port: listenPort, token: config.token, log, perfLog }).catch(async (e) => {
1167
987
  await hub.close();
1168
- if (e.code !== "EADDRINUSE") throw e;
1169
- const former2 = formerService();
1170
- throw new Error(
1171
- former2 ? `Port ${listenPort} is in use, likely by the service of the former name, ${FORMER_NAME} (${former2}). Remove it: ${NAME} uninstall-service. Or another port: --port <n>` : `Port ${listenPort} is in use: is ${NAME} already running (perhaps as a service)? Another port: --port <n>`,
1172
- { cause: e }
1173
- );
988
+ if (e.code === "EADDRINUSE") throw new Error(`Port ${listenPort} is in use: is ${NAME} already running in another window? Another port: --port <n>`, { cause: e });
989
+ throw e;
1174
990
  });
1175
991
  let stopping = false;
1176
992
  const stop = async () => {
@@ -1187,7 +1003,6 @@ For the extension's options:
1187
1003
  await hub.start();
1188
1004
  const names = hub.listTools().map((t) => t.name);
1189
1005
  const token = process.stdout.isTTY ? config.token : `(not printed here; run: ${NAME} token)`;
1190
- const former = formerService();
1191
1006
  const out = [
1192
1007
  `${NAME} ${VERSION}`,
1193
1008
  ` URL: http://127.0.0.1:${listenPort}/mcp`,
@@ -1196,7 +1011,6 @@ For the extension's options:
1196
1011
  ` Perf: ${perfLog} (when the extension's performance log is on)`,
1197
1012
  ` Tools: ${names.length ? names.join(", ") : "none"}`,
1198
1013
  ...hub.notRunning().map((s) => ` Not running yet: ${s.name}${s.error ? ` (${s.error})` : " (starting)"}`),
1199
- ...former ? [` The service of the former name, ${FORMER_NAME}, is still installed (${former}). Remove it: ${NAME} uninstall-service`] : [],
1200
1014
  "",
1201
1015
  "In Chrome: click the Gemini MCP Bridge icon > Settings, and enter the URL and the token.",
1202
1016
  "From another computer, or through a forwarded port: the same URL with that address and port.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "local-mcp-bridge-server",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Local MCP server for the Gemini MCP Bridge Chrome extension: your computer's shell and files, plus the MCP servers you list",
5
5
  "type": "module",
6
6
  "license": "MIT",