Zenaique

You want to build an MCP server in Python. What do you install and what does the API look like?

Flashcard·Easy·4.0 · 0·~30s·Asked atDatadogDifyDoordash·Relevant atAnthropic
Attempt it
TL;DR

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.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

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.

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.

Two layers: FastMCP and the low-level Server
FastMCP: a complete server in a few lines
Type hints become JSON Schema
Transports and operational notes
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

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.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow does FastMCP turn Python type hints into JSON Schema?
A

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.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Pip-installing model context protocol or mcp-sdk instead of the canonical name `mcp`. The correct PyPI package is just `mcp`, maintained by Anthropic.

Sign in to see all red flags and common mistakes.

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).

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is the Model Context Protocol (MCP) and what problem does it solve?
MCQ·Easy