All posts

What I Learned About MCP Configuration by Breaking It Repeatedly

Updated November 26, 2026

What I Learned About MCP Configuration by Breaking It Repeatedly

Five translucent layers stacked like strata with glowing lines running down through them

The first MCP server I tried to use was someone else's. The second was one I built myself. Both broke in ways the documentation didn't prepare me for, and the debugging process taught me more about how Claude Code discovers and connects to MCP servers than any guide I've found online.

This isn't a theoretical overview. I run five MCP servers in production across two physical servers, including a custom memory system (MemBrane) that I built from scratch and an OPNsense firewall integration with constitutional safety constraints. The configuration knowledge here comes from months of getting things wrong in specific, instructive ways.

The MCP Server That Didn't Work

In September 2025, I adopted Graphiti as my AI memory backend. It had exactly what I needed: a temporal knowledge graph with entity extraction, relationship tracking, and (critically) an MCP server that would let me wire it directly into Claude Code. Four days in, I had 9,626 nodes in the graph and was feeling productive.

Then the MCP server stopped connecting. No error surfaced to Claude Code. No warning appeared. It simply failed silently, and Claude Code carried on as if it didn't exist.

The problem turned out to be a compatibility issue between Graphiti's hardcoded OpenAI model defaults and my local inference setup. Graphiti's server expected specific OpenAI models for its LLM client initialization, and those models didn't exist in my environment. I spent hours checking my configuration files, restarting Claude Code, and wondering what I'd misconfigured before I finally read the server's source code and understood the mismatch. The server wasn't broken — it was built for a different deployment model than mine.

That experience taught me something that shapes everything in this post: MCP configuration problems are almost never about the configuration. They're about understanding the connection lifecycle between Claude Code and the servers it talks to, and making sure your environment matches what the server expects. The JSON is the easy part.

Five Config Files, One Mental Model

Claude Code looks for MCP server definitions in five locations. This sounds like a design flaw, but once you understand the scoping logic, it makes sense. The hierarchy, from highest to lowest priority:

  1. <project>/.mcp.json in your project root (project-specific, highest priority)
  2. ~/.claude.json -> projects[path].mcpServers (project overrides in the global config)
  3. ~/.claude/.mcp.json (default workspace config)
  4. ~/.claude.json -> mcpServers (true global config)
  5. ~/.config/claude-code/mcp_config.json (legacy, effectively deprecated)

The confusion happens because most people (myself included, initially) put a server definition in one location and expect it to appear everywhere. It won't. A server defined in a project's .mcp.json only exists when you're working in that project directory. A server in ~/.claude.json's top-level mcpServers object is genuinely global.

Two framed panels holding different clusters of glowing nodes, showing two separate scopes

The practical rule I follow: if I need a server across multiple projects, it goes in ~/.claude.json under the top-level mcpServers key. If it's specific to one codebase, it goes in that project's .mcp.json. I almost never use the other three locations.

Here's what my global config actually looks like for the servers I use daily:

{
  "mcpServers": {
    "membrane": {
      "type": "sse",
      "url": "http://your-server-ip/sse"
    },
    "gitlab": {
      "command": "bunx",
      "args": ["@modelcontextprotocol/server-gitlab"],
      "env": {
        "GITLAB_PERSONAL_TOKEN": "your-token-here",
        "GITLAB_API_URL": "https://your-gitlab-instance/api/v4"
      }
    }
  }
}

Two servers, two completely different connection types. That distinction matters more than most guides acknowledge.

stdio vs SSE: The Transport Decision That Shapes Everything

MCP supports three transport types: stdio, SSE (Server-Sent Events), and HTTP. In practice, the choice between stdio and SSE is the decision that determines your server's operational characteristics, and getting it wrong costs you hours of debugging time you'll never get back.

stdio is the default for most community MCP servers. Claude Code spawns the server as a child process and communicates over stdin/stdout. The server starts when Claude Code starts, dies when Claude Code exits, and runs on the same machine. Configuration looks like this:

{
  "command": "python",
  "args": ["-m", "my_mcp_server"],
  "cwd": "/path/to/your/server",
  "env": {
    "API_KEY": "secret"
  }
}

