infra-mcp
MCP server that wraps Docker, Caddy, and GitHub Actions operations on a remote VPS, enabling Claude to take read-then-write-with-confirmation infrastructure actions over SSH with a service allowlist and audit-trail-friendly responses.
README
infra-mcp
MCP server that wraps Docker / Caddy / GitHub Actions ops on a remote VPS. Lets Claude take read-then-write-with-confirmation infra actions over SSH, with a service allowlist and audit-trail-friendly responses.
MCP · FastMCP · Claude Code · Claude Desktop · Docker Compose · Caddy · GitHub Actions · Pydantic v2 · httpx · pytest-asyncio
| Tool | Read/Write | What it does |
|---|---|---|
infra_status |
R | docker compose ps parsed into one row per container |
infra_logs |
R | tail logs from one service with --since + plain-text grep |
infra_disk |
R | df -h / + docker system df for "is there room to rebuild?" |
infra_deploys |
R | last N GitHub Actions runs per configured repo |
service_url |
R | resolves <svc>.<INFRA_PUBLIC_DOMAIN> and probes HTTP status |
infra_restart |
W | restart a compose service (confirm=true + allowlisted) |
caddy_reload |
W | reload Caddy in-place (confirm=true) |
Why this exists
I spent a full afternoon on a single deploy SSH'ing to a VPS, running docker compose logs ..., scrolling, restarting things, re-SSH'ing. Every one of those steps is a tool call this server exposes. Now: "what's broken on <service> in the last 20 minutes?" in Claude Code — done.
This is also the canonical interview answer for "build us an MCP server for internal team operations": an ops surface wrapped as MCP, with three safety layers (allowlist, confirm gate, structured responses).
Safety model
- Read vs write split. Status/logs/disk/deploys/url are always callable. Restart/reload require an explicit
confirm: trueparameter so the model can't trip into a production bounce by accident. - Service allowlist. Write tools cross-check against
INFRA_ALLOWED_SERVICESfrom.env. Anything not listed is rejected even withconfirm=true. Editing the allowlist is a deliberate human action. - No shell injection. Tool inputs are typed (
tail: int,since: strvalidated against a\d+[smhd]shape,grepstrings quoted with single-quote escaping). Commands are assembled from typed params on the server, never from raw MCP-client strings. - Bounded outputs. Logs are clamped to
INFRA_MAX_LOG_LINES(500 by default) so a tool call can't dump 50 MB into the model context. - Hard timeouts. Every SSH invocation runs under
asyncio.wait_forand aConnectTimeout. A wedged container or unreachable box returns an error, not a hang.
Install
git clone https://github.com/odanree/infra-mcp
cd infra-mcp
python -m venv .venv
.venv/Scripts/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
cp .env.example .env # edit ssh host + allowlist + (optional) GH token
Requires the ssh binary on PATH and SSH-key auth already configured for the target host (your normal ~/.ssh/config works).
Register with Claude Code (user-scope)
claude mcp add infra -s user -- "/abs/path/to/infra-mcp/.venv/Scripts/python.exe" -m server.main
claude mcp list # confirms "infra" connected
Restart Claude Code, then try:
"Show me the infra status. Anything not running?"
"Tail logs for the api service since 10m and grep for 'Error'."
"Restart the api service — confirm=true."
Tests
pytest
# SSH is patched at the run() boundary — no network in the test suite.
Roadmap
infra_logsLangfuse export: when a service has Langfuse-traced calls, return a list of recent trace IDs alongside log lines so you can jump straight from a 500 to the trace.service_url+ cert expiry: when the HTTP probe succeeds, also surface days-until-cert-expiry from Caddy's storage.- Per-tool audit-log file on the target so any write action has a permanent local record independent of Claude's chat log.
License
MIT
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。