Skip to content

Commit 9a560e3

Browse files
committed
handle quotes better
1 parent 1843562 commit 9a560e3

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
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
{

0 commit comments

Comments
 (0)