Model Context Protocol: Building Agent Integrations That Last
Anthropic's Model Context Protocol (MCP) is quietly becoming the standard for agent-tool integration. If you're building agents that need to interact with databases, APIs, or file systems, MCP is the architecture you should be using.
What MCP Solves
Before MCP, every agent framework had its own tool-calling format:
- LangChain had "Tools"
- OpenAI had "Functions"
- Custom systems rolled their own JSON schemas
The problem: zero portability. Build a GitHub integration for LangChain? Rewrite it for OpenAI. Switch agent frameworks? Rewrite everything.
MCP provides a universal protocol: one server, any client.
The Architecture
MCP is client-server:
Server: Exposes resources (databases, APIs, file systems) as standardized operations Client: Agent or application that calls those operations
The protocol defines three primitives:
- Resources: Read-only data (files, database records)
- Prompts: Reusable prompt templates with variables
- Tools: Functions the agent can call (mutations, actions)
Why This Matters
- Composability: Build MCP servers once, use across any MCP-compatible agent
- Security: Servers run in isolated contexts with explicit permissions
- Portability: Same server works with Claude, GPT, local models, custom agents
Building an MCP Server
Here's the mental model:
// Expose a database as an MCP server
const server = new Server({
name: "postgres-mcp",
version: "1.0.0"
})
// Register resources (read operations)
server.setResourceHandler(async (url) => {
if (url.startsWith("db://")) {
const result = await db.query(url)
return { contents: [{ text: JSON.stringify(result) }] }
}
})
// Register tools (write operations)
server.setToolHandler(async (name, args) => {
if (name === "execute_query") {
return await db.execute(args.sql)
}
})The server exposes a JSON-RPC interface. Agents connect via stdio, HTTP, or WebSocket.
Production Patterns
1. Supabase MCP: Expose entire database schema as resources + CRUD tools 2. GitHub MCP: Repos as resources, PR creation as tools 3. Filesystem MCP: Read files as resources, write as tools
The key insight: resources are for context injection (feeding the agent data), tools are for actions (agent making changes).
Deployment
MCP servers can run:
- Locally: Cursor, Claude Code, Windsurf all support local MCP
- Hosted: Deploy to Vercel, Railway, Modal as HTTP endpoints
- Embedded: Package with your agent for single-binary distribution
The Future
MCP is becoming the TCP/IP of agent systems — a thin, universal protocol that everything builds on. As more tools adopt it, we'll see:
- MCP registries: npm-style package managers for agent tools
- Permissioned marketplaces: Vetted, security-audited servers
- Cross-framework interop: Same tools work in LangGraph, Anthropic Agent SDK, OpenAI Agents
If you're building agent infrastructure, bet on MCP. It's the rare protocol that's both simple enough to adopt and powerful enough to matter.
