From 010d50e993e137e8e7cbdd0d7f9d4fa058a1db6b Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" Date: Mon, 1 Jun 2026 04:47:09 +0000 Subject: [PATCH] refactor(cli): keep mcp add yargs internals local --- packages/opencode/src/cli/cmd/mcp.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/opencode/src/cli/cmd/mcp.ts b/packages/opencode/src/cli/cmd/mcp.ts index 86b7fd8ac5b..5702099e09c 100644 --- a/packages/opencode/src/cli/cmd/mcp.ts +++ b/packages/opencode/src/cli/cmd/mcp.ts @@ -1,4 +1,4 @@ -import { cmd } from "./cmd" +import { cmd, type WithDoubleDash } from "./cmd" import { effectCmd, fail } from "../effect-cmd" import { Cause } from "effect" import { Client } from "@modelcontextprotocol/sdk/client/index.js" @@ -56,8 +56,6 @@ function isMcpRemote(config: McpEntry): config is McpRemote { } type McpAddArgs = { - _?: Array - "--"?: string[] name?: string args?: string[] type?: "local" | "remote" @@ -65,6 +63,7 @@ type McpAddArgs = { header?: string[] global?: boolean } +type McpAddYargs = WithDoubleDash & { _?: Array } function configuredServers(config: Config.Info) { return Object.entries(config.mcp ?? {}).filter((entry): entry is [string, McpConfigured] => isMcpConfigured(entry[1])) @@ -665,11 +664,13 @@ Examples: }) function mcpAddArgs(input: McpAddArgs) { - const addIndex = input._?.lastIndexOf("add") ?? -1 + // For nested variadic commands, yargs puts tokens after `--` in `_` instead of the positional array. + const raw = input as McpAddYargs + const addIndex = raw._?.lastIndexOf("add") ?? -1 return [ ...(input.args ?? []), - ...(addIndex === -1 || !input._ ? [] : input._.slice(addIndex + 1).map(String)), - ...(input["--"] ?? []), + ...(addIndex === -1 || !raw._ ? [] : raw._.slice(addIndex + 1).map(String)), + ...(raw["--"] ?? []), ] }