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:
- Tools — Functions the AI can call (e.g.,
create_pull_request,send_message) - Resources — Data the AI can read (e.g., file contents, database records)
- Prompts — Reusable prompt templates
Why It Matters
- Interoperability — Build one MCP server, and it works with Claude, VS Code, JetBrains, and any MCP-compatible client
- Ecosystem — Growing library of pre-built servers for GitHub, Slack, Google Drive, databases, and more
- Security — Standardized permission model instead of ad-hoc API key sharing
- Developer experience — Build integrations once instead of per-application
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
| MCP | Direct API | |
|---|---|---|
| Reusability | One server, many clients | Custom per app |
| Discovery | Auto-discovers tools/resources | Hardcoded |
| Standard | Open protocol | Proprietary |
| Best for | AI tool integrations | General software |
Key Takeaways
- MCP is an open standard for connecting AI apps to external tools and data
- It eliminates the N×M integration problem (N apps × M data sources → N+M)
- Supported by Claude Code, VS Code, JetBrains IDEs, and growing
- You can build custom MCP servers to expose any data or functionality to AI tools
- The protocol uses JSON-RPC — simple, well-understood, easy to implement
Part of the DeepRaft Glossary — AI and ML terms explained for developers.