/ Blog
Home Blog Contact Buddy Ads Builder Audit Engine

Setting Up MCP Servers in Claude Code: A Tech Ritual for ...

Claude & Anthropic

Setting up MCP servers in Claude Code requires four things done right: a well-documented tool schema, correct transport configuration (stdio for local, SSE for remote), explicit environment variables in your config file, and a full Claude Code restart after any change. Most setup failures trace back to schema description quality or environment variable gaps — not the server code itself.

Key takeaways

  • MCP (Model Context Protocol) is Anthropic's open standard for connecting Claude to external tools and data sources through a consistent, discoverable interface. [1]
  • Tool description quality is the single biggest lever on reliability — Claude uses your schema text to decide what to call and when, so vague descriptions produce unreliable behavior.
  • Claude Code does not inherit your shell environment, so API keys and paths must be explicitly declared in your MCP config, not assumed from .env files or shell exports.
  • Server startup succeeding and tool invocation working correctly are two separate things — always validate each tool with a targeted test prompt after confirming the server starts.
  • For production advertising agents, design tools around business verbs ("get campaign performance," "pause underperforming ad groups") rather than low-level database operations.
Key terms
MCP (Model Context Protocol)
Anthropic's open standard for connecting Claude to external tools and data sources through a consistent, discoverable server interface.
stdio transport
A communication method that runs the MCP server as a local process using standard input/output, recommended for local Claude Code workflows.
SSE transport
Server-Sent Events over HTTP, used when an MCP server needs to run remotely or serve multiple clients simultaneously.
Tool schema
The JSON Schema definition that describes a tool's name, parameters, and expected outputs so Claude knows when and how to call it.
Agentic loop
A sequence in which Claude calls tools, receives results, reasons over them, and calls further tools to complete a multi-step task autonomously.
---

What is MCP and why does it matter for Claude Code?

Model Context Protocol is Anthropic's open standard that lets Claude connect to external tools, data sources, and services through a defined interface. [1] Think of it as the USB-C standard for AI integrations: instead of writing custom glue code for every system Claude needs to touch, MCP gives you a consistent way to expose capabilities as "servers" that Claude can discover and call at runtime. [2]

In Claude Code specifically, MCP servers extend what Claude can do beyond its base capabilities. Instead of pasting exported data into a prompt, you give Claude a direct, live connection to:

Key Insight: MCP doesn't just add tools to Claude — it changes the architecture of what's possible. When Claude can read real data and take real actions through standardized server connections, you're building an agent, not a chatbot. That distinction matters enormously for production use cases like managing live advertising budgets.

This question came up in a thread on r/ClaudeAI where practitioners described the setup process as a "tech ritual" — and the friction is real. The three phases below cover where that friction actually lives.

---

What are the three phases of MCP setup where people get stuck?

MCP setup breaks into three distinct phases, each with its own failure modes: schema design, transport configuration, and tool discovery validation.

Phase 1: Server definition & schema design

This is where most people underinvest. Your MCP server exposes a list of tools with descriptive metadata that Claude uses to decide what to call, when to call it, and what to pass. A well-designed schema is essentially self-documenting.

For each tool, be explicit about:

Best Practice: Write your tool descriptions before writing any implementation code. If you can't explain the tool clearly in plain English in the schema, your design isn't clear enough yet. Claude's reliability is almost entirely a function of description quality — treat these like documentation for a smart junior developer with no other context.

Phase 2: Transport configuration

MCP servers communicate with Claude Code through one of two transport mechanisms. Getting this right in your claude_desktop_config.json is where a lot of the ritual-like debugging happens.

Transport Best for Key consideration Production ready?
stdio Local agents, single-user tools Process must be running locally Yes, for local use
SSE (HTTP) Remote servers, multi-client setups Needs auth & connection handling Yes, for distributed use

For local development and most agentic workflows, stdio is simpler and more reliable. For production deployments where the MCP server needs to run remotely or serve multiple clients, SSE is the right choice — but adds complexity around authentication and connection management.

Phase 3: Tool discovery & validation

Once your server is running and Claude Code is configured, the question is whether Claude actually discovers and correctly uses your tools. This phase is where the "ritual" feeling really kicks in. Validation should be systematic, not hopeful: test each tool individually with a prompt designed to invoke only that tool, confirm input/output, then test combinations to see how Claude chains them in real agentic loops.

