Skip to content

fix(cli): refuse a URL that contradicts a positional command or --transport stdio - #2701

Merged
cliffhall merged 2 commits into
v2/mainfrom
v2/fix/2611-cli-target-transport-conflicts
Oct 12, 2026
Merged

cliffhall merged 2 commits into
v2/mainfrom
v2/fix/2611-cli-target-transport-conflicts

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #2611

What changed

buildConfigFromOptions (core/mcp/node/config.ts) resolved the URL as positional URL ?? --server-url and returned from the URL branch, so the other flags were never checked. It now picks the target before the transport and refuses contradictory flags instead of letting one silently win:

Invocation Before After
node ./server.js --server-url https://example.com/mcp command dropped, connects over HTTP Cannot combine a positional target (node) with --server-url (https://example.com/mcp). Pass one or the other.
https://a/mcp --server-url https://b/mcp positional URL wins same refusal
--transport stdio --server-url https://example.com/mcp stdio ignored, HTTP sniffed from /mcp stdio transport cannot be used with a URL (…)
--transport stdio --server-url https://example.com/foo "Transport type not specified…" same stdio refusal
--transport <unknown> with a URL (reachable via --web, which doesn't validate the flag) path sniffed Invalid transport type: …

The /mcp / /sse path sniffing now runs only when --transport is absent. This lives in core, so the TUI, --web, mcpdo and servers/add pick up the same refusals.

clients/cli/README.md: the first remote example claimed "default is SSE" and failed as written. It now uses a /mcp URL with --method tools/list and says plainly that there is no default transport.

Tests

Six new cases in clients/web/src/test/core/mcp/node/config.test.ts: each refusal, plus an explicit --transport sse overriding a /mcp path. npm run local:gate is green.

🤖 Generated with Claude Code

…nsport stdio (#2611)

buildConfigFromOptions resolved the target as `positional URL ?? --server-url`
and returned on the URL branch, so a positional command next to --server-url
was silently dropped, and --transport stdio next to a URL was ignored (or
reported as "not specified" when the path gave no hint).

Decide the target before the transport and refuse contradictions:
- a positional target together with --server-url is an error naming both
- --transport stdio with a URL is an error
- an unrecognized --transport is an error; /mcp and /sse path sniffing runs
  only when --transport is absent

The CLI README's first remote example no longer claims an SSE default and
now runs as written.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
@cliffhall cliffhall added the v2 Issues and PRs for v2 label Oct 12, 2026
@cliffhall
cliffhall requested a balanced review from Copilot October 12, 2026 19:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the linked issue, preserves explicit transport overrides, and includes focused regression coverage.

0 open findings

What changed in this PR

Fixes conflicting CLI target and transport options by rejecting ambiguous combinations.

Changes:

  • Validates positional targets, URLs, and transports before path inference.
  • Adds regression tests for conflict and override cases.
  • Corrects remote-server CLI documentation.
File Description
core/​mcp/​node/​config.ts Rejects contradictory target and transport options.
clients/​web/​src/​test/​core/​mcp/​node/​config.test.ts Adds regression coverage for validation behavior.
clients/​cli/​README.md Corrects remote transport guidance and example.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot review loop closed: round 1 was clean (0 inline comments, 0 findings, no suppressed comments), so no further round was requested.

@cliffhall
cliffhall merged commit cc2ee50 into v2/main Oct 12, 2026
7 checks passed
@cliffhall
cliffhall deleted the v2/fix/2611-cli-target-transport-conflicts branch October 12, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: a URL wins over a positional command and over --transport stdio, both silently

2 participants