mcp-chrome-bridger 1.0.8 → 1.0.9
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/dist/index.js +0 -0
- package/dist/mcp/mcp-server-stdio.js +2 -2
- package/dist/mcp/register-tools.js +4 -4
- package/dist/native-messaging-host.js +9 -9
- package/dist/run_host.sh +0 -0
- package/package.json +15 -15
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 hangye
|
|
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/dist/index.js
CHANGED
|
File without changes
|
|
@@ -38,7 +38,7 @@ exports.setupTools = exports.ensureMcpClient = exports.getStdioMcpServer = void
|
|
|
38
38
|
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
39
39
|
const index_js_2 = require("@modelcontextprotocol/sdk/client/index.js");
|
|
40
40
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
41
|
-
const
|
|
41
|
+
const mcp_chrome_shared_1 = require("mcp-chrome-shared");
|
|
42
42
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
43
43
|
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
44
44
|
const fs = __importStar(require("fs"));
|
|
@@ -98,7 +98,7 @@ const ensureMcpClient = async () => {
|
|
|
98
98
|
exports.ensureMcpClient = ensureMcpClient;
|
|
99
99
|
const setupTools = (server) => {
|
|
100
100
|
// List tools handler
|
|
101
|
-
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({ tools:
|
|
101
|
+
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({ tools: mcp_chrome_shared_1.TOOL_SCHEMAS }));
|
|
102
102
|
// Call tool handler
|
|
103
103
|
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments || {}));
|
|
104
104
|
// List resources handler - REQUIRED BY MCP PROTOCOL
|
|
@@ -41,7 +41,7 @@ exports.notifyToolsListChanged = notifyToolsListChanged;
|
|
|
41
41
|
exports.handleDynamicToolsUpdate = handleDynamicToolsUpdate;
|
|
42
42
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
43
43
|
const native_messaging_host_1 = __importDefault(require("../native-messaging-host"));
|
|
44
|
-
const
|
|
44
|
+
const mcp_chrome_shared_1 = require("mcp-chrome-shared");
|
|
45
45
|
const dynamic_tools_registry_1 = require("./dynamic-tools-registry");
|
|
46
46
|
const mcp_server_1 = require("./mcp-server");
|
|
47
47
|
const fs = __importStar(require("fs"));
|
|
@@ -99,7 +99,7 @@ function handleDynamicToolsUpdate(payload) {
|
|
|
99
99
|
const setupTools = (server) => {
|
|
100
100
|
// List tools handler - include static and dynamic tools
|
|
101
101
|
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
102
|
-
const staticTools =
|
|
102
|
+
const staticTools = mcp_chrome_shared_1.TOOL_SCHEMAS;
|
|
103
103
|
const dynamicTools = (0, dynamic_tools_registry_1.getDynamicToolSchemas)();
|
|
104
104
|
return { tools: [...staticTools, ...dynamicTools] };
|
|
105
105
|
});
|
|
@@ -126,7 +126,7 @@ const handleToolCall = async (name, args) => {
|
|
|
126
126
|
toolName: dynamicTool.originalName,
|
|
127
127
|
params: args,
|
|
128
128
|
},
|
|
129
|
-
},
|
|
129
|
+
}, mcp_chrome_shared_1.NativeMessageType.CALL_TOOL, 30000);
|
|
130
130
|
if (response.status === 'success') {
|
|
131
131
|
return response.data;
|
|
132
132
|
}
|
|
@@ -141,7 +141,7 @@ const handleToolCall = async (name, args) => {
|
|
|
141
141
|
const response = await native_messaging_host_1.default.sendRequestToExtensionAndWait({
|
|
142
142
|
name,
|
|
143
143
|
args,
|
|
144
|
-
},
|
|
144
|
+
}, mcp_chrome_shared_1.NativeMessageType.CALL_TOOL, 30000);
|
|
145
145
|
if (response.status === 'success') {
|
|
146
146
|
return response.data;
|
|
147
147
|
}
|
|
@@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.NativeMessagingHost = void 0;
|
|
40
40
|
const process_1 = require("process");
|
|
41
41
|
const uuid_1 = require("uuid");
|
|
42
|
-
const
|
|
42
|
+
const mcp_chrome_shared_1 = require("mcp-chrome-shared");
|
|
43
43
|
const constant_1 = require("./constant");
|
|
44
44
|
const file_handler_1 = __importDefault(require("./file-handler"));
|
|
45
45
|
const register_tools_1 = require("./mcp/register-tools");
|
|
@@ -134,10 +134,10 @@ class NativeMessagingHost {
|
|
|
134
134
|
// Handle directive messages from Chrome
|
|
135
135
|
try {
|
|
136
136
|
switch (message.type) {
|
|
137
|
-
case
|
|
137
|
+
case mcp_chrome_shared_1.NativeMessageType.START:
|
|
138
138
|
await this.startServer(((_a = message.payload) === null || _a === void 0 ? void 0 : _a.port) || 3000);
|
|
139
139
|
break;
|
|
140
|
-
case
|
|
140
|
+
case mcp_chrome_shared_1.NativeMessageType.STOP:
|
|
141
141
|
await this.stopServer();
|
|
142
142
|
break;
|
|
143
143
|
// Keep ping/pong for simple liveness detection, but this differs from request-response pattern
|
|
@@ -147,7 +147,7 @@ class NativeMessagingHost {
|
|
|
147
147
|
case 'file_operation':
|
|
148
148
|
await this.handleFileOperation(message);
|
|
149
149
|
break;
|
|
150
|
-
case
|
|
150
|
+
case mcp_chrome_shared_1.NativeMessageType.WEBMCP_TOOLS_UPDATE:
|
|
151
151
|
// Handle WebMCP dynamic tools update from extension
|
|
152
152
|
logToFile(`Received WEBMCP_TOOLS_UPDATE: ${JSON.stringify(message.payload)}`);
|
|
153
153
|
try {
|
|
@@ -243,7 +243,7 @@ class NativeMessagingHost {
|
|
|
243
243
|
try {
|
|
244
244
|
if (this.associatedServer.isRunning) {
|
|
245
245
|
this.sendMessage({
|
|
246
|
-
type:
|
|
246
|
+
type: mcp_chrome_shared_1.NativeMessageType.ERROR,
|
|
247
247
|
payload: { message: 'Server is already running' },
|
|
248
248
|
});
|
|
249
249
|
return;
|
|
@@ -254,7 +254,7 @@ class NativeMessagingHost {
|
|
|
254
254
|
this.serverStarting = false;
|
|
255
255
|
logToFile(`HTTP server started successfully on port ${port}`);
|
|
256
256
|
this.sendMessage({
|
|
257
|
-
type:
|
|
257
|
+
type: mcp_chrome_shared_1.NativeMessageType.SERVER_STARTED,
|
|
258
258
|
payload: { port },
|
|
259
259
|
});
|
|
260
260
|
}
|
|
@@ -275,14 +275,14 @@ class NativeMessagingHost {
|
|
|
275
275
|
// Check status through associatedServer
|
|
276
276
|
if (!this.associatedServer.isRunning) {
|
|
277
277
|
this.sendMessage({
|
|
278
|
-
type:
|
|
278
|
+
type: mcp_chrome_shared_1.NativeMessageType.ERROR,
|
|
279
279
|
payload: { message: 'Server is not running' },
|
|
280
280
|
});
|
|
281
281
|
return;
|
|
282
282
|
}
|
|
283
283
|
await this.associatedServer.stop();
|
|
284
284
|
// this.serverStarted = false; // Server should update its own status after successful stop
|
|
285
|
-
this.sendMessage({ type:
|
|
285
|
+
this.sendMessage({ type: mcp_chrome_shared_1.NativeMessageType.SERVER_STOPPED }); // Distinguish from previous 'stopped'
|
|
286
286
|
}
|
|
287
287
|
catch (error) {
|
|
288
288
|
this.sendError(`Failed to stop server: ${error.message}`);
|
|
@@ -318,7 +318,7 @@ class NativeMessagingHost {
|
|
|
318
318
|
*/
|
|
319
319
|
sendError(errorMessage) {
|
|
320
320
|
this.sendMessage({
|
|
321
|
-
type:
|
|
321
|
+
type: mcp_chrome_shared_1.NativeMessageType.ERROR_FROM_NATIVE_HOST, // Use more explicit type
|
|
322
322
|
payload: { message: errorMessage },
|
|
323
323
|
});
|
|
324
324
|
}
|
package/dist/run_host.sh
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-chrome-bridger",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Chrome Native-Messaging host (Node) - Fork with Chrome Web Store support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"mcp-chrome-bridger": "./dist/cli.js",
|
|
8
8
|
"mcp-chrome-stdio": "./dist/mcp/mcp-server-stdio.js"
|
|
9
9
|
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"dev": "nodemon --watch src --ext ts,js,json --ignore dist/ --exec \"npm run build && npm run register:dev\"",
|
|
12
|
-
"build": "ts-node src/scripts/build.ts",
|
|
13
|
-
"test": "jest",
|
|
14
|
-
"test:watch": "jest --watch",
|
|
15
|
-
"lint": "eslint 'src/**/*.{js,ts}'",
|
|
16
|
-
"lint:fix": "eslint 'src/**/*.{js,ts}' --fix",
|
|
17
|
-
"format": "prettier --write 'src/**/*.{js,ts,json}'",
|
|
18
|
-
"register:dev": "node dist/scripts/register-dev.js",
|
|
19
|
-
"postinstall": "node scripts/postinstall-check.js"
|
|
20
|
-
},
|
|
21
10
|
"files": [
|
|
22
11
|
"dist",
|
|
23
12
|
"scripts"
|
|
@@ -38,13 +27,13 @@
|
|
|
38
27
|
"@modelcontextprotocol/sdk": "^1.11.0",
|
|
39
28
|
"@types/node-fetch": "^2.6.13",
|
|
40
29
|
"chalk": "^5.4.1",
|
|
41
|
-
"chrome-mcp-shared": "^1.0.2",
|
|
42
30
|
"commander": "^13.1.0",
|
|
43
31
|
"fastify": "^5.3.2",
|
|
44
32
|
"is-admin": "^4.0.0",
|
|
45
33
|
"node-fetch": "^2.7.0",
|
|
46
34
|
"pino": "^9.6.0",
|
|
47
|
-
"uuid": "^11.1.0"
|
|
35
|
+
"uuid": "^11.1.0",
|
|
36
|
+
"mcp-chrome-shared": "1.0.0"
|
|
48
37
|
},
|
|
49
38
|
"devDependencies": {
|
|
50
39
|
"@jest/globals": "^29.7.0",
|
|
@@ -77,5 +66,16 @@
|
|
|
77
66
|
"*.{json,md}": [
|
|
78
67
|
"prettier --write"
|
|
79
68
|
]
|
|
69
|
+
},
|
|
70
|
+
"scripts": {
|
|
71
|
+
"dev": "nodemon --watch src --ext ts,js,json --ignore dist/ --exec \"npm run build && npm run register:dev\"",
|
|
72
|
+
"build": "ts-node src/scripts/build.ts",
|
|
73
|
+
"test": "jest",
|
|
74
|
+
"test:watch": "jest --watch",
|
|
75
|
+
"lint": "eslint 'src/**/*.{js,ts}'",
|
|
76
|
+
"lint:fix": "eslint 'src/**/*.{js,ts}' --fix",
|
|
77
|
+
"format": "prettier --write 'src/**/*.{js,ts,json}'",
|
|
78
|
+
"register:dev": "node dist/scripts/register-dev.js",
|
|
79
|
+
"postinstall": "node scripts/postinstall-check.js"
|
|
80
80
|
}
|
|
81
|
-
}
|
|
81
|
+
}
|