mcp-chrome-bridger 1.0.7 → 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 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 chrome_mcp_shared_1 = require("chrome-mcp-shared");
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: chrome_mcp_shared_1.TOOL_SCHEMAS }));
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 chrome_mcp_shared_1 = require("chrome-mcp-shared");
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 = chrome_mcp_shared_1.TOOL_SCHEMAS;
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
- }, chrome_mcp_shared_1.NativeMessageType.CALL_TOOL, 30000);
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
- }, chrome_mcp_shared_1.NativeMessageType.CALL_TOOL, 30000);
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 chrome_mcp_shared_1 = require("chrome-mcp-shared");
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 chrome_mcp_shared_1.NativeMessageType.START:
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 chrome_mcp_shared_1.NativeMessageType.STOP:
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 chrome_mcp_shared_1.NativeMessageType.WEBMCP_TOOLS_UPDATE:
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: chrome_mcp_shared_1.NativeMessageType.ERROR,
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: chrome_mcp_shared_1.NativeMessageType.SERVER_STARTED,
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: chrome_mcp_shared_1.NativeMessageType.ERROR,
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: chrome_mcp_shared_1.NativeMessageType.SERVER_STOPPED }); // Distinguish from previous 'stopped'
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: chrome_mcp_shared_1.NativeMessageType.ERROR_FROM_NATIVE_HOST, // Use more explicit 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,25 +1,15 @@
1
1
  {
2
2
  "name": "mcp-chrome-bridger",
3
- "version": "1.0.7",
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
- "dist"
11
+ "dist",
12
+ "scripts"
23
13
  ],
24
14
  "engines": {
25
15
  "node": ">=14.0.0"
@@ -37,13 +27,13 @@
37
27
  "@modelcontextprotocol/sdk": "^1.11.0",
38
28
  "@types/node-fetch": "^2.6.13",
39
29
  "chalk": "^5.4.1",
40
- "chrome-mcp-shared": "^1.0.2",
41
30
  "commander": "^13.1.0",
42
31
  "fastify": "^5.3.2",
43
32
  "is-admin": "^4.0.0",
44
33
  "node-fetch": "^2.7.0",
45
34
  "pino": "^9.6.0",
46
- "uuid": "^11.1.0"
35
+ "uuid": "^11.1.0",
36
+ "mcp-chrome-shared": "1.0.0"
47
37
  },
48
38
  "devDependencies": {
49
39
  "@jest/globals": "^29.7.0",
@@ -76,5 +66,16 @@
76
66
  "*.{json,md}": [
77
67
  "prettier --write"
78
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"
79
80
  }
80
- }
81
+ }
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Postinstall wrapper script
5
+ * Checks if the compiled postinstall.js exists before running it.
6
+ * This handles CI environments where dist/ doesn't exist yet during pnpm install.
7
+ */
8
+
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+
12
+ const postinstallPath = path.join(__dirname, '..', 'dist', 'scripts', 'postinstall.js');
13
+
14
+ if (fs.existsSync(postinstallPath)) {
15
+ // dist/ exists, run the actual postinstall script
16
+ require(postinstallPath);
17
+ } else {
18
+ // dist/ doesn't exist yet (CI build or fresh clone)
19
+ // This is expected - the postinstall will run when users install the published package
20
+ console.log('Skipping postinstall: dist/ not built yet (CI/development environment)');
21
+ }