SSE is for servers that run independently as HTTP services. Claude Code connects to them over the network. The server has its own lifecycle, its own process, its own machine if you want. This is what I use for MemBrane, which runs as a Docker Compose stack on a dedicated server and needs to survive Claude Code restarts.

{
  "type": "sse",
  "url": "http://your-server-ip/sse"
}

The tradeoff is straightforward. stdio servers are simpler to configure and require no separate deployment. SSE servers are more operationally complex but survive Claude Code restarts, can serve multiple clients, and can run on dedicated hardware.

I learned the SSE tradeoff the hard way. MemBrane runs on Python's asyncio with a Neo4j graph database, a Qdrant vector store, and a Redis cache. When I initially ran it as a stdio server, every time I restarted Claude Code, the server had to reinitialize all those connections. Cold start took 8-12 seconds. Worse, killing Claude Code while MemBrane was mid-write to Neo4j occasionally left the graph in an inconsistent state. Moving to SSE and running MemBrane as a persistent service solved both problems.

The third transport, HTTP, is for simple request/response patterns without streaming. I haven't needed it in practice.

Building Your Own: What the Tutorials Leave Out

Most MCP server tutorials show you the happy path: define a tool, register it, run the server. What they don't cover is the operational reality of running an MCP server that Claude Code depends on for every session.

An abstract instrument panel of round indicator lights, a wave line and rising bars

Token cost is invisible until it's catastrophic. When I first deployed MemBrane's MCP server, tool responses were bloated with unnecessary data like raw embedding arrays. Profiling revealed the responses were consuming far more tokens than necessary, which we optimized separately.

Async initialization bugs can cause silent failures that look like configuration problems. I had a cache warming system that silently did nothing for weeks because of an event loop mismatch during startup. No errors, no exceptions -- just a feature that wasn't working. If your MCP server uses async Python, be especially careful about how startup tasks interact with the framework's own event loop.

SSE connection health requires active monitoring. Claude Code doesn't always tell you when an SSE connection drops. I've had sessions where MemBrane tools appeared in the tool list but silently failed on every call because the server had restarted and the SSE connection was stale. The only reliable indicator was checking Claude Code's MCP server status (the /mcp command) before starting substantive work. I eventually added a health check endpoint to MemBrane's SSE server and built a cron job that verifies connectivity periodically.

The OPNsense MCP: When Security Is the Feature

Not every MCP server is a database wrapper. The OPNsense MCP server I built gives Claude Code programmatic access to my firewall configuration: reading rules, checking interface status, querying DHCP leases. The interesting part isn't the API integration. It's the constitutional safety layer.

Giving an AI unrestricted write access to a production firewall is, to put it mildly, inadvisable. The OPNsense MCP server implements what I call constitutional constraints: a set of invariants that the server enforces regardless of what the AI requests. It can read any configuration. It can propose changes. But certain operations (disabling WAN interfaces, modifying core NAT rules, changing admin credentials) are structurally impossible through the MCP interface. The constraints live in the server code, not in the AI's system prompt, because system prompts are suggestions and code is law.

This pattern (broad read access, constrained write access, hard-coded safety invariants) has become my template for any MCP server that touches production infrastructure.

Configuration Patterns That Actually Work

After months of iteration, these are the patterns I've settled on.

Python servers need absolute paths. Relative paths in MCP config are resolved against Claude Code's working directory, not the server's directory. This means python -m my_server works when you run it from the project directory but fails when Claude Code spawns it from somewhere else. Always use the full path to the virtualenv Python binary:

{
  "command": "/path/to/your/server/.venv/bin/python",
  "args": ["-m", "src.mcp_server"],
  "cwd": "/path/to/your/server"
}

Remote servers via SSH work but need care. You can run stdio MCP servers on remote machines by wrapping them in SSH:

{
  "command": "ssh",
  "args": [
    "your-remote-host",
    "cd /path/to/your/server && .venv/bin/python -m src.mcp_server"
  ]
}

The catch: SSH needs to connect without interactive prompts. That means key-based auth, StrictHostKeyChecking handled in your SSH config, and no passphrase on the key (or an ssh-agent running). If SSH prompts for anything, the MCP server will hang silently during initialization.

