Building Zero-Dependency MCP Servers in Pure Python

How to implement the Model Context Protocol from scratch — no SDK, no framework, no pip installs. Just the standard library and a socket.

Why Zero Dependencies?

The Model Context Protocol (MCP) is Anthropic's open standard for connecting AI assistants to external tools and data sources. The official SDK (mcp on PyPI) is excellent — well-tested, feature-complete, and ergonomic. But it pulls in pydantic, httpx, anyio, httpx-sse, tokenizers, and a tree of transitive dependencies that, as of mid-2026, totals 47 installed packages.

For most server authors, that's fine. But there's a category of deployment where 47 packages is a dealbreaker: