Agents IA & Automation

Model Context Protocol (MCP) with Claude: complete implementation guide

9 min read

Learn how to implement Anthropic's Model Context Protocol (MCP) with Claude to build powerful, autonomous AI agents. Practical guide with examples.

Developer implementing TypeScript API integration on dark screen with multiple windows

The Model Context Protocol (MCP) is Anthropic's new standard for connecting Claude agents to your tools, databases, and business services. Officially launched in June 2026 and integrated into Claude Sonnet 5, MCP allows your AI agents to access your data directly without relying on dummy integrations or API hacks.

If you're building AI agents in 2026, MCP is no longer optional, it's the foundation. Here's how to implement it.

What is the model context protocol really?

MCP isn't a new API for calling Claude (you already have that). It's an interoperability protocol that defines how a client application (Claude, Cursor, Grok Build, or your own AI) connects to MCP servers that expose tools, resources, and data.

Analogy: MCP is to Claude what plugins are to a browser. Except it's standardized, bidirectional, and built for AI.

Key components:

  • MCP Client: Claude, your AI agent, or your application
  • MCP Server: endpoint that exposes tools and resources
  • Resources: data that the server makes available (database, files, API)
  • Tools: functions that the agent can call to accomplish an action
  • Prompts: reusable templates to guide Claude

This is exactly what Simple Booking did in June 2026, they built an MCP server exposing their CRS hotel reservation system, and now Claude can directly check/modify hotel reservations.

Architecture: how it fits together

Before MCP, the architecture was chaotic:

Claude (via API)
    ↓ [manual prompt engineering]
    ↓ [tool_use call]
Application -> [You parse the response] -> Custom integration
    ↓
Database

With MCP:

Claude (via MCP client)
    ↓
MCP Client Protocol (standardized JSON-RPC)
    ↓
Your MCP Server
    ↓ [automatic reconnection]
    ↓
Your tools (functions), resources (data), prompts

The Claude agent can now:

  • Query your resources directly: "How many pending orders are there?" -> MCP request -> your database
  • Call your tools atomically: "Create an invoice" -> MCP tool call -> your business logic
  • Reuse optimized prompts: use_mcp_resource("billing_context") -> consistent template across all agents

How to implement a minimal MCP server

The MCP protocol uses JSON-RPC 2.0 over stdio or HTTP. Here's a minimal server in Python that exposes a PostgreSQL database:

from MCP.server import Server
from MCP.types import Tool, Resource, TextContent
import asyncio
import psycopg2

app = Server("my-database-server")

# Declare a resource: the list of customers
@app.resource("db://customers")
async def get_customers():
    conn = psycopg2.connect("dbname=mydb user=postgres")
    cur = conn.cursor()
    cur.execute("SELECT id, name, email FROM customers LIMIT 100")
    rows = cur.fetchall()
    conn.close()
    
    return TextContent(
        type="text/plain",
        text="\n".join([f"ID: {r[0]}, Name: {r[1]}, Email: {r[2]}" for r in rows])
    )

# Declare a tool: create a new order
@app.tool("create_order")
async def create_order(customer_id: int, items: list, total: float):
    conn = psycopg2.connect("dbname=mydb user=postgres")
    cur = conn.cursor()
    cur.execute(
        "INSERT INTO orders (customer_id, items, total, status) VALUES (%s, %s, %s, %s)",
        (customer_id, str(items), total, "pending")
    )
    conn.commit()
    order_id = cur.lastrowid
    conn.close()
    
    return f"Order {order_id} created successfully"

if __name__ == "__main__":
    asyncio.run(app.run())

That's 30 lines. No manual parsing, no complicated prompt engineering. Claude now knows it can:

  1. Call get_customers to see customers
  2. Call create_order(customer_id, items, total) to create an order

But wait, there's a catch. You're exposing your database directly. What if Claude hallucinates an invalid customer_id? You need to add validation:

