tiny-mcp-server
A zero-dependency Python framework for building Model Context Protocol servers using a simple @tool decorator, with support for stdio and SSE transports.
README
tiny-mcp-server
The fastest, smallest way to build Model Context Protocol (MCP) servers in Python. Zero dependencies. MIT.
tiny-mcp-server is a single-file Python framework for building Model Context Protocol servers. No external dependencies, no boilerplate â just decorate a function with @tool and you're shipping an MCP server.
Features
- ðŠķ One-file, zero-dependency â pure Python stdlib, drop it in any project
- ðŠ
@tooldecorator â turn any function into an MCP tool with one line - ð Multiple transports â
stdio(for desktop MCP clients) andsse(for web/remote) - ïŋ― Automatic JSON Schema generation â type hints + docstrings become tool schemas
- ïŋ―ïļ Built-in logging and error handling â never crash on a malformed payload
- ïŋ―ïļ MIT licensed â use it anywhere
Install
Pick whichever is easiest:
# Option 1 â pip (when published)
pip install tiny-mcp-server
# Option 2 â curl a single file and import it
curl -O https://raw.githubusercontent.com/hussain-alsaibai/tiny-mcp-server/main/tiny_mcp_server.py
# Option 3 â vendor it
cp tiny_mcp_server.py your_project/
Quick Start
Here's a complete MCP server with two tools â under 20 lines:
from tiny_mcp_server import Server, tool
app = Server("hello-world")
@app.tool
def add(a: int, b: int) -> int:
"""Add two numbers together."""
return a + b
@app.tool
def greet(name: str = "World") -> str:
"""Greet someone by name."""
return f"Hello, {name}!"
if __name__ == "__main__":
app.run("stdio") # or "sse" for HTTP transport
The add tool's auto-generated JSON Schema:
{
"name": "add",
"description": "Add two numbers together.",
"inputSchema": {
"type": "object",
"properties": {
"a": {"type": "integer"},
"b": {"type": "integer"}
},
"required": ["a", "b"]
}
}
Transports
stdio (default â for Claude Desktop, Cursor, etc.)
app.run("stdio")
The server reads JSON-RPC messages from stdin and writes responses to stdout. This is the transport used by every desktop MCP client.
SSE (HTTP â for web clients)
app.run("sse", host="127.0.0.1", port=8000)
Exposes a Server-Sent Events endpoint at /sse and a POST endpoint at /messages. Great for running an MCP server as a local microservice.
API Reference
Server(name: str)
app = Server("my-server")
@app.tool
@app.tool(name="optional-name", description="optional-desc")
def my_tool(arg: str, count: int = 1) -> str:
"""Tool description (used as fallback if description not provided)."""
return arg * count
nameâ defaults to the function namedescriptionâ defaults to the function's docstring- Arguments are inferred from the signature; types from annotations
- Default values become optional in the schema
app.run(transport: str, **kwargs)
"stdio"â no extra args"sse"âhost(default127.0.0.1),port(default8000)
Examples
See examples/hello_world.py for a runnable demo.
License
MIT ÂĐ hussain-alsaibai
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.