andersch.dev

<2025-03-22 Sat>
[ ai ]

Model Context Protocol (MCP)

The Model Context Protocol (MCP) is an open protocol that specifies how an LLM can retrieve data from different sources into its context window and can be used to provide custom tool usage to a model. It was introduced by Anthropic in 2024.

Similar to Retrieval Augmented Generation (RAG), MCP is concerned with giving LLMs access to data that was not part of their original training data set.

Protocol

Components:

  • MCP Host: Program that wants to access resources (e.g. Claude Desktop)
  • MCP Client: On the host; maintains connections with servers
  • MCP Servers: Provides resources, prompts and tools
  • Resources: Local (filesystem, databases), or remote (behind API)

Python SDK Example

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("hello-world-server")

@mcp.tool(
    description="Say hello to someone"
)
def say_hello(name: str) -> str:
    return f"Hello, {name}!"

MCP Servers

See Awesome MCP Servers

Resources