[BUG] mcp add incorrectly escapes command line arguments

Resolved 💬 2 comments Opened Mar 16, 2025 by raghavsethi Closed Mar 17, 2025

Environment

  • Platform (select one): Anthropic API
  • Claude CLI version: 0.2.45
  • Operating System: macOS 15.3.2
  • Terminal: iTerm2

Bug Description

Unable to provide command line arguments with spaces/parens

Steps to Reproduce

  1. claude mcp add
Name: fetch                                                                                                               │
│   Scope: global                                                                                                             │
│   Command: uvx                                                                                                              │
│   Arguments: mcp-server-fetch --user-agent "Test"
  1. claude
> /mcp
  ⎿  MCP Server Status

     • fetch: connected
  1. claude mcp add
Name: fetch                                                                                                               │
│   Scope: global                                                                                                             │
│   Command: uvx                                                                                                              │
│   Arguments: mcp-server-fetch --user-agent "Test Test"
  1. claude --mcp-debug
MCP server "fetch" Connection failed: MCP error -32000: Connection closed

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ > Try "how does src/App.tsx work?"                                                                                          │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  1 MCP server failed to connect (see /mcp for info)

Expected Behavior

Cmdline args with spaces to work

Actual Behavior

They are being incorrectly passed to mcp server

Additional Context

Can confirm that npx @modelcontextprotocol/inspector has the same issue, but that it can be fixed by proper escaping

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