agents

MCP

Learn what MCP (Model Context Protocol) means in AI and machine learning, with examples and related concepts.

Definition

MCP stands for Model Context Protocol — an open standard created by Anthropic that defines how AI applications connect to external data sources and tools.

Think of MCP as “USB-C for AI.” Before USB-C, every device had a different connector. Before MCP, every AI tool had to build custom integrations for every data source. MCP provides one standard protocol so any AI application can connect to any compatible data source.

How It Works

MCP uses a client-server architecture:

┌─────────────┐     MCP Protocol      ┌─────────────────┐
│  AI App      │ ←──────────────────→  │  MCP Server     │
│  (Client)    │   JSON-RPC over       │  (Data Source)   │
│              │   stdio / SSE         │                  │
│  e.g. Claude │                       │  e.g. GitHub,    │
│  Code, IDE   │                       │  Slack, Database │
└─────────────┘                        └─────────────────┘

MCP servers expose three types of capabilities:

Why It Matters

Example

# Building a simple MCP server (Python)
from mcp.server import Server

app = Server("weather-server")

@app.tool()
async def get_weather(city: str) -> str:
    """Get current weather for a city."""
    return f"72°F and sunny in {city}"

@app.resource("weather://{city}/forecast")
async def get_forecast(city: str) -> str:
    """Get 5-day forecast for a city."""
    return f"5-day forecast for {city}: ..."
// Claude Code MCP server configuration (~/.claude.json)
{
  "mcpServers": {
    "weather": {
      "command": "python",
      "args": ["weather_server.py"]
    }
  }
}

MCP vs Direct API Integration

MCPDirect API
ReusabilityOne server, many clientsCustom per app
DiscoveryAuto-discovers tools/resourcesHardcoded
StandardOpen protocolProprietary
Best forAI tool integrationsGeneral software

Key Takeaways


Part of the DeepRaft Glossary — AI and ML terms explained for developers.