@app.tool("create_order")
async def create_order(customer_id: int, items: list, total: float):
    # Validation: does the customer actually exist?
    conn = psycopg2.connect("dbname=mydb user=postgres")
    cur = conn.cursor()
    cur.execute("SELECT id FROM customers WHERE id = %s", (customer_id,))
    if not cur.fetchone():
        return f"Error: customer {customer_id} does not exist"
    
    # Continue with order creation...

Honest limitation: the more functionality you expose via MCP, the more you depend on Claude making good decisions. A poorly guided agent can still cause damage. You need:

  • Rate limiting on dangerous tools
  • Logging and audit trails
  • Clear system prompts about business constraints
  • Chaos tests to see what happens if Claude calls a tool with weird inputs

Connecting claude sonnet 5 to your MCP server

Once your MCP server is in place, you call it via the Claude SDK. Claude Sonnet 5 (launched June 30, 2026) has native MCP support built in.

from anthropic import Anthropic

client = Anthropic()

# Configure MCP server for this session
mcp_config = {
    "servers": {
        "my_database": {
            "command": "python",
            "args": ["./mcp_server.py"],
            "env": {"DATABASE_URL": "postgresql://..."}
        }
    }
}

response = client.messages.create(
    model="claude-sonnet-5",  # New, released June 30, 2026
    max_tokens=2048,
    tools=[
        # MCP tools are auto-discovered from servers
    ],
    messages=[
        {
            "role": "user",
            "content": "Create an order for customer #42: 2x product A, 1x product B. Total: €150"
        }
    ]
)

# Claude will now:
# 1. Parse the user message
# 2. Check that it has access to the "create_order" tool via MCP
# 3. Call create_order(customer_id=42, items=[...], total=150)
# 4. Receive the response from the MCP server
# 5. Continue the conversation

Claude Sonnet 5 also adds improved agentic loops, it can call multiple tools in sequence without returning to your code each time. Useful for: "Fetch pending orders, create invoices for each, then send an email."

Real-world production use cases

1. Hotel integrations (Simple Booking, June 2026)

Simple Booking exposes its CRS hotel reservation system via MCP. Travel agencies use Claude to:

  • "Which suites are available on August 15th at the Lyon hotel?" -> Claude queries MCP -> real-time response
  • "Book suite 42 for the Duponts from August 15-20" -> Claude calls the reservation tool

Before MCP: custom webhooks. Now: a standardized MCP server, and any MCP-compatible tool can use it without reimplementing the integration.

2. Media buying automation (Nexxen, June 2026)

Nexxen exposes its campaign parameters, budgets, and audiences via MCP. Agencies build Claude agents that:

  • Analyze campaign performance ("Our CPM is dropping, why?")
  • Adjust budgets automatically ("Allocate 20% of budget to premium audience")
  • Create new campaigns from text briefs

Before: Zapier integration + custom scripts. Now: one MCP server, done.

3. Your use case: e-commerce content management

You have a Shopify store or custom product system. Build an MCP server that exposes:

  • Resource: inventory/sku-123 -> stock count
  • Resource: products/all -> complete catalog
  • Tool: update_product_description(sku, new_desc) -> updates your database
  • Tool: create_bundle(products, discount) -> creates a bundle
  • Prompt: catalog_refresh_context -> instructions for Claude when asked to overhaul 100 product descriptions

Real example: you tell Claude "Review all product descriptions and fix typos, improve SEO, add dimensions in cm". Claude:

  1. Queries products/all via MCP
  2. Analyzes 200 descriptions
  3. For each product, calls update_product_description(sku, new_desc)
  4. Delivers a report

Human time: 10 minutes of supervision. Before: a full day for your team.

Permissions and security management

Major risk: if Claude has access to all your tools, it could call a dangerous function. Add controls:

1. Scope tools by use case

# Instead of exposing "delete_order" globally
@app.tool("delete_order", scopes=["admin_only"])
async def delete_order(order_id: int):
    # Requires special permission
    pass

2. Rate limiting

from functools import wraps

def rate_limit(max_calls=10, period=60):
    def decorator(func):
        calls = []
        async def wrapper(*args, **kwargs):
            now = time.time()
            calls = [c for c in calls if c > now - period]
            if len(calls) >= max_calls:
                raise Exception("Rate limit exceeded")
            calls.append(now)
            return await func(*args, **kwargs)
        return wrapper
    return decorator

