Homelab MCP starter
A minimal MCP server for homelab environments, providing demo tools like ping and echo over Streamable HTTP for testing client-server integration.
README
Homelab MCP starter
A minimal, working Model Context Protocol server over Streamable HTTP. It ships with a few demo tools and one resource so you can verify the whole path — client → Cloudflare Tunnel → this server — before you write anything of your own.
What's here
server.py— the server: four demo tools (ping,echo,add,server_info), one resource, a/healthroute, and optional bearer-token auth.requirements.txt,Dockerfile,docker-compose.yml— containerised, with an optional Cloudflare Tunnel sidecar..env.example— every config knob.
1. Run it locally
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # set MCP_AUTH_TOKEN to a random value
export $(grep -v '^#' .env | xargs)
python server.py
Verify in another terminal:
# Health (no auth required)
curl -s http://127.0.0.1:8000/health # -> ok
# MCP handshake (auth required)
curl -s -X POST http://127.0.0.1:8000/mcp \
-H "Authorization: Bearer $MCP_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'
For an interactive view of the tools, point the MCP Inspector at it:
npx @modelcontextprotocol/inspector
# Transport: Streamable HTTP, URL: http://127.0.0.1:8000/mcp
# Add an Authorization header: Bearer <your token>
2. Run it in Docker
cp .env.example .env # fill in MCP_AUTH_TOKEN (and TUNNEL_TOKEN later)
docker compose up -d --build mcp
3. Expose it with Cloudflare Tunnel
Both Claude and ChatGPT connect to your server from their cloud, so it needs a public HTTPS URL. A tunnel gives you that without opening any inbound ports.
-
In the Cloudflare dashboard: Zero Trust → Networks → Tunnels → Create a tunnel. Choose the token install method and copy the tunnel token.
-
Put it in
.envasTUNNEL_TOKEN=.... -
In the tunnel's Public Hostname config, add e.g.
mcp.yourdomain.comand set the service tohttp://mcp:8000(the compose service name). -
Start the sidecar:
docker compose up -d
Your endpoint is now https://mcp.yourdomain.com/mcp.
4. Connect it to Claude and ChatGPT
Same URL in both.
- Claude (Pro/Max/Team/Enterprise): Settings → Connectors → Add custom
connector → paste
https://mcp.yourdomain.com/mcp. - ChatGPT (Plus/Pro/Business/Enterprise/Edu): Settings → Apps → Advanced settings → Developer mode → add the same URL.
5. A note on auth
The bearer token here is real protection and is perfect for curl, the MCP
Inspector, and any code you write. The catch: the consumer connector UIs don't
reliably let you set a custom Authorization header, so for Claude/ChatGPT
specifically you have two clean production options:
- Cloudflare Access in front of the public hostname (simplest for a homelab): gate the hostname with an Access policy. Good for connectors you drive yourself.
- OAuth — the path the connector "Connect" button is built for. FastMCP ships
providers (GitHub, Google, Azure, Auth0, Keycloak, …) under
fastmcp.server.auth.providers; wire one in to replace the bearer middleware.
Until you add one of those, keep MCP_AUTH_TOKEN set and treat the URL as a
secret. Never run with auth disabled on a public hostname.
6. Add your own tools
Replace the demo functions in server.py. The pattern is just a decorated
function — type hints become the input schema, and the docstring is what the
model reads to decide when to call it:
@mcp.tool
def restart_service(name: str) -> str:
"""Restart a systemd service by name on the host. Returns the new status."""
...
Keep descriptions concrete about when to use the tool, validate every input (these run with whatever privileges the container has), and prefer read-only tools until you trust the setup.
Security checklist
- [ ]
MCP_AUTH_TOKENset to a random 32-byte value,.envgit-ignored. - [ ] Public hostname gated by Cloudflare Access or OAuth before exposing write tools.
- [ ] Container runs least-privilege (no host Docker socket, scoped mounts only).
- [ ] Tools validate inputs and avoid shelling out with unsanitised arguments.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。