Skip to content

Commit 85df5fd

Browse files
authored
Merge pull request #641 from modelcontextprotocol/fweinberger/fix-cli-args
Fix command-line argument passing to pre-fill UI
2 parents 0db0bbb + 21745d6 commit 85df5fd

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

cli/src/cli.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,21 @@ async function runWebClient(args: Args): Promise<void> {
6666
abort.abort();
6767
});
6868

69+
// Build arguments to pass to start.js
70+
const startArgs: string[] = [];
71+
72+
// Pass environment variables
73+
for (const [key, value] of Object.entries(args.envArgs)) {
74+
startArgs.push("-e", `${key}=${value}`);
75+
}
76+
77+
// Pass command and args (using -- to separate them)
78+
if (args.command) {
79+
startArgs.push("--", args.command, ...args.args);
80+
}
81+
6982
try {
70-
await spawnPromise("node", [inspectorClientPath], {
83+
await spawnPromise("node", [inspectorClientPath, ...startArgs], {
7184
signal: abort.signal,
7285
echoOutput: true,
7386
});

client/bin/start.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ async function startProdServer(serverOptions) {
9191
"node",
9292
[
9393
inspectorServerPath,
94-
...(command ? [`--env`, command] : []),
95-
...(mcpServerArgs ? [`--args=${mcpServerArgs.join(" ")}`] : []),
94+
...(command ? [`--command`, command] : []),
95+
...(mcpServerArgs && mcpServerArgs.length > 0
96+
? [`--args`, mcpServerArgs.join(" ")]
97+
: []),
9698
],
9799
{
98100
env: {

server/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const { values } = parseArgs({
3939
options: {
4040
env: { type: "string", default: "" },
4141
args: { type: "string", default: "" },
42+
command: { type: "string", default: "" },
4243
},
4344
});
4445

@@ -520,7 +521,7 @@ app.get("/config", originValidationMiddleware, authMiddleware, (req, res) => {
520521
try {
521522
res.json({
522523
defaultEnvironment,
523-
defaultCommand: values.env,
524+
defaultCommand: values.command,
524525
defaultArgs: values.args,
525526
});
526527
} catch (error) {

0 commit comments

Comments
 (0)