From 8e0bceaea9040d34ecdb27937cb3f7c71bdb349b Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" Date: Mon, 1 Jun 2026 04:57:16 +0000 Subject: [PATCH] refactor(cli): require mcp command separator --- packages/opencode/src/cli/cmd/mcp.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/packages/opencode/src/cli/cmd/mcp.ts b/packages/opencode/src/cli/cmd/mcp.ts index 5702099e09c..73baf8e6f91 100644 --- a/packages/opencode/src/cli/cmd/mcp.ts +++ b/packages/opencode/src/cli/cmd/mcp.ts @@ -63,7 +63,6 @@ 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])) @@ -450,7 +449,6 @@ export const McpAddCommand = effectCmd({ describe: "add an MCP server", builder: (yargs) => yargs - .parserConfiguration({ "unknown-options-as-args": true }) .positional("name", { describe: "name of the MCP server", type: "string", @@ -492,7 +490,7 @@ Examples: opencode mcp add local-env --env FOO=bar -- node server.js opencode mcp add sg --header Authorization=token https://sg.example/mcp opencode mcp add hugging-face https://huggingface.co/mcp`), - handler: Effect.fn("Cli.mcp.add")(function* (input: McpAddArgs) { + handler: Effect.fn("Cli.mcp.add")(function* (input: WithDoubleDash) { const maybeCtx = yield* InstanceRef if (!maybeCtx) return yield* Effect.die("InstanceRef not provided") const ctx = maybeCtx @@ -663,15 +661,8 @@ Examples: }), }) -function mcpAddArgs(input: McpAddArgs) { - // 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 || !raw._ ? [] : raw._.slice(addIndex + 1).map(String)), - ...(raw["--"] ?? []), - ] +function mcpAddArgs(input: WithDoubleDash) { + return [...(input.args ?? []), ...(input["--"] ?? [])] } function parseInlineMcpAdd(