Skip to content

Fully Understanding MCP in AI: Focusing on Anthropic's "Model Context Protocol" and Its Ecosystem

The AI world is rapidly evolving, and "MCP" is a term that can easily cause confusion. Let's first clarify the boundaries:

  • MCP Concept 1 (Multi-Agent Collaboration): Sometimes refers to "Multi-Agent Collaboration Platform," such as AutoGen, which enables multiple AIs to work together. It's cool, but not the focus today.
  • MCP Concept 2 (Anthropic Protocol): This is the official standard introduced by Anthropic (the developer of Claude), with the full name "Model Context Protocol," aimed at enabling efficient and secure interactions between AI models (like Claude) and external data and tools.

Focus of this article: We concentrate on Anthropic's MCP, helping you understand what it is, why it matters, and how to quickly develop with MCP!


First Stop: Why Do We Need MCP? The "Pain Points" of AI Interaction

Imagine you're using Claude for work; when tasks get complex, things can go wrong:

  • Confusing Instructions: Background, steps, and limitations are mixed together, making it hard for the AI to grasp the key points.
  • Context Loss: In long conversations, the AI forgets your initial requirements.
  • Tool Calling Issues: When you want the AI to check the weather or read a file, it either can't use the tools or uses them incorrectly.
  • Security Risks: Malicious inputs (Prompt Injection) can cause the AI to make errors.

MCP is a standardized communication protocol, like a "universal language" between AI and the external world, aiming to make information structured, processes smooth, and interactions secure and reliable.


Second Stop: The Core of MCP: Structured Communication

MCP uses JSON format to divide information into clear parts, each with its own role (Role). The core roles defined officially include:

  • system: Global settings, e.g., "You are a weather assistant that can check real-time weather."
  • user: User input, e.g., "What's the weather in Beijing?"
  • assistant: AI response, which may include tool calls (tool_use).
  • tool_use: Instructions for calling tools, e.g., { "name": "get_weather", "input": { "city": "Beijing" } }.
  • tool_result: Results returned by tools, e.g., { "result": "Sunny, 25°C" }.

Example: MCP interaction for querying GitHub commits:

json
[
  { "role": "system", "content": "You are my programming assistant with access to GitHub." },
  { "role": "user", "content": "Check my latest GitHub commit." },
  { "role": "assistant", "content": "Calling tool", "tool_use": { "name": "github_latest_commit", "input": { "username": "yourname" } } },
  { "role": "tool_result", "content": { "commit_message": "Fix bug #123", "date": "2025-03-31" } },
  { "role": "assistant", "content": "Latest commit: Fix bug #123, 2025-03-31." }
]

Summary: MCP turns chaotic inputs into standardized "forms," making AI processing more efficient.


Third Stop: The MCP Ecosystem: Protocol + Tools

MCP is more than just a protocol; it includes supporting tools. The three core components are:

1. MCP Server

  • What it is: A server that adheres to the MCP protocol, acting as a "hub" that receives and processes MCP requests, connecting AI models to external resources.
  • Functions:
    • Parses MCP-formatted requests and passes them to models or tools.
    • Returns standardized MCP responses.
    • Supports custom tools and data access.
  • Implementation:
    • Anthropic provides pre-built servers (e.g., for Google Drive, Slack).
    • Developers can use FastMCP (Python SDK) to quickly build their own.
  • Key Point: It is the core hub of MCP, and the official recommendation is to use FastMCP for implementation because it simplifies tool definition and server setup.

2. MCP SDK (Software Development Kit)

  • What it is: A "toolkit" for developers, supporting languages like Python and TypeScript.
  • Functions: Provides convenient APIs, such as FastMCP, making it easy to build and send MCP requests.
  • Example: Using FastMCP to define tools automatically generates JSON Schema.

3. MCP Connector

  • What it is: An "adapter" that connects non-MCP systems.
  • Functions: Translates requests and results from external tools (e.g., databases) into MCP format.
  • Example: Community-provided connectors for Postgres, Puppeteer, etc.

Workflow:

  1. Use the SDK (including FastMCP) to write applications and send requests.
  2. The MCP server receives the requests and calls models or tools.
  3. Results are returned to the application.

Fourth Stop: Benefits and Latest Developments of MCP

Core Advantages

  • Reliability: Structured communication reduces misunderstandings.
  • Tool Integration: Seamlessly calls external resources.
  • Security: Reduces injection risks.
  • Scalability: Standard protocol supports cross-system collaboration.

Latest Developments (As of April 2025)

  • Industry Support: OpenAI, Microsoft, and Google have joined, potentially making MCP the "HTTP for AI."
  • Ecosystem Expansion: Anthropic released a roadmap in January 2025 supporting remote connections.
  • Active Community: The modelcontextprotocol on GitHub has thousands of contributors.

Fifth Stop: How Can Beginners Quickly Get Started with MCP Development?

Want to use MCP? Here's a beginner's guide based on FastMCP.

Preparations

  1. Environment: Python 3.10+.
  2. Install SDK:
    bash
    pip install "mcp[cli]" httpx
  3. Tools: Obtain a Weather API Key (e.g., from weatherapi.com).

Developing an MCP Server with FastMCP

Goal: Build a weather query server.

  1. Code Example (weather_server.py):

    python
    from mcp.server.fastmcp import FastMCP
    import httpx
    
    # Initialize FastMCP server
    mcp = FastMCP("weather_server")
    
    # Define weather tool
    @mcp.tool()
    async def get_weather(city: str) -> str:
        """Get real-time weather for a specified city"""
        async with httpx.AsyncClient() as client:
            url = f"http://api.weatherapi.com/v1/current.json?key=YOUR_API_KEY&q={city}"
            response = await client.get(url)
            data = response.json()
            return f"{city} weather: {data['current']['condition']['text']}, {data['current']['temp_c']}°C"
    
    # Run server
    if __name__ == "__main__":
        mcp.run()
    • Explanation:
      • FastMCP is the officially recommended high-level framework that automatically handles tool registration and JSON Schema generation.
      • The @mcp.tool() decorator defines tools, simplifying development.
  2. Start the Server:

    bash
    python weather_server.py

Testing with a Client

  1. Client Code (client.py):

    python
    from mcp import MCPClient
    
    client = MCPClient(server_url="http://localhost:8000")
    client.add_message(role="system", content="You are a weather assistant.")
    client.add_message(role="user", content="What's the weather in Beijing?")
    client.add_tool("get_weather")
    response = client.send()
    print(response["content"])  # Output: Beijing weather: Sunny, 25°C
  2. Run:

    • First, run the server: python weather_server.py
    • Then, run the client: python client.py

  • What MCP is: Anthropic's standardized protocol to enhance AI interaction efficiency with external systems.
  • How it works: Structured JSON communication, paired with tools like FastMCP.
  • Why it's important: It could become the future standard for AI development.
  • Take action now: Use FastMCP to get a server running in 10 minutes!

Why Use FastMCP: Official examples heavily use FastMCP because it encapsulates underlying details and is suitable for rapid development. Compared to manual FastAPI implementations, FastMCP is closer to the official style and simpler.

References

MCP Official DocumentationGitHub MCP