Common Mistake: Assuming that because your MCP server starts without errors, it's working correctly. Server startup and actual tool invocation are two completely separate things to validate. A misconfigured parameter type in a tool schema will let the server run fine while Claude passes the wrong format and gets silent failures.
---

How do you set up an MCP server in Claude Code step by step?

Here is the process in order, stripped of ambiguity:

  1. Install the MCP SDK. Use the official Anthropic MCP SDK for your language. For Node.js: npm install @modelcontextprotocol/sdk. TypeScript and Python are the most mature options.
  2. Define your server and tools. Create your server instance and register tools with full schema descriptions. This is your most important work.
  3. Implement tool handlers. Write the logic that runs when Claude calls each tool. Keep handlers focused and return clean, structured data.
  4. Choose and configure your transport. For local Claude Code use, wire up stdio. For remote, set up SSE with proper error handling and authentication.
  5. Add your server to Claude Code's config. Edit claude_desktop_config.json to point to your server. Test the exact command from the config manually in your terminal before involving Claude Code.
  6. Restart Claude Code completely. Not a refresh — a full restart. MCP servers are initialized at startup. [2]
  7. Test with explicit tool-invocation prompts. Try "Use the [tool-name] tool to…" to force a specific tool call and confirm end-to-end flow.
  8. Check logs actively. Claude Code surfaces MCP errors in its developer tools. Use them. Don't guess.
Best Practice: Build a simple "ping" or "echo" tool as the first tool in every new MCP server. It takes five minutes to implement and immediately confirms that server connection, tool discovery, and basic invocation all work before you add any real complexity.

If you're curious about which MCP servers practitioners find most useful, that's a good reference for scoping what to build first.

---

What are the most common MCP configuration pitfalls and how do you fix them?

The majority of MCP setup failures trace back to three recurring issues.

Path and environment variable problems

The most common source of "it works in terminal but not in Claude Code" is environment variable and PATH differences. Claude Code does not inherit your shell environment the way a terminal session does.

Common Mistake: Relying on .env files or shell exports that work in your terminal but aren't available when Claude Code spawns your server process. Always explicitly configure environment variables in your MCP server config entry and use absolute paths for executables rather than relying on PATH resolution.

Schema validation failures

If Claude is calling your tool but getting errors, check your parameter schemas first. The MCP SDK enforces JSON Schema validation, and mismatches between what Claude passes and what your schema declares will cause quiet failures. Common culprits: string vs. number types, required vs. optional parameters, and nested object schemas that don't match the actual data structure.

SDK version mismatches

MCP is still evolving. The SDK version your server uses needs to be compatible with the MCP client version Claude Code implements. When in doubt, check the current Anthropic documentation for the recommended SDK version — don't assume the latest npm release is always the right choice. [2]

---

How do you design MCP tools for agentic marketing or advertising workflows?

Tools organized around meaningful business actions work better in production than either giant do-everything tools or atomic CRUD operations. The right granularity sits in the middle.

The tool granularity problem

Too coarse-grained and Claude can't be precise enough. Too fine-grained and you need many tool calls to accomplish something simple, burning tokens and latency. In accounts I manage — including Buddy, the open-source Google Ads agent built on Claude — tools organized around business verbs ("get campaign performance," "update bid strategy," "pause underperforming ad groups") consistently outperform both extremes.

As a rough benchmark from practitioner experience: if a single logical task requires more than four or five tool calls, your tools are probably too granular. If a single tool has more than six or seven parameters, it's probably trying to do too much.

Return formats Claude can reason over

The data your tools return shapes how well Claude can reason and take next steps. For ad campaign data, a useful pattern is:

This structure lets Claude make decisions without needing to aggregate raw numbers itself, which reduces reasoning errors in long agentic loops.

Error handling as a first-class concern

Agentic loops fail at the edges. When your MCP tool hits an API rate limit, gets a malformed response, or encounters a permission error, how it communicates that failure determines whether the agent recovers or stops.

Key Insight: In a production advertising agent, a tool that fails clearly is far more valuable than one that fails silently. Claude can work around a clear error — retry with different parameters, notify the user, fall back to an alternative approach. It cannot work around an error it doesn't know happened.

