claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] `claude mcp add` command fails when options are placed before required arguments

Open roychri opened this issue 6 months ago • 3 comments

Environment

  • Platform (select one):
    • [x] Anthropic API
    • [ ] AWS Bedrock
    • [ ] Google Vertex AI
    • [ ] Other:
  • Claude CLI version: 1.0.30 (Claude Code)
  • Operating System: Ubuntu 24.04.2 LTS (on WSL2)
  • Terminal: Windows Terminal

Bug Description

The claude mcp add command fails when command-line header options are placed after the transport option argument, even though option order should not matter according to standard CLI conventions.

Steps to Reproduce

  1. Run: claude mcp add --transport sse -H "Authorization: Bearer XXX" postman https://mcp.postman.com/sse
  2. Observe the error

Expected Behavior

The command should work regardless of option order, as both commands have the same arguments and options.

Actual Behavior

Command fails with error: missing required argument 'name' when options are placed before the name argument.

Working command:

claude mcp add -H "Authorization: Bearer XXX" --transport sse postman https://mcp.postman.com/sse

Failing command:

claude mcp add --transport sse -H "Authorization: Bearer XXX" postman https://mcp.postman.com/sse

Additional Context

The help documentation for claude mcp add does not specify that option order matters, which makes this behavior unexpected. Standard CLI practice allows options to be placed anywhere in the command. Same problem with I use transport "http"

roychri avatar Jun 19 '25 22:06 roychri

I couldn't even get this command to work at all with options, I had to run it without the options and then edit the json file.

E.g.:

> claude mcp add -e SENTRY_ACCESS_TOKEN=sntrys_..... -e SENTRY_HOST=sentry.io sentry npx @sentry/mcp-server@latest
error: missing required argument 'name'

colinmollenhour avatar Aug 14 '25 04:08 colinmollenhour

I have just experienced this with Claude Code 2.0.47 and 2.0.50. The workaround mentioned (moving the --transport option to just before the name argument) does work for me.

odyssey4me avatar Nov 24 '25 14:11 odyssey4me

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 25 '25 10:12 github-actions[bot]