scripts / check-mcp.js
#!/usr/bin/env node
/**
* 獨立診斷腳本 - 測試 MCP server 是否能正常啟動
*/
const { spawn } = require("child_process");
const path = require("path");
const fs = require("fs");
const PLUGIN_ROOT = path.resolve(__dirname, "..");
const MAVERICK_DIR = path.join(PLUGIN_ROOT, "maverick-mcp");
function getPythonExecutable() {
const venvDir = path.join(MAVERICK_DIR, ".venv");
if (process.platform === "win32") {
return path.join(venvDir, "Scripts", "python.exe");
} else {
return path.join(venvDir, "bin", "python");
}
}
function main() {
console.log("=== MaverickMCP MCP Server Diagnostic ===\n");
const python = getPythonExecutable();
console.log(`Python path: ${python}`);
console.log(`Exists: ${fs.existsSync(python)}`);
console.log(`Maverick root: ${MAVERICK_DIR}`);
console.log(`Exists: ${fs.existsSync(MAVERICK_DIR)}\n`);
if (!fs.existsSync(python)) {
console.error("ERROR: Python venv not found. Run 'npm install' first.");
process.exit(1);
}
console.log("Starting MCP server...\n");
const child = spawn(python, ["-m", "maverick.server", "--transport", "stdio"], {
cwd: MAVERICK_DIR,
stdio: ["pipe", "pipe", "pipe"],
});
let stdoutData = "";
let stderrData = "";
child.stdout.on("data", (data) => {
const text = data.toString();
stdoutData += text;
console.log(`[STDOUT] ${text}`);
});
child.stderr.on("data", (data) => {
const text = data.toString();
stderrData += text;
console.error(`[STDERR] ${text}`);
});
child.on("error", (err) => {
console.error(`[ERROR] Failed to spawn process: ${err.message}`);
});
child.on("close", (code) => {
console.log(`\nProcess exited with code ${code}`);
console.log(`\nTotal stdout: ${stdoutData.length} bytes`);
console.log(`Total stderr: ${stderrData.length} bytes`);
if (code === 0) {
console.log("\n✓ MCP server started successfully!");
} else {
console.log("\n✗ MCP server failed to start.");
}
});
// 等待 5 秒後關閉
setTimeout(() => {
console.log("\nTimeout reached, terminating process...");
child.kill();
}, 5000);
}
main();
scripts / check-mcp.js
#!/usr/bin/env node
/**
* 獨立診斷腳本 - 測試 MCP server 是否能正常啟動
*/
const { spawn } = require("child_process");
const path = require("path");
const fs = require("fs");
const PLUGIN_ROOT = path.resolve(__dirname, "..");
const MAVERICK_DIR = path.join(PLUGIN_ROOT, "maverick-mcp");
function getPythonExecutable() {
const venvDir = path.join(MAVERICK_DIR, ".venv");
if (process.platform === "win32") {
return path.join(venvDir, "Scripts", "python.exe");
} else {
return path.join(venvDir, "bin", "python");
}
}
function main() {
console.log("=== MaverickMCP MCP Server Diagnostic ===\n");
const python = getPythonExecutable();
console.log(`Python path: ${python}`);
console.log(`Exists: ${fs.existsSync(python)}`);
console.log(`Maverick root: ${MAVERICK_DIR}`);
console.log(`Exists: ${fs.existsSync(MAVERICK_DIR)}\n`);
if (!fs.existsSync(python)) {
console.error("ERROR: Python venv not found. Run 'npm install' first.");
process.exit(1);
}
console.log("Starting MCP server...\n");
const child = spawn(python, ["-m", "maverick.server", "--transport", "stdio"], {
cwd: MAVERICK_DIR,
stdio: ["pipe", "pipe", "pipe"],
});
let stdoutData = "";
let stderrData = "";
child.stdout.on("data", (data) => {
const text = data.toString();
stdoutData += text;
console.log(`[STDOUT] ${text}`);
});
child.stderr.on("data", (data) => {
const text = data.toString();
stderrData += text;
console.error(`[STDERR] ${text}`);
});
child.on("error", (err) => {
console.error(`[ERROR] Failed to spawn process: ${err.message}`);
});
child.on("close", (code) => {
console.log(`\nProcess exited with code ${code}`);
console.log(`\nTotal stdout: ${stdoutData.length} bytes`);
console.log(`Total stderr: ${stderrData.length} bytes`);
if (code === 0) {
console.log("\n✓ MCP server started successfully!");
} else {
console.log("\n✗ MCP server failed to start.");
}
});
// 等待 5 秒後關閉
setTimeout(() => {
console.log("\nTimeout reached, terminating process...");
child.kill();
}, 5000);
}
main();