Project

umcp

active

Micro MCP server — zero dependencies, stdio and HTTP transports, sync and async.

Overview

A zero-dependency Python micro-framework for the Model Context Protocol. Sync and async implementations (umcp.py and aioumcp.py) with a shared umcp_shared.py module, no third-party packages, stdio, Streamable HTTP, legacy HTTP+SSE and TCP transports, and a naming convention — functions starting with tool_ or prompt_ are discovered and exposed automatically. Type hints become JSON Schema; docstrings become descriptions. Adding MCP to an existing script takes minutes.

How it works

The protocol layer reads JSON-RPC 2.0 over stdio, Streamable HTTP, legacy HTTP+SSE or raw TCP. It discovers tool_ and prompt_ methods on your subclass via introspection, generates inputSchema from type hints (including Literal, Union, Optional, TypedDict), and infers MCP annotations (readOnlyHint, destructiveHint) from naming conventions. Return a value and it serialises automatically. Pick MCPServer for local-disk and compute work; pick AsyncMCPServer when tools are network-bound.

Features
🪶
Zero dependencies

Pure Python 3.10+ standard library; no third-party packages.

📡
Local and network transports

stdio, Streamable HTTP, legacy HTTP+SSE and raw TCP.

🔍
Convention over decoration

Name a method tool_ or prompt_ — discovery, schema generation, and MCP wiring happen automatically.

⚡
Sync + async

MCPServer for compute / disk-bound tools; AsyncMCPServer for network-bound tools. Same API surface.

📐
Full schema inference

Literal, Union, Optional, TypedDict -> JSON Schema. Strict argument validation, type coercion for stringy clients.

📝
Prompt templates

prompt_* methods exposed via prompts/list and prompts/get. Reusable structured interactions for AI assistants.

Architecture
Your Python code tool_* / prompt_* methods MCPServer introspect + JSON Schema Discovery auto naming Schema gen type hints Transport stdio · SSE · TCP MCP client Claude · Copilot · Pi JSON-RPC Zero-dependency Python MCP framework — convention over decoration
Posts