/ 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 (Model Context Protocol) servers in Claude Code feels like a rite of passage for anyone serious about building production AI agents — and the friction is real. I've been through this process building Buddy, an open-source Google Ads agent on Claude, and the gap between "it works on my machine" and "it works reliably in production" is wider than most tutorials let on. Whether you're automating marketing workflows, spinning up custom tools for client reporting, or just trying to connect Claude to your internal data, getting MCP right is foundational. Here's what actually matters.

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. Think of it as the USB-C standard for AI integrations — instead of writing custom glue code for every tool Claude needs to touch, MCP gives you a consistent way to expose capabilities as "servers" that Claude can discover and call.

In Claude Code specifically, MCP servers let you extend what Claude can do beyond its base capabilities. Instead of pasting data into a prompt or writing elaborate workarounds, you can give Claude a direct line to:

  • Your Google Ads or Meta Ads account data
  • Internal databases and CRMs
  • File systems and project directories
  • External APIs (analytics platforms, bid management tools, etc.)
  • Custom business logic and calculation engines

For marketers and advertisers, this is the difference between Claude being a smart writing assistant and Claude being an actual agent that can pull live campaign data, run analysis, and take actions — all in one loop.

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 no longer building a chatbot. You're building an agent. That distinction matters enormously for production use cases.

The Three Phases of MCP Setup (And Where People Get Stuck)

A common question in the r/ClaudeAI community is why MCP setup feels so unpredictable — sometimes it just clicks, and other times you're staring at errors with no clear path forward. After going through this multiple times, I've found the process breaks into three distinct phases, each with its own failure modes.

Phase 1: Server Definition & Schema Design

This is where most people underinvest. Your MCP server needs to expose a list of commands (tools) with enough descriptive metadata that Claude can figure out how to use them — even without explicit instructions in every prompt. As practitioners often discuss, a well-designed MCP has tool descriptions that are essentially self-documenting: the name, the parameters, and the description together tell Claude what to call, when to call it, and what to expect back.

Treat your tool descriptions like you're writing documentation for a junior developer who has no other context. Be explicit about:

  • What the tool does (one clear sentence)
  • What each parameter means and what format it expects
  • What the tool returns and in what shape
  • Any important constraints or side effects
Best Practice: Write your tool descriptions before you write the implementation code. If you can't explain the tool clearly in plain English in the schema, you probably don't have a clear enough design yet. Claude's ability to use your MCP reliably is almost entirely a function of how good your descriptions are.

Phase 2: Transport Configuration

MCP servers communicate with Claude Code through one of two transport mechanisms: stdio (standard input/output) or SSE (Server-Sent Events over HTTP). Getting this configuration right in your claude_desktop_config.json or equivalent config file is where a lot of the ritual-like debugging happens.

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.

Transport Type 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

Phase 3: Tool Discovery & Validation

Once your server is running and Claude Code is configured to connect to it, there's still the question of whether Claude actually discovers and correctly uses your tools. This phase is where the "ritual" feeling really kicks in — you restart, you check logs, you test a prompt, and you iterate.

The validation process should be systematic, not hopeful. Test each tool explicitly with a prompt designed to invoke only that tool, confirm the input/output is what you expect, then test combinations of tools 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. I've spent hours debugging what turned out to be a misconfigured parameter type in a tool schema — the server ran fine, but Claude was passing the wrong format and getting silent failures.

Step-by-Step: Setting Up Your First MCP Server in Claude Code

Here's the actual process, stripped of the magic and laid out in order:

  1. Install the MCP SDK — Use the official Anthropic MCP SDK for your language (TypeScript and Python are the most mature). Run npm install @modelcontextprotocol/sdk for Node.js projects.
  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 actual 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 the stdio transport. For remote, set up SSE with proper error handling.
  5. Add your server to Claude Code's config — Edit your claude_desktop_config.json to point to your server. The exact path and command matter — test the command manually in your terminal first.
  6. Restart Claude Code completely — Not just a refresh. Full restart. MCP servers are initialized at startup.
  7. Test with explicit tool-invocation prompts — Try something like "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 very first tool in every new MCP server. It takes 5 minutes to implement and immediately tells you whether the server connection, tool discovery, and basic invocation are all working before you add any real complexity.

Designing MCP Tools for Agentic Marketing Workflows

If you're building MCP servers to power marketing or advertising agents — which is where I spend most of my time — there are design principles that separate servers that actually work in production from ones that feel impressive in demos but fall apart under real load.

