Skip to main content
Glama

mini-mcp

MCP (Model Context Protocol)は、第一原理から約200行の読みやすいコードで実装されている。 サーバー、クライアント、そしてそれらの間のJSON-RPCメカニズム—すべてのエージェント統合が依存するツール呼び出しの中核であり、一気に読めるほど小さい。

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

SDKが存在するのに、なぜこれを構築するのか

フレームワークはプロトコルを隠す。そして隠されたプロトコルは、統合を配線できてもデバッグできないエンジニアを生み出す。コアを実装することで、SDKが実際に何をしているのかが分かる。MCPはトランスポート上のJSON-RPC 2.0であり、重要な3つのメソッド——initialize(ハンドシェイクと機能)、tools/list(JSON-Schema記述による発見)、tools/call(検証付き呼び出し)——を備えている。それを理解すれば、すべてのMCP SDKは便利なラッパーとして読める。実際、その通りである。

Related MCP server: mcp-anvil-lite

実装内容

構成要素

詳細

サーバー

デコレータによるツール登録、JSON-RPCディスパッチ、正しいエラーコード(-32700 パースエラー、-32600 無効なリクエスト、-32601 メソッドが見つからない、-32602 無効なパラメータ、-32603 内部エラー)

スキーマ検証

最小限のJSON-Schemaサブセット(type、required、properties)。インポートではなく自作

クライアント

任意のstdio MCPサーバーを起動し、ハンドシェイク、検出、呼び出しを行う

デモサーバー

3つの決定論的なツールを備え、ループをオフラインで実行できる

スコープは意図的に絞られている。リソース、プロンプト、サンプリング、通知は対象外である。ツールのサブセットはエージェントが依存する部分であり、完全な小さなものは、不完全な大きなものに勝る。

議論に値する設計判断

トランスポートに依存しないサーバー。 handle_line は1つのリクエスト文字列を1つのレスポンス文字列にマッピングする。同じサーバーがstdio、ソケット、またはそれを直接呼び出す単体テスト上で動作する—そのため、プロトコルテストはサブプロセスを必要とせず、決して不安定にならない。

未知のツール引数は無視されず、拒否される。 宣言していないパラメータを受け取るツールは、本番環境に向かう途中のバグである。ここでの厳格さこそが、エージェントのツール呼び出しをデバッグ可能にする。

ツールの例外はクラッシュではなくプロトコルエラーになる。 バグのあるツールはサーバーやセッションをダウンさせてはならない。クライアントはメッセージ付きの -32603 を受け取り、ループは継続する。

boolinteger ではない。 Pythonの boolint のサブクラスであるため、素朴なバリデータはカウントが入るべき場所で True を受け入れてしまう。これはそれを受け入れず、テストがそれを固定している。

テスト

PYTHONPATH=src python3 -m pytest tests -q

ハンドシェイク、検出、有効な呼び出しと無効な呼び出し、すべてのJSON-RPCエラーコード、そして実際のクライアントを実際のサーバーに対してサブプロセスとして実行する1つのエンドツーエンドテストをカバーする。

ライセンス

MIT

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    A minimal Model Context Protocol server that provides basic utility tools including mathematical operations, text processing, hashing, and JSON validation. Implements JSON-RPC stdio transport for local testing and development.
  • F
    license
    A
    quality
    C
    maintenance
    A minimal starting point for a Model Context Protocol server with stdio transport and one tool, enabling quick setup and custom tool addition.
    1
  • A
    license
    A
    quality
    C
    maintenance
    Minimal typed scaffold for a local Model Context Protocol stdio server, providing echo and server_status tools.
    2
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Exposes 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.
    3
    MIT

View all related MCP servers

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

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/harshadkhetpal/mini-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server