Install the `mcp` package from PyPI. The SDK exposes FastMCP, a decorator-driven API that auto-generates JSON Schema from type hints, uses docstrings as tool descriptions, and ships stdio plus streamable HTTP transports.
Imagine you write a small Python file with a few functions that do useful things: add numbers, list files, query a database. The MCP Python SDK is a tiny library that lets you put one decorator above each function and turns the file into a server that any MCP host (Claude Desktop, Cursor, Zed) can connect to and call. The library reads your type hints to figure out what arguments each function expects, so the AI knows how to call you. You write normal Python; the SDK turns it into a tool server.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Python is the default language for ML and data tooling, so a large share of internal MCP servers end up written in Python. The official Python MCP SDK exists to make that path easy: install one package, decorate your functions, run.
This deep dive covers the package and where it lives, the two API layers the SDK exposes, the FastMCP decorator pattern, the type hint to schema bridge, and the operational details (transports, async) worth knowing on day one.
The package, the repo, the install
The official SDK is the mcp package on PyPI, maintained at github.com/modelcontextprotocol/python-sdk by the same Anthropic-led team that maintains the protocol spec. Install with pip install mcp, or uv add mcp if you use uv (the fast Rust-based package manager that has become the default for new Python projects in 2026).
Name ambiguity catches people. The package is not model-context-protocol, not mcp-sdk, not anthropic-mcp. Just mcp. The repository sits under the modelcontextprotocol GitHub org alongside the TypeScript SDK and a growing set of language SDKs.
What you get on install: the server-side FastMCP framework, the lower-level Server API it is built on, a client-side Client class, transport helpers for stdio and streamable HTTP, type definitions for every protocol message, and Pydantic models for the schemas. The total footprint is small (a few MB plus dependencies), and the runtime overhead is negligible compared to whatever real work the server does.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- A data team wraps their internal feature-store query API as a FastMCP server in roughly 50 lines, letting engineers ask Claude Desktop questions about feature freshness and data quality.
- An ML engineer exposes a Hugging Face datasets browser as MCP resources so the model can read dataset cards and metadata on demand without hardcoded URLs.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow does FastMCP turn Python type hints into JSON Schema?
It introspects the function signature with inspect, resolves type hints to their JSON Schema equivalents (int to integer, list[str] to array of string, Pydantic models to nested objects), and uses the docstring as the tool description.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Pip-installing model context protocol or mcp-sdk instead of the canonical name `mcp`. The correct PyPI package is just `mcp`, maintained by Anthropic.
60 second bullets to scan on the way to the call.
The PyPI package name (
mcp) and install command.The GitHub repo (github.com/modelcontextprotocol/python-sdk).
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.