Tool Granularity: The Goldilocks Problem

Too coarse-grained and Claude can't be precise enough in what it does. Too fine-grained and you need 15 tool calls to accomplish something simple, burning tokens and latency. For Google Ads workflows specifically, I've found that tools organized around meaningful business actions — "get campaign performance," "update bid strategy," "pause underperforming ad groups" — work better than either giant do-everything tools or atomic CRUD operations.

A rough benchmark: if a single logical task in your workflow requires more than 4-5 tool calls, your tools are probably too granular. If a single tool has more than 6-7 parameters, it's probably trying to do too much.

Return Formats That Claude Can Reason Over

This is underappreciated. The data your tools return shapes how well Claude can reason about it and take next steps. JSON is fine, but structured JSON with clear field names beats raw arrays. Including summary statistics alongside detailed data gives Claude better signal for decision-making without forcing it to compute everything from raw numbers.

For ad campaign data, I'll typically return something like:

  • A summary object (total spend, aggregate ROAS, alert flags)
  • An array of entities (campaigns, ad groups) with their key metrics
  • A metadata object (date range, last updated timestamp, data freshness)

This pattern means Claude can immediately see the headline situation in the summary, drill into specifics in the entity array, and understand the data context from metadata — without needing to do a lot of manual aggregation.

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 to Claude determines whether the agent can recover gracefully or just stops. Return structured error objects, not thrown exceptions that bubble up as opaque failures. Include enough context in error messages that Claude can explain what happened and, ideally, suggest a next step.

Key Insight: In a production advertising agent, a tool that fails clearly is far more valuable than a tool 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.

Common Configuration Pitfalls (And How to Escape Them)

The r/ClaudeAI community has surfaced a lot of the same setup frustrations repeatedly — and most of them come down to a handful of recurring issues.

Path and Environment Issues

The most common source of "my server runs fine from terminal but not from Claude Code" is environment variable and PATH differences. Claude Code doesn't inherit your shell environment the way a terminal session does. Any environment variables your MCP server needs (API keys, database URLs, etc.) need to be explicitly provided in the config, not assumed from the system environment.

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 issues: string vs. number types, required vs. optional parameters, and nested object schemas that don't match the actual structure.

Version Mismatches

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

Scaling MCP: From One 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 — where I'm typically dealing with Google Ads accounts spending anywhere from $10K to $500K+ per month — the architecture gets more deliberate.

A few patterns that hold up at scale:

  • Separate servers by domain — One server for campaign data reads, one for bid management writes, one for reporting. This makes each server simpler, easier to test, and easier to swap out without affecting others.
  • Add caching at the server layer — Claude doesn't need to hit live APIs for every tool call during an agentic loop. Cache frequently-read data (campaign lists, account structure) at the MCP server level to reduce latency and API costs.
  • Implement rate limiting at the tool level — Especially for write operations. An enthusiastic agent can make a lot of API calls fast. Build in guards that prevent tool calls from exceeding your API quotas or performing destructive actions without confirmation.
  • Log every tool invocation — In production, you need an audit trail of what your agent did and why. Log tool inputs and outputs server-side, not just at the application level.

What to Do Next

If you're ready to move from reading about MCP to actually building with it, here's where to put your energy:

  1. Start with one tool, fully implemented. Don't design a 20-tool server before validating the pipeline. Build a single tool with great documentation, get it working end-to-end in Claude Code, then expand from there.
  2. Invest heavily in your tool descriptions. Before writing implementation code, write the description text for each tool as if you're 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 explicit logging from day one. Add server-side logging for every tool call — inputs, outputs, errors, and latency. You'll need this the moment something goes wrong in production (and it will).
  4. Test your config in isolation. Run the exact command from your MCP config entry directly in your terminal to confirm it starts correctly before ever involving Claude Code. This eliminates half the debugging variables.
  5. If you're in marketing or advertising, think about what data your agent needs to see and what actions it needs to take — then design tools around those verbs. "Get performance report," "identify underperforming keywords," "propose bid adjustments" are real tools. "Query database table" is a building block, not a tool for an agent with a job to do.

MCP setup has a real learning curve, and the "tech ritual" feeling is legitimate — there's friction in the configuration, the environment, and the schema design that you have to work through. But once it clicks, you have the infrastructure to build agents that actually do things, not just agents that talk about things. That's a meaningful capability shift, and it's worth the investment to get right.

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.