MCP (Model Context Protocol)
The USB-C standard for connecting AI agents to tools, data, and APIs.
The Tool Integration Problem
Before MCP, every AI application had to build custom integrations for each tool. If you had 10 tools and 5 AI platforms, you built 50 connectors. Model Context Protocol (MCP), created by Anthropic, standardizes this into a universal protocol — like USB-C for AI.
MCP Architecture
Key Concepts
- MCP Host: The AI application (Claude Desktop, VS Code, your app) that needs to access tools.
- MCP Client: Lives inside the host. Maintains a 1:1 connection with each MCP server.
- MCP Server: Lightweight service that exposes tools, resources (data), and prompts via the MCP protocol.
- Transport: Servers connect via
stdio(local) orSSE/HTTP(remote).
What MCP Servers Expose
- Tools: Functions the LLM can call (e.g.,
query_database,create_issue) - Resources: Read-only data the LLM can access (e.g., file contents, DB schemas)
- Prompts: Reusable prompt templates that the host can surface to users
Code Example
Creating a simple MCP server that exposes tools for a database.
python
1# pip install mcp
2from mcp.server.fastmcp import FastMCP
3import sqlite3
4
5# Create an MCP server
6mcp = FastMCP("My Database Server")
7
8# Expose a tool
9@mcp.tool()
10def query_users(name: str) -> str:
11 \"\"\"Search users by name in the database.\"\"\"
12 conn = sqlite3.connect("app.db")
13 cursor = conn.execute(
14 "SELECT * FROM users WHERE name LIKE ?", (f"%{name}%",)
15 )
16 results = cursor.fetchall()
17 conn.close()
18 return str(results)
19
20# Expose a resource (read-only data)
21@mcp.resource("schema://database")
22def get_schema() -> str:
23 \"\"\"Return the database schema for context.\"\"\"
24 return "CREATE TABLE users (id INT, name TEXT, email TEXT)"
25
26# Run the server
27if __name__ == "__main__":
28 mcp.run(transport="stdio") # Local: stdio, Remote: sseUse Cases
Connecting Claude Desktop to your local filesystem, databases, and Git repos
Building IDE copilots that can read project files, run tests, and create PRs
Creating enterprise tools that connect to Slack, Jira, and internal APIs through a single protocol
Publishing reusable MCP servers that any AI platform can consume
Common Mistakes
Exposing write operations without authentication — MCP servers should enforce access control
Building monolithic MCP servers — keep servers focused on one domain (DB, files, API)
Not using the resources primitive for static context — stuffing everything into tools wastes tokens
Ignoring transport security — remote SSE servers need HTTPS and auth tokens
Interview Insight
Relevance
High - Emerging industry standard by Anthropic, adopted by OpenAI, Google, Microsoft.