mini-mcp-demo
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mini-mcp-demoadd 2 and 40"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mini-mcp
MCP (Model Context Protocol), implemented from first principles in ~200 readable lines. A server, a client, and the JSON-RPC mechanics between them — the tool-calling core that every agent integration depends on, small enough to read in one sitting.
git clone https://github.com/harshadkhetpal/mini-mcp
cd mini-mcp
PYTHONPATH=src python3 -m minimcp.clientconnected: mini-mcp-demo protocol 2025-06-18
tools discovered: calc.add, text.word_count, text.summarize_naive
calc.add(2, 40) -> 42
word_count -> 6Why build this when SDKs exist
Frameworks hide the protocol, and hidden protocols produce engineers who can wire an
integration but cannot debug one. Implementing the core teaches what the SDKs
actually do: MCP is JSON-RPC 2.0 over a transport, plus three methods that matter —
initialize (handshake and capabilities), tools/list (discovery with JSON-Schema
descriptions), and tools/call (validated invocation). Once that is understood, every
MCP SDK reads as a convenience wrapper, which is what it is.
Related MCP server: toolbox-mcp
What's implemented
Piece | Detail |
Server | Tool registry via decorator, JSON-RPC dispatch, correct error codes (-32700 parse, -32600 invalid request, -32601 method not found, -32602 invalid params, -32603 internal) |
Schema validation | Minimal JSON-Schema subset (type, required, properties), written not imported |
Client | Spawns any stdio MCP server, handshakes, discovers, calls |
Demo server | Three deterministic tools, so the loop runs offline |
Scope is deliberate: resources, prompts, sampling and notifications are out. The tools subset is the part agents live on, and a complete small thing beats an incomplete big one.
Design decisions worth arguing with
Transport-agnostic server. handle_line maps one request string to one response
string. The same server runs over stdio, a socket, or a unit test calling it
directly — which is why the protocol tests need no subprocess and never flake.
Unknown tool arguments are rejected, not ignored. A tool receiving parameters it never declared is a bug on its way to production. Strictness here is what makes agent tool-calling debuggable.
Tool exceptions become protocol errors, not crashes. A buggy tool must not take
down the server or the session; the client gets -32603 with the message, and the
loop continues.
bool is not an integer. Python's bool subclasses int, so naive validators
accept True where a count belongs. This one doesn't, and a test pins it.
Testing
PYTHONPATH=src python3 -m pytest tests -qCovers the handshake, discovery, valid and invalid calls, every JSON-RPC error code, and one end-to-end test running the real client against the real server as a subprocess.
Licence
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
AI Reasoning Cache & Consensus Layer with 11 MCP tools via Streamable HTTP.
x402-paid agent tools: 18 over HTTP, 14 over stdio. USDC per call, no API key.
A Model Context Protocol server for Wix AI tools
Enable secure connectivity between Sentry issues and debugging data, and LLM clients, using a Model Context Protocol (MCP) server.
Related MCP Servers
- AlicenseAqualityCmaintenanceExposes a verified tool registry (calculator, sandboxed file read, web fetch) over MCP stdio, enabling any MCP-capable client to reuse the same tools from the inspectable ReAct loop.3MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI hosts to call deterministic tools such as echo, add, reverse, read/write files, and a C++-implemented two_sum via the MCP stdio interface.2Apache 2.0
- FlicenseNot gradedqualityCmaintenanceEnables local text analysis, statistical calculations, and system information retrieval via the Model Context Protocol over stdio.-
- AlicenseNot gradedqualityCmaintenanceEnables registering custom agent tools via a minimal JSON-RPC over stdio implementation, with zero external dependencies, to expose them to AI agents like Claude, Cursor, and Gemini.MIT