@app.tool("create_order")
@rate_limit(max_calls=50, period=3600)
async def create_order(...):\n    pass

3. Exhaustive logging

import logging

logger = logging.getLogger("mcp_audit")

@app.tool("delete_order")
async def delete_order(order_id: int):
    logger.warning(f"Claude called delete_order({order_id}) - action requires approval")
    # Optional: request human confirmation before deleting
    return "Deletion queued for human approval"

Build a secure, production-ready MCP server

Deploying an MCP server in production

Two approaches:

1. Stdio (for rapid development)

Your MCP server runs as a child process of the Claude client. Simple, but limited for scalability.

{
  "servers": {
    "my_server": {
      "command": "python",
      "args": ["./mcp_server.py"]
    }
  }
}

2. HTTP with authentication (for production)

{
  "servers": {
    "my_server": {
      "url": "HTTPS://MCP.mycompany.com",
      "auth": {
        "type": "bearer",
        "token": "sk_live_..."
      }
    }
  }
}

Your MCP server listens on a secure HTTPS endpoint, with SSL certificates and rate limiting at the gateway.

Recommended deployment:

  • MCP Server: Docker on ECS/K8s, behind a load balancer
  • Database: PostgreSQL or MongoDB, strictly in private VPC
  • Monitoring: CloudWatch, structured JSON logs, alerts on errors
  • Versioning: version your MCP resources and tools (e.g., /API/v1/resources)

Frequently asked questions

What's the difference between MCP and claude's classic tools calling?

Tools calling (function_calling in the Claude SDK) already lets Claude call functions. MCP is an abstraction layer on top, which standardizes how tools are discovered, called, and managed.

Without MCP: you tell Claude "you can call create_order, delete_order, update_price" and pass the schemas manually.

With MCP: your MCP server exposes the tools, Claude discovers them automatically, and any MCP-compatible client (Claude, Cursor, your app) can use them without reimplementing the integration.

Does claude sonnet 5 outperform claude 3 opus for agents with MCP?

Yes, significantly. Claude Sonnet 5 (launched June 30, 2026) has better reasoning for agent workflows and can handle more complex sequences of MCP calls. But Opus remains more powerful for non-agentic tasks (plain text analysis, creative writing).

For MCP agents: Sonnet 5 ≥ Opus, at half the cost.

Can i run multiple MCP servers at once?

Yes. You can configure multiple servers in your MCP client:

{
  "servers": {
    "database": { "command": "python", "args": ["./db_mcp.py"] },
    "email": { "command": "node", "args": ["./email_mcp.js"] },
    "shopify": { "url": "HTTPS://MCP.shopify.com" }
  }
}

Claude will see all tools and resources from all three servers. Beware: if two servers expose a tool with the same name, you'll get a collision.

Who hosts the MCP server, me or anthropic?

You do. MCP is open-source and you keep full control. Anthropic provides the protocol and support in Claude, that's it.

Can i use MCP without anthropic?

Yes. MCP is model-agnostic. X launched an MCP server on June 30, 2026, and any MCP-compatible client (including non-Anthropic models) can use it.

Conclusion

The Model Context Protocol solves a real problem: before 2026, every AI agent integration was a one-off customization. Now, it's standardized.

Three key takeaways:

  1. MCP is the new standard for AI agents in 2026, it replaces custom API hacks
  2. Implementing an MCP server is simple, 50 lines of code to expose your tools and data
  3. Claude Sonnet 5 has the best native MCP support, if you're building an agent today, this is the right model

Building an AI agent for your business? Start by exposing your critical data and tools via MCP. Then connect them to Claude Sonnet 5. In a week, you'll automate what took a full day before.

Need help implementing MCP for you? We can audit your current architecture and propose an integration plan. Get in touch.

Équipe Fullstack
Follow us on LinkedIn →

Let's talk about your project

Got a project in the works, a bold idea?
Let's meet and talk about it.

Contact us