Docker servers need -i for stdio. If you're running an MCP server in a container, the -i flag (keep stdin open) is mandatory for stdio transport. Without it, the container's stdin closes immediately and the server can't receive messages:

{
  "command": "docker",
  "args": ["run", "--rm", "-i", "my-mcp-server:latest"]
}

Environment variables are your credential layer. The env field in MCP config is the cleanest way to pass secrets. These values are injected into the server's environment at spawn time and never appear in Claude Code's context window:

{
  "command": "bunx",
  "args": ["@modelcontextprotocol/server-gitlab"],
  "env": {
    "GITLAB_PERSONAL_TOKEN": "your-token-here",
    "GITLAB_API_URL": "https://your-gitlab-instance/api/v4"
  }
}

Never hardcode credentials in the server code itself. Never pass them as command-line arguments (they'll show up in ps output).

Debugging: The Systematic Approach

A branching decision tree with one highlighted teal path leading to a final glowing node

When an MCP server doesn't appear in Claude Code or fails silently, here's the sequence I follow. It's ordered by likelihood of being the actual problem.

1. Verify the server runs standalone. Before touching Claude Code config, run the server's command directly in your terminal. If it crashes, throws import errors, or needs dependencies you haven't installed, no amount of configuration will help. For stdio servers, you should see the server waiting for input on stdin. For SSE servers, you should be able to curl the URL.

2. Check configuration scope. Are you in the right project directory? Run pwd and verify that your config file (.mcp.json or ~/.claude.json) actually covers this location. I've lost 20 minutes more than once because I was in a symlinked directory and the project path didn't match the one in my config.

3. Restart Claude Code. Configuration changes don't hot-reload. A full restart is required. This sounds obvious, but when you're iterating quickly on config changes, it's easy to forget that the session is still running the old configuration.

4. Check /mcp status. Inside Claude Code, the /mcp command shows connected servers and their status. If your server appears but shows as disconnected, the problem is runtime (the server crashed, the SSE endpoint is unreachable, the network path is blocked). If it doesn't appear at all, the problem is configuration.

5. Read the server logs. For stdio servers, Claude Code captures stderr output. For SSE servers, check whatever logging the server provides. The Graphiti compatibility issue I mentioned earlier would have been caught in minutes if I'd looked at the server's stderr output instead of assuming my config was wrong.

6. Test with a minimal config. If nothing else works, create a bare-minimum .mcp.json with just the failing server and nothing else. This eliminates interaction effects between multiple server definitions and gives you a clean baseline.

The Operational Reality

A central hub connected by five spokes to five distinct geometric shapes

Running MCP servers in production is different from running them in a tutorial. The servers need monitoring, the connections need health checks, and the configuration needs to be version-controlled somewhere that isn't the project repository (because ~/.claude.json contains credentials you don't want in git).

I keep my MCP configurations in a private dotfiles repository with encrypted credential sections. The actual ~/.claude.json is symlinked from this repo. When I set up a new development machine, the MCP server configuration comes along with everything else, and I only need to update the credential values.

The deeper lesson from all this configuration work is that MCP servers are infrastructure, not features. They need the same operational discipline as any other service you depend on: health checks, monitoring, documented configuration, and a plan for what happens when they go down. Claude Code will work fine without MCP servers. But once you've experienced having your memory system, your git platform, and your infrastructure tooling available as native tools inside your AI workflow, going back to copy-pasting between terminals feels like returning to a flip phone.

The configuration hierarchy is five files deep and initially confusing. The transport choice between stdio and SSE has real operational consequences. The debugging process requires systematic elimination, not guesswork. None of this is documented well enough in official sources. But once you've mapped the territory, MCP servers become the connective tissue that turns Claude Code from a sophisticated chatbot into an actual infrastructure component.

That's worth the configuration headaches.

About the author

Carlos Mendez

Carlos Mendez

IT support and systems, Maui, Hawaii

I come from IT support and systems work. I build and run my own infrastructure and the production websites for West Maui Tech, my business, and I build AI tooling on top of that stack. I write here about what I run, what broke, and how I fixed it.

Enjoyed this article?

Subscribe to get notified about new posts on software engineering, AI development, and infrastructure.

No spam, unsubscribe anytime.