ProtocolPythonTypeScript

Model Context Protocol

by AnthropicUpdated Jun 15, 2025

Open protocol that standardizes how LLM applications connect to external data sources, tools, and services. MCP defines a client-server architecture where MCP servers expose tools, resources, and prompts through a standard interface, and MCP clients (like Claude, IDEs, and agent frameworks) can discover and use them. Think of it as a 'USB-C for AI' — one standard connector for all integrations.

Architecture Overview

MCP uses a JSON-RPC 2.0-based client-server protocol. An MCP server exposes three primitives: Tools (callable functions), Resources (readable data), and Prompts (reusable templates). The transport layer supports stdio (for local servers) and HTTP with Server-Sent Events (for remote servers). Clients discover server capabilities via an initialization handshake, then invoke tools and read resources through typed RPC calls. The protocol is stateful within a session but stateless between sessions.

When to Use Model Context Protocol

  • Standardized tool integration for LLM applications
  • Connecting AI assistants to databases, APIs, and services
  • Building reusable tool servers shared across applications
  • Agent interoperability across different frameworks
  • IDE and developer tool AI integration

Strengths & Weaknesses

Strengths

  • Industry standard backed by Anthropic, OpenAI, and others
  • Growing ecosystem with 1000+ community servers
  • Simple protocol that is easy to implement in any language
  • Decouples tool implementation from agent framework
  • Supports both local (stdio) and remote (HTTP/SSE) transports

Weaknesses

  • Still evolving — specification changes can break implementations
  • Authentication and authorization patterns still maturing
  • Discovery and registry mechanisms are still being developed

Quick Start

python
# Build an MCP server in Python
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("Weather Service")

@mcp.tool()
def get_weather(city: str) -> str:
    """Get the current weather for a city.

    Args:
        city: The city name to get weather for
    """
    return f"The weather in {city} is sunny, 72°F."

@mcp.resource("weather://current/{city}")
def weather_resource(city: str) -> str:
    """Provide weather data as a readable resource."""
    return f"Current conditions in {city}: Sunny, 72°F, Humidity: 45%"

@mcp.prompt()
def weather_prompt(city: str) -> str:
    """Generate a weather analysis prompt."""
    return f"Analyze the current weather conditions in {city} and provide recommendations."

# Run the server (stdio transport for local use)
if __name__ == "__main__":
    mcp.run()

Features at a Glance

DeveloperAnthropic
LanguagePython, TypeScript
LicenseMIT
GitHub Stars40k+
MCP SupportYes
Multi-AgentNo

Notable Users

AnthropicOpenAICursorZed

Resources

Explore Related Content