Skip to content

Demystifying 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 clarify the boundaries first:

  • MCP Concept 1 (Multi-Agent Collaboration): Sometimes refers to "Multi-Agent Collaboration Platform," such as AutoGen, which allows multiple AI agents to work together. Cool, but not the focus today.
  • MCP Concept 2 (Anthropic Protocol): This is a formal standard launched by Anthropic (the developer of Claude), officially called "Model Context Protocol," designed to enable AI models (such as Claude) to interact with external data and tools efficiently and securely.

Focus of this Article: We focus on Anthropic's MCP, guiding you to understand what it is, why it's important, and how to quickly develop with MCP!


First Stop: Why is MCP Needed? The "Pain Points" of AI Interaction

Imagine you are using Claude to work, and the task becomes complex, it may fail:

  • Confused Instructions: Background, steps, and restrictions are mixed together, and the AI cannot grasp the key points.
  • Lost Context: As the conversation gets longer, the AI forgets your original requirements.
  • Unsmooth Tool Calling: If you want the AI to check the weather or read files, it either doesn't know how to use it or uses it incorrectly.
  • Security Risks: Malicious input (Prompt Injection) may cause the AI to make mistakes.

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


Second Stop: The Core of MCP: Structured Communication

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

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

Example: Check the MCP interaction submitted to GitHub:

json
[
  { "role": "system", "content": "You are my programming assistant and have 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 messy input into a standardized "table," making it more efficient for AI to process.


Third Stop: MCP Ecosystem: Protocol + Tools

MCP is not just a protocol, but also has supporting tools. The three core components are:

1. MCP Server

  • What is it: A server that complies with the MCP protocol, like a "transfer station," receiving and processing MCP requests, connecting AI models and external resources.
  • Function:
    • Parses MCP format requests and hands them over to models or tools.
    • Returns standardized MCP responses.
    • Supports custom tools and data access.
  • Implementation Method:
    • Anthropic provides pre-built servers (such as Google Drive, Slack).
    • Developers can quickly build with FastMCP (Python SDK).
  • Key Point: It is the core hub of MCP. It is officially recommended to implement it with FastMCP because it simplifies tool definition and server building.

2. MCP SDK (Software Development Kit)

  • What is it: A developer's "toolbox" that supports Python, TypeScript, etc.
  • Function: Provides convenient APIs, such as FastMCP, allowing you to easily build and send MCP requests.
  • Example: After defining a tool with FastMCP, a JSON Schema is automatically generated.

3. MCP Connector

  • What is it: An "adapter" that connects non-MCP systems.
  • Function: Translates requests and results from external tools (such as databases) into MCP format.
  • Example: The community provides connectors such as Postgres, Puppeteer, etc.

Workflow:

  1. Write an application with the SDK (including FastMCP) and send a request.
  2. The MCP server receives it and calls the model or tool.
  3. The result is returned to the application.

Fourth Stop: The Benefits and Latest Developments of MCP

Core Advantages

  • Reliability: Structured communication reduces misunderstandings.
  • Tool Integration: Seamlessly call external resources.
  • Security: Reduce the risk of injection attacks.
  • Scalability: The standard protocol supports cross-system collaboration.

Latest Developments (as of April 2025)

  • Industry Support: OpenAI, Microsoft, and Google joined, and MCP may become the "HTTP of AI."
  • Ecosystem Expansion: Anthropic released a roadmap in January 2025 to support remote connections.
  • Active Community: There are thousands of contributions to modelcontextprotocol on GitHub.

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

Want to use MCP? Here is a getting started guide based on FastMCP.

Preparation

  1. Environment: Python 3.10+.
  2. Install SDK:
    bash
    pip install "mcp[cli]" httpx
  3. Tools: Get a Weather API Key (such as 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 the real-time weather of 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 the server
    if __name__ == "__main__":
        mcp.run()
    • Explanation:
      • FastMCP is the officially recommended advanced framework, which automatically handles tool registration and JSON Schema generation.
      • The @mcp.tool() decorator defines the tool and simplifies development.
  2. Start the server:

    bash
    python weather_server.py

Test with 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 is 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 is MCP: Anthropic's standardized protocol to improve AI interaction efficiency with external resources.
  • How it Works: JSON structured communication, equipped with tools like FastMCP.
  • Why it Matters: It may be the future standard for AI development.
  • Take Action Now: Use FastMCP to run the server in 10 minutes!

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

References

MCP Official DocumentationGitHub MCP