Return structured error objects with enough context that Claude can explain what happened and suggest a next step. Avoid thrown exceptions that bubble up as opaque failures.

If you're setting up Buddy or a similar agent, the getting started documentation walks through these patterns in a concrete advertising context.

---

How do you scale MCP from a single server to a production architecture?

For simple workflows, one MCP server with a handful of tools is enough. For production agents handling real advertising budgets, the architecture gets more deliberate.

Patterns that hold up at scale:

For a deeper look at how MCP connects to version control and external services in production pipelines, the MCP and GitHub reference covers that integration pattern.

---

What to do next

  1. Start with one tool, fully implemented. Don't design a twenty-tool server before validating the pipeline. Get a single tool working end-to-end in Claude Code, then expand.
  2. Write tool descriptions first. Before any implementation code, write the description text for each tool as if explaining it to a smart non-technical colleague. If it's not clear to a human, it won't be reliably clear to Claude.
  3. Set up server-side logging from day one. Log every tool call — inputs, outputs, errors, and latency. You'll need this the moment something breaks in production.
  4. Test your config command in isolation. Run the exact command from your MCP config entry directly in your terminal to confirm it starts correctly before involving Claude Code. This eliminates half the debugging variables.
  5. Design tools around business verbs. If you're in marketing or advertising, identify what data your agent needs to see and what actions it needs to take — then design tools around those verbs, not around database operations.

For a broader look at structuring your Claude Code projects, the complete guide to Claude Code and CLAUDE.md covers project-level configuration that works alongside MCP. And if you want to explore what the community considers the most impactful integrations, this roundup of useful MCPs is worth reading before you decide what to build.

---

Frequently asked questions

Do I need to restart Claude Code every time I change my MCP server?

Yes — a full restart, not just a refresh. Claude Code initializes MCP server connections at startup, so changes to your server code, config file, or tool schemas won't take effect until you fully quit and reopen the application. This is one of the most common reasons a fix appears to do nothing: the old server process is still running.

Can Claude Code use multiple MCP servers at the same time?

Yes. You can register multiple servers in your claude_desktop_config.json, and Claude Code will connect to all of them at startup. Claude can then call tools from any registered server within the same conversation. For production agents, separating concerns across multiple servers — reads, writes, reporting — is a recommended architectural pattern.

What's the difference between stdio and SSE transport, and which should I use?

stdio (standard input/output) runs the MCP server as a local process and is simpler, more reliable, and the right default for local Claude Code workflows. SSE (Server-Sent Events over HTTP) is for remote servers that need to serve multiple clients or run independently of the user's machine. Choose SSE only when you need distributed deployment; the added authentication and connection management complexity isn't worth it for local use.

Why is Claude calling my tool incorrectly even though the server starts fine?

Almost always, the cause is a mismatch between your tool's JSON Schema definition and what Claude is actually passing. Check parameter types (string vs. number), required vs. optional field declarations, and nested object shapes. The MCP SDK enforces schema validation, so mismatches produce silent failures at the invocation level even when the server process is healthy.

Can I use MCP servers with Claude on mobile?

MCP server support has been extending beyond desktop. Claude on mobile now supports MCP servers in certain configurations, though the setup process and supported transport options may differ from the Claude Code desktop environment. Check the current Anthropic documentation for the latest mobile MCP support details.

How many tools should a single MCP server have?

There's no hard limit, but from practitioner experience, servers with fewer than fifteen well-described tools are easier to maintain and debug than large monolithic servers. The more useful constraint is granularity: if a logical task requires more than four or five tool calls, your tools may be too fine-grained. If a single tool takes more than six or seven parameters, it's likely doing too much.

References

  1. Model Context Protocol. “What is the Model Context Protocol (MCP)?.” Accessed Nov 1, 2026.
  2. Anthropic. “Claude Code overview.” Accessed Nov 1, 2026.
  3. Original community discussion: r/ClaudeAI thread on Reddit.

Related Reading

AI Disclosure: This article was generated with AI assistance based on a community discussion on Reddit r/ClaudeAI. Expert analysis and practitioner perspective by John Williams, Founder, AHMEEGO · Google Ads Practitioner with $350M+ in managed Google Ads spend. AI was used to draft and structure the content; all strategic recommendations reflect real campaign experience.