MCP-Demo
mcp-demo
最小限のPython MCPサーバーです。各コミットで1つの概念を学べるように段階的に構築されています。 最終状態:Claude CodeがローカルのOllamaモデル(gemma3:4b / 3:12b)をツールとして呼び出し、重要度の低いタスクをAPIからホームラボへオフロードします。
MCPとは何か?
Model Context Protocol (MCP) は、標準化されたJSON-RPC 2.0プロトコルです。これにより、LLMクライアント(Claude Code、Claude Desktop、Cursor)は、MCPサーバーと呼ばれる別のプロセスからツールを発見・呼び出し、リソースを取得し、プロンプトテンプレートを読み込むことができます。MCPとLLMツールの関係は、LSPとIDEの言語サポートの関係に似ています。つまり、1つのプロトコルで多くの相互運用可能な実装が可能になります。
構成要素
┌───────────────────┐ stdio / HTTP ┌──────────────────┐
│ MCP Client │ ◄──JSON-RPC──► │ MCP Server │
│ (Claude Code) │ │ (this repo) │
└───────────────────┘ └──────────────────┘
│ │
│ spawns as child │ hits
│ process (stdio) │ localhost:11434
▼ ▼
your shell env Ollama / gemma3クライアント — LLMアプリに組み込まれています
サーバー — MCPを話すあらゆるプロセス
トランスポート —
stdio(クライアントがサーバーを子プロセスとして起動し、JSON-RPCをパイプする)またはstreamable-http(サーバーがWebサービスとして動作する)。このリポジトリではstdioを使用します。
MCPサーバーが公開する3つのプリミティブ
プリミティブ | 内容 | このリポジトリでの用途 |
Tools (ツール) | LLMが呼び出せる関数 |
|
Resources (リソース) | クライアントが取得できる読み取り専用のブロブ |
|
Prompts (プロンプト) | 事前に用意されたプロンプトテンプレート | (未使用 — 最小限に維持) |
フェーズの進行
各フェーズは1つのコミットに対応しています。git logで進化の過程を確認できます。
✅ scaffold — pyproject, README, .gitignoreの作成。
✅ hello-world server — 1つの
echoツールとスモークテスト用クライアント。クライアントの起動 → ハンドシェイク → ツールの発見 → ツールの呼び出しという完全なライフサイクルを証明します。✅ ollama_ask tool —
localhost:11434/api/generateにPOSTし、Gemmaの応答を返す非同期ツール。✅ polish —
ollama_askにsystemパラメータを追加し、ollama://models(プル済みのモデル一覧)でリソースを公開します。
インストールと実行
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
# Phase 2+ only: run the server by hand to smoke-test
python -m mcp_demo.serverサーバーは標準入力(stdin)からJSON-RPCを読み取り、標準出力(stdout)に書き込みます。ターミナルで直接実行しても、入力待ちの状態で停止します。これは正常な動作です。実際にデータを供給するのはクライアント(Claude Code)です。
Claude Codeへの登録
~/.claude/settings.json に以下を追加します:
{
"mcpServers": {
"mcp-demo": {
"command": "/home/booty/mcp-demo/.venv/bin/python",
"args": ["-m", "mcp_demo.server"]
}
}
}Claude Codeを再起動してください。ツールは mcp__mcp-demo__<tool_name> として表示されます。
参考文献
Python SDK: https://github.com/modelcontextprotocol/python-sdk
Inspector (あらゆるMCPサーバーを調査するためのデバッグUI):
npx @modelcontextprotocol/inspector
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
MCP server for AI dialogue using various LLM models via AceDataCloud
An MCP server that gives your AI access to the source code and docs of all public github repos
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/SiNBooty/MCP-Demo'
If you have feedback or need assistance with the MCP directory API, please join our Discord server