mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-21 15:55:50 +00:00
feat: 完成第一个 mcp-chrome 接入版本
This commit is contained in:
@@ -49,14 +49,15 @@
|
|||||||
"test": "bun test",
|
"test": "bun test",
|
||||||
"check:unused": "knip-bun",
|
"check:unused": "knip-bun",
|
||||||
"health": "bun run scripts/health-check.ts",
|
"health": "bun run scripts/health-check.ts",
|
||||||
"postinstall": "node scripts/postinstall.cjs",
|
"postinstall": "node scripts/postinstall.cjs && node scripts/setup-chrome-mcp.mjs",
|
||||||
"docs:dev": "npx mintlify dev",
|
"docs:dev": "npx mintlify dev",
|
||||||
"rcs": "bun run scripts/rcs.ts"
|
"rcs": "bun run scripts/rcs.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/he": "^1.2.3"
|
"mcp-chrome-bridge": "^1.0.31"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/he": "^1.2.3",
|
||||||
"@langfuse/otel": "^5.1.0",
|
"@langfuse/otel": "^5.1.0",
|
||||||
"@langfuse/tracing": "^5.1.0",
|
"@langfuse/tracing": "^5.1.0",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
|
|||||||
46
scripts/setup-chrome-mcp.mjs
Normal file
46
scripts/setup-chrome-mcp.mjs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unified Chrome MCP setup script.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* node scripts/setup-chrome-mcp.mjs # Run full setup (fix-permissions → register → doctor)
|
||||||
|
* node scripts/setup-chrome-mcp.mjs doctor # Run a single sub-command
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { execFileSync } from "node:child_process";
|
||||||
|
import { dirname, join } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const cliPath = join(
|
||||||
|
__dirname,
|
||||||
|
"..",
|
||||||
|
"node_modules",
|
||||||
|
"mcp-chrome-bridge",
|
||||||
|
"dist",
|
||||||
|
"cli.js",
|
||||||
|
);
|
||||||
|
|
||||||
|
const userArgs = process.argv.slice(2);
|
||||||
|
|
||||||
|
if (userArgs.length > 0) {
|
||||||
|
// Forward single sub-command
|
||||||
|
execFileSync("node", [cliPath, ...userArgs], { stdio: "inherit" });
|
||||||
|
} else {
|
||||||
|
// Full setup sequence
|
||||||
|
const steps = [
|
||||||
|
["fix-permissions"],
|
||||||
|
["register", "--browser", "chrome"],
|
||||||
|
["doctor"],
|
||||||
|
];
|
||||||
|
|
||||||
|
for (let i = 0; i < steps.length; i++) {
|
||||||
|
const args = steps[i];
|
||||||
|
const isLast = i === steps.length - 1;
|
||||||
|
if (isLast) console.log(`\n[${i + 1}/${steps.length}] ${args.join(" ")}`);
|
||||||
|
execFileSync("node", [cliPath, ...args], { stdio: isLast ? "inherit" : "pipe" });
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("\nChrome MCP setup complete!");
|
||||||
|
}
|
||||||
@@ -2270,7 +2270,14 @@ async function run(): Promise<CommanderCommand> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse the MCP config files/strings if provided
|
// Parse the MCP config files/strings if provided
|
||||||
let dynamicMcpConfig: Record<string, ScopedMcpServerConfig> = {};
|
let dynamicMcpConfig: Record<string, ScopedMcpServerConfig> = {
|
||||||
|
// Built-in MCP servers (default disabled, user enables via /mcp)
|
||||||
|
"mcp-chrome": {
|
||||||
|
type: "http",
|
||||||
|
url: "http://127.0.0.1:12306/mcp",
|
||||||
|
scope: "dynamic",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
if (mcpConfig && mcpConfig.length > 0) {
|
if (mcpConfig && mcpConfig.length > 0) {
|
||||||
// Process mcpConfig array
|
// Process mcpConfig array
|
||||||
|
|||||||
@@ -1505,20 +1505,25 @@ export function areMcpConfigsAllowedWithEnterpriseMcpConfig(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Built-in MCP server that defaults to disabled. Unlike user-configured servers
|
* Built-in MCP servers that default to disabled. Unlike user-configured servers
|
||||||
* (opt-out via disabledMcpServers), this requires explicit opt-in via
|
* (opt-out via disabledMcpServers), these require explicit opt-in via
|
||||||
* enabledMcpServers. Shows up in /mcp as disabled until the user enables it.
|
* enabledMcpServers. They show up in /mcp as disabled until the user enables them.
|
||||||
*/
|
*/
|
||||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||||
const DEFAULT_DISABLED_BUILTIN = feature('CHICAGO_MCP')
|
const DEFAULT_DISABLED_BUILTINS: Set<string> = new Set([
|
||||||
? (
|
'mcp-chrome',
|
||||||
require('../../utils/computerUse/common.js') as typeof import('../../utils/computerUse/common.js')
|
...(feature('CHICAGO_MCP')
|
||||||
).COMPUTER_USE_MCP_SERVER_NAME
|
? [
|
||||||
: null
|
(
|
||||||
|
require('../../utils/computerUse/common.js') as typeof import('../../utils/computerUse/common.js')
|
||||||
|
).COMPUTER_USE_MCP_SERVER_NAME,
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
])
|
||||||
/* eslint-enable @typescript-eslint/no-require-imports */
|
/* eslint-enable @typescript-eslint/no-require-imports */
|
||||||
|
|
||||||
function isDefaultDisabledBuiltin(name: string): boolean {
|
function isDefaultDisabledBuiltin(name: string): boolean {
|
||||||
return DEFAULT_DISABLED_BUILTIN !== null && name === DEFAULT_DISABLED_BUILTIN
|
return DEFAULT_DISABLED_BUILTINS.has(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user