mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
feat: 完成第一个 mcp-chrome 接入版本
This commit is contained in:
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!");
|
||||
}
|
||||
Reference in New Issue
Block a user