diff --git a/bin/cli.js b/bin/cli.js index 77d6e52a9..79a6d402a 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -16,10 +16,30 @@ const inspectorClientPath = join(__dirname, "../client/bin/cli.js"); console.log("Starting MCP inspector..."); +function escapeArg(arg) { + if (arg.includes(" ") || arg.includes("'") || arg.includes('"')) { + return `\\"${arg.replace(/"/g, '\\\\\\"')}\\"`; + } + return arg; +} + +const serverCommand = [ + `node`, + inspectorServerPath, + command ? `--env ${escapeArg(command)}` : "", + mcpServerArgs.length + ? `--args="${mcpServerArgs.map(escapeArg).join(" ")}"` + : "", +] + .filter(Boolean) + .join(" "); + +console.log(serverCommand); + const { result } = concurrently( [ { - command: `node ${inspectorServerPath}${command ? ` --env ${command}` : ""}${mcpServerArgs.length ? ` --args "${mcpServerArgs.join(" ")}"` : ""}`, + command: serverCommand, name: "server", }, { diff --git a/package.json b/package.json index 651b11483..6f293ce0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@modelcontextprotocol/inspector", - "version": "0.1.5", + "version": "0.1.6", "description": "Model Context Protocol inspector", "license": "MIT", "author": "Anthropic, PBC (https://anthropic.com)",