AI Infrastructure & Tools11 min read

Model Context Protocol (MCP)

The USB port for AI β€” one standard that lets any model talk to any tool
scope:Intermediatedifficulty:Intermediate

The USB Port for AI

Remember what life was like before USB? Every device had its own special cable. Your printer used a parallel port. Your mouse used a PS/2 connector. Your camera used a FireWire cable. Your phone had a proprietary charger. You needed a different cable for everything, and nothing was interchangeable.

Then USB came along: one standard port that works with everything. Mouse, keyboard, printer, phone, camera, hard drive β€” all the same connector.

MCP (Model Context Protocol) is the USB port for AI. It's an open standard, created by Anthropic in late 2024, that lets any AI model connect to any external tool or data source using a single, universal protocol.

The Problem MCP Solves

Before MCP, connecting an AI to external tools was a mess:

  • Want Claude to read your files? Write custom code for that.
  • Want GPT-4 to query your database? Write different custom code.
  • Want Gemini to post to Slack? Write yet more custom code.
  • Want to switch from Claude to GPT-4? Rewrite all your integrations.

Every combination of (AI model) x (tool) required its own custom integration. If you had 5 AI models and 10 tools, that's 50 custom integrations to build and maintain. This is called the M x N problem.

MCP collapses this to M + N. Each AI model implements the MCP client protocol once. Each tool implements the MCP server protocol once. And they all work together automatically.

How MCP Works: Clients and Servers

MCP has two sides:

MCP Servers (the tools)

An MCP server wraps a tool, API, or data source and exposes it through a standardized interface. Examples:

  • Filesystem server β€” read, write, search, and list files
  • GitHub server β€” create issues, read PRs, search repos
  • Slack server β€” send messages, read channels, search history
  • Postgres server β€” query tables, describe schemas, run SQL
  • Google Drive server β€” search docs, read spreadsheets, create files
  • Brave Search server β€” search the web in real time

Each server tells clients: "Here are the tools I offer, here's what each tool does, and here are the parameters it accepts."

MCP Clients (the AI apps)

An MCP client is any AI application that can connect to MCP servers and use their tools. Examples:

  • Claude Desktop β€” Anthropic's desktop app
  • Cursor β€” AI-powered code editor
  • VS Code + Copilot β€” GitHub's AI assistant
  • Windsurf β€” Another AI coding tool
  • Any custom app you build with the MCP SDK

The magic: a GitHub MCP server built for Claude Desktop also works with Cursor, VS Code, and any other MCP client. Write once, use everywhere.

What MCP Exposes: Tools, Resources, and Prompts

MCP servers can expose three types of capabilities:

  • Tools β€” Actions the AI can take. Like "send_message," "create_file," or "run_query." The AI calls these with specific parameters.
  • Resources β€” Data the AI can read. Like a database schema, a configuration file, or the contents of a document. Think of these as read-only data sources.
  • Prompts β€” Pre-built prompt templates that help the AI use the server effectively. For example, a database server might include a prompt template for "analyze this table."

The Discovery Step

One of MCP's most powerful features is automatic discovery. When an AI client connects to an MCP server, it doesn't need to know in advance what tools are available. It asks the server: "What can you do?" The server responds with a list of all its tools, their descriptions, and their parameter schemas.

This means you can add new MCP servers to your AI setup and the AI immediately knows how to use them β€” no code changes, no retraining, no manual configuration.

Building a Simple MCP Server in Python

from mcp.server.fastmcp import FastMCP
# Create an MCP server called "weather"
mcp = FastMCP("weather")
# Define a tool that any AI client can discover and use
@mcp.tool()
def get_weather(city: str) -> str:
"""Get the current weather for a city.
Args:
city: The city name (e.g., 'London', 'Tokyo')
"""
# In a real app, this would call a weather API
weather_data = {
"London": "Cloudy, 15Β°C, 60% humidity",
"Tokyo": "Sunny, 28Β°C, 45% humidity",
"New York": "Rainy, 12Β°C, 85% humidity",
}
return weather_data.get(city, f"Weather data not found for {city}")
@mcp.tool()
def get_forecast(city: str, days: int = 3) -> str:
"""Get a weather forecast for the next N days.
Args:
city: The city name
days: Number of days to forecast (1-7)
"""
return f"Forecast for {city}: Next {days} days look mild with occasional rain."
# Expose a resource (read-only data)
@mcp.resource("weather://supported-cities")
def list_cities() -> str:
"""List all cities with weather data."""
return "London, Tokyo, New York, Paris, Sydney"
# Start the server β€” any MCP client can now connect!
if __name__ == "__main__":
mcp.run()
Output
# When an MCP client connects, it discovers:
#
# Tools available:
#   - get_weather(city: str) -> str
#   - get_forecast(city: str, days: int) -> str
#
# Resources available:
#   - weather://supported-cities
#
# The AI can now call these tools automatically:
# "What's the weather in Tokyo?" β†’ calls get_weather("Tokyo")
# β†’ Returns: "Sunny, 28Β°C, 45% humidity"
Note: MCP is open source and open standard. Anthropic created MCP but released it as an open protocol β€” anyone can build MCP servers and clients. There's a growing ecosystem of community-built servers for everything from email to Kubernetes to Spotify. You can find them at github.com/modelcontextprotocol/servers.

Real-World MCP Examples

Here's what MCP looks like in practice:

  • Coding assistant + GitHub MCP server: "Create a pull request for the changes I just made" β€” The AI uses the GitHub MCP server to create a PR with a title, description, and the right branch.
  • Data analyst + Postgres MCP server: "What were our top-selling products last month?" β€” The AI discovers the database schema, writes a SQL query, executes it, and presents the results.
  • Team chat + Slack MCP server: "Summarize what the engineering team discussed yesterday" β€” The AI reads the Slack channel history and generates a summary.
  • Writer + Google Drive MCP server: "Find my notes on the Q3 marketing plan" β€” The AI searches Google Drive and pulls up the relevant document.

Why MCP Matters

MCP is important because it transforms AI from a text-in, text-out tool into something that can actually do things in the real world. Without MCP (or something like it), every AI integration is a one-off engineering project. With MCP, you can snap together AI capabilities like LEGO bricks β€” mix and match any AI model with any tool.

This is a critical step toward AI agents β€” AI systems that don't just answer questions but take actions on your behalf.

Challenge

Quick check

What problem does MCP solve?

Continue reading