Why a Command Works in Your Terminal Yet Fails Inside MCP Configs

The single most confusing Model Context Protocol bug happens right after following a README: you type npx -y @modelcontextprotocol/server-filesystem in your terminal and it starts happily, yet placing "command": "npx" inside Claude Desktop, Cursor, or Antigravity shows *Server disconnected*.

Graphical apps on macOS, Windows, and Linux rarely load your full .zshrc, Homebrew, nvm, or Python virtualenv $PATH. Providing the complete binary location—found via which npx or where.exe python—resolves spawn failures instantly.

4-step diagnostic flow for MCP connection errors: absolute paths, stdio transport, log files, and package updates
Checklist for local MCP troubleshooting across Claude Desktop, Google Antigravity, and Cursor.
Builder Note

If you write a custom Python or Node MCP tool using stdio, never write print() or console.log() to standard output—JSON-RPC reads every line of stdout and immediately crashes on plain text logs.

Clean Absolute-Path .mcp.json / mcp_config.json Example

Compare a fragile relative config against an environment-safe production configuration using explicit binary paths and scoped workspace directories.

json
{
  "mcpServers": {
    "workspace-files": {
      "command": "/opt/homebrew/bin/npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/alex/projects/app"],
      "env": {
        "PATH": "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
      }
    }
  }
}

Where to Read Real Logs & Avoid Security Pitfalls

Guessing JSON typos blindly wastes hours. Check your client's raw protocol error log first, verify no trailing commas exist in JSON, and audit directory scopes before connecting community MCP packages.

  • macOS Claude logs: Inspect ls -lt ~/Library/Logs/Claude/mcp*.log directly to read the exact crash trace.
  • Windows logs: Check %APPDATA%\Claude\logs\ or Antigravity's diagnostic MCP Output pane cleanly.
  • Keep scopes tight: Grant filesystem MCP access strictly to one project folder instead of your entire Home or C:\Users directory.
Failure ModeWhat Logs ShowExact Fix
ENOENT npx / server closedSpawn failed in stripped GUI $PATHUse full which npx / uvx binary path
Handshake freeze / timeoutMalformed JSON line or SSE proxy bufferSwitch local server to stdio; send logs to stderr
JSON parse failed on startupTrailing comma or smart quotes in configValidate file with python -m json.tool config.json
Security / CVE risk warningOutdated mcp-server-git / server-memoryPin updated versions & restrict root folders cleanly

Quick Sanity Checklist Before Wiring New Community MCP Servers

Before pasting an unfamiliar MCP configuration block off GitHub or social feeds, verify two fast details: first, test launching the server directly from your own terminal with clean arguments so missing Node or Python dependencies fail loudly right in front of you; second, audit what directories and shell commands the server exposes.

Keeping reference servers like mcp-server-git, mcp-server-filesystem, and server-memory updated protects your workstation against stale path-traversal patches while keeping daily tool discovery instant inside Claude Desktop, Antigravity, and Cursor.