LLMs & GenAI

Model Context Protocol (MCP)

The open standard developed by Anthropic for connecting AI models to data sources, tools, and application contexts over a unified protocol.

🟡 intermediate5 min readagents
Model Context Protocol (MCP - Anthropic, 2024) is an open client-server protocol that standardizes how AI applications provide context, prompt templates, and tool capabilities to LLMs. Instead of writing custom API integration code for every data source (GitHub, Postgres, Slack, Google Drive) for each distinct AI application, MCP establishes a universal interface: MCP Servers expose Resources, Tools, and Prompts, while MCP Clients (Claude Desktop, IDEs) consume them over standardized JSON-RPC 2.0 transport layers (stdio / SSE).

The N×M Integration Problem vs MCP Standard

  BEFORE MCP (Custom N × M Matrix):
  Claude Desktop ──► Custom Github Code ──► GitHub API
  VS Code Copilot──► Custom Github Code ──► GitHub API
  Custom Agent   ──► Custom Postgres Code ─► Postgres DB

  AFTER MCP (Universal Standard Interface):
  [ MCP CLIENTS ]                        [ MCP SERVERS ]
  - Claude Desktop ─────── (JSON-RPC) ──────► GitHub MCP Server ──► GitHub API
  - Cursor / VS Code ───── (Over stdio/SSE) ──► Postgres MCP Server ──► Postgres DB
  - Custom AI Agents ────────────────────────► Slack MCP Server ────► Slack API

Three Core MCP Primitives

                                    MCP PRIMITIVES
┌──────────────────────────┬──────────────────────────┬──────────────────────────┐
│  1. RESOURCES            │  2. TOOLS                │  3. PROMPTS              │
├──────────────────────────┼──────────────────────────┼──────────────────────────┤
│ Read-only data sources   │ Executable functions     │ Parameterized prompt     │
│ (File contents, database │ (API calls, SQL queries, │ templates exposed to the │
│ rows, API responses).    │ file operations).        │ client UI.               │
│ URI: `file:///log.txt`   │ Schema: JSON Schema      │ Args: `{"repo": "vllm"}` │
└──────────────────────────┴──────────────────────────┴──────────────────────────┘

Transport Architecture

  1. Local Process Transport (stdio): Client launches MCP Server sub-process locally, communicating via standard input/output streams. Ideal for Desktop apps and IDE extensions.
  2. Remote Network Transport (SSE): Client connects over HTTP using Server-Sent Events (SSE) for server-to-client streaming, and POST endpoints for client-to-server JSON-RPC requests.

Example MCP Tool Registration (Python SDK)

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("Database Explorer")

@mcp.tool()
def execute_sql_query(query: str) -> str:
    """Executes a read-only SQL query against the SQLite database."""
    # MCP automatically generates JSON Schema from docstrings & type hints!
    return db.execute(query).fetchall()

if __name__ == "__main__":
    mcp.run(transport="stdio")

Say this out loud

"Model Context Protocol (MCP) is Anthropic's open standard unifying how AI models connect to tools and data sources. MCP Servers expose Resources (data), Tools (functions), and Prompts (templates) over JSON-RPC 2.0 via stdio or SSE. MCP eliminates N×M custom API integrations, enabling any AI client to interact with any MCP server seamlessly."

Follow-ups to expect

Check yourself

Question 1 of 3

What core problem does the Model Context Protocol (MCP) solve for AI developers?

More in LLMs & GenAI

See all →
Pretraining → SFT → RLHF5 minFine-Tune vs RAG vs Prompt: Choosing5 minRetrieval-Augmented Generation5 min