From 7c04df5e2e5e378fc0f83307ac5d616e9574da8a Mon Sep 17 00:00:00 2001 From: Ashwin Bhat Date: Tue, 19 Nov 2024 14:19:59 -0800 Subject: [PATCH 1/3] fix arg passing in cli --- bin/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/cli.js b/bin/cli.js index 77d6e52..0485a30 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -19,7 +19,7 @@ console.log("Starting MCP inspector..."); const { result } = concurrently( [ { - command: `node ${inspectorServerPath}${command ? ` --env ${command}` : ""}${mcpServerArgs.length ? ` --args "${mcpServerArgs.join(" ")}"` : ""}`, + command: `node ${inspectorServerPath}${command ? ` --env ${command}` : ""}${mcpServerArgs.length ? ` --args="${mcpServerArgs.join(" ")}"` : ""}`, name: "server", }, { From 1843562dce656cf2bfd0c9a3f87541f2cac88fd0 Mon Sep 17 00:00:00 2001 From: Ashwin Bhat Date: Tue, 19 Nov 2024 14:22:00 -0800 Subject: [PATCH 2/3] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 651b114..6f293ce 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)", From 9a560e3f065227cd1f772b50d55532d5b9418ba1 Mon Sep 17 00:00:00 2001 From: Ashwin Bhat Date: Tue, 19 Nov 2024 15:42:53 -0800 Subject: [PATCH 3/3] handle quotes better --- bin/cli.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/bin/cli.js b/bin/cli.js index 0485a30..79a6d40 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", }, {