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
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.