Low-level access
Let’s recap how we first build a server so we can easily compare it to how low-level access is different. Here’s how you build a simple MCP server with a high-level API:
from mcp.server.fastmcp import FastMCP mcp = FastMCP("Echo") @mcp.resource("echo://{message}") def echo_resource(message: str) -> str: """Echo a message as a resource""" return f"Resource echo: {message}" @mcp.tool() def echo_tool(message: str) -> str: """Echo a message as a tool""" return f"Tool echo: {message}" The FastMCP class is what you use to instantiate a server – in this case, an instance called mcp. Then we use @mcp to define resources, tools, and prompts.
This is a high-level way of building a server, but what if you want more control over how the server is built? Here’s how you can do that using low-level access.
Let’...