MCP-Demo
A minimal Python MCP server that enables Claude Code to call local Ollama models (e.g., gemma3) as a tool, routing low-stakes work off the API and onto a homelab.
README
mcp-demo
A minimal Python MCP server, built in phases so each commit teaches one concept. End state: Claude Code can call local Ollama models (gemma3:4b / 3:12b) as a tool, routing low-stakes work off the API and onto the homelab.
What is MCP, really?
Model Context Protocol is a standardized JSON-RPC 2.0 protocol that lets an LLM client (Claude Code, Claude Desktop, Cursor) discover and invoke tools, fetch resources, and load prompt templates from separate processes called MCP servers. MCP is to LLM tooling what LSP is to IDE language support: one protocol, many interoperable implementations.
The moving pieces
┌───────────────────┐ 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
- Client — embedded in the LLM app
- Server — any process that speaks MCP
- Transport —
stdio(client spawns server as child, pipes JSON-RPC) orstreamable-http(server is a web service). This repo uses stdio.
Three primitives an MCP server exposes
| Primitive | What it is | This repo's use |
|---|---|---|
| Tools | Functions the LLM can call | echo, ollama_ask, get_weather |
| Resources | Read-only blobs the client can fetch | ollama://models (list pulled models) |
| Prompts | Pre-canned prompt templates | (not used — kept minimal) |
Phase progression
Each phase is one commit — git log shows the evolution.
- ✅ scaffold — pyproject, README, .gitignore.
- ✅ hello-world server — one
echotool + smoke-test client. Proves the full lifecycle: client spawn → handshake → tool discovery → tool call. - ✅ ollama_ask tool — async tool that POSTs to
localhost:11434/api/generateand returns Gemma's reply. - ✅ polish — adds
systemparameter toollama_askand exposes a resource atollama://models(list of pulled models). - ✅ grounding contrast — adds
get_weather(hits NWS api.weather.gov). The point isn't the weather — it's thatollama_askhallucinates current facts whileget_weatherreturns live data. Same MCP primitive (a tool), completely different epistemic status. This is the difference between an LLM guessing and an agent.
Install & run
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
The server reads JSON-RPC off stdin and writes to stdout — if you run it directly in a terminal it will just sit there waiting for input. That's expected. The client (Claude Code) is what actually feeds it.
Registering with Claude Code
MCP servers live in ~/.claude.json (not settings.json — that schema rejects
the mcpServers key). The supported path is the claude CLI:
claude mcp add mcp-demo /home/booty/mcp-demo/.venv/bin/python -- -m mcp_demo.server
That writes an entry like this into ~/.claude.json:
"mcp-demo": {
"type": "stdio",
"command": "/home/booty/mcp-demo/.venv/bin/python",
"args": ["-m", "mcp_demo.server"]
}
Restart Claude Code. Tools appear as mcp__mcp-demo__<tool_name> and the
resource as ollama://models.
Further reading
- Spec: https://modelcontextprotocol.io/specification
- Python SDK: https://github.com/modelcontextprotocol/python-sdk
- Inspector (a debug UI for poking at any MCP server):
npx @modelcontextprotocol/inspector
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。