Introduction
Model Context Protocol (MCP) — developed by Anthropic — is an open standard that helps agents connect to any data source or tool in a consistent way. Instead of writing custom integration for each tool, you implement MCP Server once and all MCP-compatible clients can use it.
1. MCP Architecture
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ MCP Client │◄───►│ MCP Server │◄───►│ Data Source │
│ (Agent/IDE) │ │ (Your code) │ │ (DB/API/FS) │
└──────────────┘ └──────────────┘ └──────────────┘
2. Build MCP Server
from mcp.server import Server
from mcp.types import Tool
server = Server("my-tools")
@server.tool("query_database")
async def query_db(sql: str) -> str:
"""Execute read-only SQL query."""
result = await db.execute(sql)
return json.dumps(result)
@server.tool("search_github")
async def search_github(query: str, repo: str) -> str:
"""Search code in a GitHub repository."""
...
Summary
- MCP = USB-C for AI — universal connection standard
- Client/Server architecture: agents are clients, tools are servers
- Tool discovery: the agent knows which tools are available
- Ecosystem: 1000+ MCP servers available
Exercises
- Build MCP Server for SQLite database
- Build MCP Server for GitHub API (search repos, read files)
- Connect agent to 3+ MCP Servers at the same time
- Compare custom tool vs MCP tool: development experience