Build an MCP server in Python
Build an MCP server in Python
The Python MCP SDK turns a typed function into a tool the same way FastAPI turns one into a route. You decorate it, the SDK reads the parameters and the docstring, and a JSON Schema and a description appear in tools/list without you writing either. The Relay server you sketched in the last lesson is about thirty lines, and most of them are the tool bodies you already have.
Two commands run it. One starts a development inspector over stdio so you can click through the tools in a browser. The other serves it over streamable HTTP at a URL that agents and desktop hosts can connect to. The code does not change between the two.
Continue reading
Pro unlocks every video lesson, the full notes and runnable code across the Python with AI course, from the language itself to agents, MCP, Langfuse and deployment.