mini-mcp-demo

mini-mcp-demo

Enables local tool calling over Model Context Protocol via stdio, providing deterministic tools such as calc.add, text.word_count, and text.summarize_naive after JSON-RPC handshake and discovery.

Category
Visit Server

README

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.client
connected: mini-mcp-demo protocol 2025-06-18
tools discovered: calc.add, text.word_count, text.summarize_naive
calc.add(2, 40) -> 42
word_count -> 6

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

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 -q

Covers 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

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured