Skip to content

Commit 676de45

Browse files
authored
Merge pull request modelcontextprotocol#64 from modelcontextprotocol/ashwin/spaces
fix arg passing in cli
2 parents 64d2fea + 9a560e3 commit 676de45

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

bin/cli.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,30 @@ const inspectorClientPath = join(__dirname, "../client/bin/cli.js");
1616

1717
console.log("Starting MCP inspector...");
1818

19+
function escapeArg(arg) {
20+
if (arg.includes(" ") || arg.includes("'") || arg.includes('"')) {
21+
return `\\"${arg.replace(/"/g, '\\\\\\"')}\\"`;
22+
}
23+
return arg;
24+
}
25+
26+
const serverCommand = [
27+
`node`,
28+
inspectorServerPath,
29+
command ? `--env ${escapeArg(command)}` : "",
30+
mcpServerArgs.length
31+
? `--args="${mcpServerArgs.map(escapeArg).join(" ")}"`
32+
: "",
33+
]
34+
.filter(Boolean)
35+
.join(" ");
36+
37+
console.log(serverCommand);
38+
1939
const { result } = concurrently(
2040
[
2141
{
22-
command: `node ${inspectorServerPath}${command ? ` --env ${command}` : ""}${mcpServerArgs.length ? ` --args "${mcpServerArgs.join(" ")}"` : ""}`,
42+
command: serverCommand,
2343
name: "server",
2444
},
2545
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@modelcontextprotocol/inspector",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "Model Context Protocol inspector",
55
"license": "MIT",
66
"author": "Anthropic, PBC (https://anthropic.com)",

0 commit comments

Comments
 (0)