Merge pull request #641 from modelcontextprotocol/fweinberger/fix-cli-args
Fix command-line argument passing to pre-fill UI
This commit is contained in:
commit
85df5fd836
3 changed files with 20 additions and 4 deletions
|
|
@ -66,8 +66,21 @@ async function runWebClient(args: Args): Promise<void> {
|
|||
abort.abort();
|
||||
});
|
||||
|
||||
// Build arguments to pass to start.js
|
||||
const startArgs: string[] = [];
|
||||
|
||||
// Pass environment variables
|
||||
for (const [key, value] of Object.entries(args.envArgs)) {
|
||||
startArgs.push("-e", `${key}=${value}`);
|
||||
}
|
||||
|
||||
// Pass command and args (using -- to separate them)
|
||||
if (args.command) {
|
||||
startArgs.push("--", args.command, ...args.args);
|
||||
}
|
||||
|
||||
try {
|
||||
await spawnPromise("node", [inspectorClientPath], {
|
||||
await spawnPromise("node", [inspectorClientPath, ...startArgs], {
|
||||
signal: abort.signal,
|
||||
echoOutput: true,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -91,8 +91,10 @@ async function startProdServer(serverOptions) {
|
|||
"node",
|
||||
[
|
||||
inspectorServerPath,
|
||||
...(command ? [`--env`, command] : []),
|
||||
...(mcpServerArgs ? [`--args=${mcpServerArgs.join(" ")}`] : []),
|
||||
...(command ? [`--command`, command] : []),
|
||||
...(mcpServerArgs && mcpServerArgs.length > 0
|
||||
? [`--args`, mcpServerArgs.join(" ")]
|
||||
: []),
|
||||
],
|
||||
{
|
||||
env: {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ const { values } = parseArgs({
|
|||
options: {
|
||||
env: { type: "string", default: "" },
|
||||
args: { type: "string", default: "" },
|
||||
command: { type: "string", default: "" },
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -520,7 +521,7 @@ app.get("/config", originValidationMiddleware, authMiddleware, (req, res) => {
|
|||
try {
|
||||
res.json({
|
||||
defaultEnvironment,
|
||||
defaultCommand: values.env,
|
||||
defaultCommand: values.command,
|
||||
defaultArgs: values.args,
|
||||
});
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue