mcp-page-bridge 0.1.7 → 0.2.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.
- package/bin/mcp-page-bridge.js +74 -0
- package/package.json +9 -30
- package/dist/bridge.d.ts +0 -53
- package/dist/bridge.js +0 -7
- package/dist/chunk-VB4V3KDR.js +0 -1703
- package/dist/cli.d.ts +0 -19
- package/dist/cli.js +0 -314
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Thin launcher for the mcp-page-bridge Go binary (esbuild/turbo model): the
|
|
3
|
+
// real implementation lives in a per-platform optionalDependency; npm installs
|
|
4
|
+
// only the one matching this machine. All arguments and stdio pass through.
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import { accessSync, chmodSync, constants } from "node:fs";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
|
|
11
|
+
const PLATFORM_PACKAGES = {
|
|
12
|
+
"linux-x64": ["mcp-page-bridge-linux-x64", "mcp-page-bridge"],
|
|
13
|
+
"linux-arm64": ["mcp-page-bridge-linux-arm64", "mcp-page-bridge"],
|
|
14
|
+
"darwin-x64": ["mcp-page-bridge-darwin-x64", "mcp-page-bridge"],
|
|
15
|
+
"darwin-arm64": ["mcp-page-bridge-darwin-arm64", "mcp-page-bridge"],
|
|
16
|
+
"win32-x64": ["mcp-page-bridge-windows-x64", "mcp-page-bridge.exe"],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function resolveBinary() {
|
|
20
|
+
// Escape hatch for tests, local checkouts, and unsupported platforms.
|
|
21
|
+
if (process.env.MCP_PAGE_BRIDGE_BINARY) return process.env.MCP_PAGE_BRIDGE_BINARY;
|
|
22
|
+
|
|
23
|
+
const key = `${process.platform}-${process.arch}`;
|
|
24
|
+
const entry = PLATFORM_PACKAGES[key];
|
|
25
|
+
if (!entry) {
|
|
26
|
+
console.error(
|
|
27
|
+
`[mcp-page-bridge] unsupported platform ${key}; download a binary from ` +
|
|
28
|
+
"https://github.com/rytsh/mcp-page-bridge/releases or build with " +
|
|
29
|
+
"`go install github.com/rytsh/mcp-page-bridge/cmd/mcp-page-bridge@latest`",
|
|
30
|
+
);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const [pkg, bin] = entry;
|
|
35
|
+
try {
|
|
36
|
+
const path = require.resolve(`${pkg}/bin/${bin}`);
|
|
37
|
+
// Some package managers (e.g. pnpm pack) strip the executable bit from
|
|
38
|
+
// files not listed in `bin`; restore it before spawning.
|
|
39
|
+
if (process.platform !== "win32") {
|
|
40
|
+
try {
|
|
41
|
+
accessSync(path, constants.X_OK);
|
|
42
|
+
} catch {
|
|
43
|
+
chmodSync(path, 0o755);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return path;
|
|
47
|
+
} catch {
|
|
48
|
+
console.error(
|
|
49
|
+
`[mcp-page-bridge] the platform package ${pkg} is missing. ` +
|
|
50
|
+
"It installs as an optionalDependency of mcp-page-bridge — make sure optional " +
|
|
51
|
+
"dependencies are not disabled (npm: --no-optional, pnpm: --no-optional), then reinstall.",
|
|
52
|
+
);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const child = spawn(resolveBinary(), process.argv.slice(2), { stdio: "inherit" });
|
|
58
|
+
|
|
59
|
+
child.on("error", (error) => {
|
|
60
|
+
console.error(`[mcp-page-bridge] failed to start binary: ${error.message}`);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
65
|
+
process.on(signal, () => child.kill(signal));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
child.on("exit", (code, signal) => {
|
|
69
|
+
if (signal) {
|
|
70
|
+
process.kill(process.pid, signal);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
process.exit(code ?? 0);
|
|
74
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-page-bridge",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MCP bridge that aggregates live browser-page MCP servers and exposes them to a coding agent over stdio",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,16 +18,10 @@
|
|
|
18
18
|
"opencode"
|
|
19
19
|
],
|
|
20
20
|
"bin": {
|
|
21
|
-
"mcp-page-bridge": "./
|
|
22
|
-
},
|
|
23
|
-
"exports": {
|
|
24
|
-
"./bridge": {
|
|
25
|
-
"types": "./dist/bridge.d.ts",
|
|
26
|
-
"import": "./dist/bridge.js"
|
|
27
|
-
}
|
|
21
|
+
"mcp-page-bridge": "./bin/mcp-page-bridge.js"
|
|
28
22
|
},
|
|
29
23
|
"files": [
|
|
30
|
-
"
|
|
24
|
+
"bin"
|
|
31
25
|
],
|
|
32
26
|
"engines": {
|
|
33
27
|
"node": ">=18"
|
|
@@ -35,26 +29,11 @@
|
|
|
35
29
|
"publishConfig": {
|
|
36
30
|
"access": "public"
|
|
37
31
|
},
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"@types/ws": "^8.5.13",
|
|
45
|
-
"tsup": "^8.3.5",
|
|
46
|
-
"tsx": "^4.19.2",
|
|
47
|
-
"typescript": "^5.7.3",
|
|
48
|
-
"vitest": "^2.1.8",
|
|
49
|
-
"zod": "^3.25.0",
|
|
50
|
-
"mcp-page-bridge-protocol": "0.1.7"
|
|
51
|
-
},
|
|
52
|
-
"scripts": {
|
|
53
|
-
"start": "tsx src/cli.ts",
|
|
54
|
-
"dev": "tsx watch src/cli.ts",
|
|
55
|
-
"test": "vitest run",
|
|
56
|
-
"test:watch": "vitest",
|
|
57
|
-
"typecheck": "tsc -p tsconfig.json",
|
|
58
|
-
"build": "tsup"
|
|
32
|
+
"optionalDependencies": {
|
|
33
|
+
"mcp-page-bridge-linux-x64": "0.2.1",
|
|
34
|
+
"mcp-page-bridge-linux-arm64": "0.2.1",
|
|
35
|
+
"mcp-page-bridge-darwin-x64": "0.2.1",
|
|
36
|
+
"mcp-page-bridge-darwin-arm64": "0.2.1",
|
|
37
|
+
"mcp-page-bridge-windows-x64": "0.2.1"
|
|
59
38
|
}
|
|
60
39
|
}
|
package/dist/bridge.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { WebSocketServer } from 'ws';
|
|
2
|
-
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
-
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
4
|
-
import { Tool, Prompt, Resource } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
-
|
|
6
|
-
interface ProviderMeta {
|
|
7
|
-
url?: string;
|
|
8
|
-
title?: string;
|
|
9
|
-
userAgent?: string;
|
|
10
|
-
tabId?: number;
|
|
11
|
-
providerId?: string;
|
|
12
|
-
}
|
|
13
|
-
/** A connected browser MCP server (one per WebSocket connection). */
|
|
14
|
-
interface Provider {
|
|
15
|
-
id: string;
|
|
16
|
-
/** Unique, tool-name-safe namespace label. */
|
|
17
|
-
label: string;
|
|
18
|
-
/** Raw serverInfo.name reported by the browser. */
|
|
19
|
-
rawName: string;
|
|
20
|
-
version: string;
|
|
21
|
-
client: Client;
|
|
22
|
-
tools: Tool[];
|
|
23
|
-
prompts: Prompt[];
|
|
24
|
-
resources: Resource[];
|
|
25
|
-
meta: ProviderMeta;
|
|
26
|
-
connectedAt: number;
|
|
27
|
-
}
|
|
28
|
-
type PublicProvider = Omit<Provider, "client">;
|
|
29
|
-
interface Bridge {
|
|
30
|
-
/** Agent-facing MCP server (connect this to a stdio/http transport). */
|
|
31
|
-
server: Server;
|
|
32
|
-
wss: WebSocketServer;
|
|
33
|
-
/** Actual port the WS server bound to (useful when port 0 is requested). */
|
|
34
|
-
port: number;
|
|
35
|
-
listProviders(): PublicProvider[];
|
|
36
|
-
close(): Promise<void>;
|
|
37
|
-
}
|
|
38
|
-
interface BridgeOptions {
|
|
39
|
-
port?: number;
|
|
40
|
-
host?: string;
|
|
41
|
-
/** If set, browsers must connect with `?token=<token>` or they're rejected. */
|
|
42
|
-
token?: string;
|
|
43
|
-
/**
|
|
44
|
-
* If set (> 0), the bridge shuts itself down after this many ms with no
|
|
45
|
-
* connected browser providers AND no attached `/agent` connections.
|
|
46
|
-
*/
|
|
47
|
-
idleTimeoutMs?: number;
|
|
48
|
-
/** Invoked after an idle-triggered shutdown completes (e.g. to exit a daemon). */
|
|
49
|
-
onIdleShutdown?: () => void;
|
|
50
|
-
}
|
|
51
|
-
declare function createBridge(opts?: BridgeOptions): Promise<Bridge>;
|
|
52
|
-
|
|
53
|
-
export { type Bridge, type BridgeOptions, type PublicProvider, createBridge };
|