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.
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.
{
"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*.logdirectly 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:\Usersdirectory.
| Failure Mode | What Logs Show | Exact Fix |
|---|---|---|
ENOENT npx / server closed | Spawn failed in stripped GUI $PATH | Use full which npx / uvx binary path |
| Handshake freeze / timeout | Malformed JSON line or SSE proxy buffer | Switch local server to stdio; send logs to stderr |
| JSON parse failed on startup | Trailing comma or smart quotes in config | Validate file with python -m json.tool config.json |
| Security / CVE risk warning | Outdated mcp-server-git / server-memory | Pin 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.