safe-runbook-mcp
Enables AI agents to safely inspect and execute version-controlled operational runbooks with policy checks, dry-run planning, and out-of-band approvals.
README
safe-runbook-mcp
A policy-gated MCP server for operational runbooks. It lets an AI inspect and run known commands without giving it an unrestricted shell.
Why it exists
AI agents are useful for operations, but handing one a terminal is a large trust decision. This project keeps the useful part—repeatable diagnostics and maintenance—inside a small, reviewable boundary:
AI client → inspect plan → policy checks → optional human approval → exact command
Safety model
- Runbooks are version-controlled JSON; the AI cannot invent a command.
- Execution is off by default.
- Executables must be explicitly allowlisted.
- Variables are regex-validated and become complete process arguments.
- Commands run with
shell: falseinside a realpath-confined workspace. - Mutating and destructive plans require a short-lived HMAC approval token created outside MCP.
- The token is bound to the runbook and exact plan hash, so changed inputs invalidate it.
- Processes have time and output limits; declared secrets are redacted.
MCP tool annotations are also provided for clients, while server-side checks remain the authority.
Stack
TypeScript 7, Node.js 22, MCP TypeScript SDK v2, Zod 4, Vitest 4, Biome 2, Docker, and GitHub Actions. The project is open source and has no paid API dependency.
Quick start
npm install
npm run cli -- list
npm run cli -- plan docker-service-status --var service=api
npm test
Execution must be enabled explicitly:
RUNBOOK_EXECUTION_ENABLED=true npm run cli -- run disk-usage
For a mutating runbook, generate approval outside the MCP connection and use the same variables for approval and execution:
export RUNBOOK_EXECUTION_ENABLED=true
export RUNBOOK_APPROVAL_SECRET='replace-with-a-long-random-secret'
TOKEN=$(npm run --silent cli -- approve restart-compose-service --var service=api)
npm run cli -- run restart-compose-service --var service=api --approval "$TOKEN"
Connect an MCP client
Build once, then add this stdio server to an MCP-compatible client. Replace the paths with absolute paths on your machine.
{
"mcpServers": {
"safe-runbooks": {
"command": "node",
"args": ["/absolute/path/safe-runbook-mcp/dist/server.js"],
"env": {
"RUNBOOK_DIRECTORY": "/absolute/path/safe-runbook-mcp/runbooks",
"RUNBOOK_WORKSPACE": "/workspace/to/manage",
"RUNBOOK_EXECUTION_ENABLED": "false"
}
}
}
}
The server exposes:
list_runbooks— discover available runbooks and risk levels.inspect_runbook— resolve variables and return the exact plan plus its hash.execute_runbook— execute the already-defined plan after policy checks.runbook://catalog— read-only catalog resource.
Logs go to stderr because stdout is reserved for MCP JSON-RPC traffic.
Add a runbook
Create a JSON file in runbooks/:
{
"id": "service-status",
"title": "Inspect a service",
"description": "Read one Compose service state.",
"risk": "diagnostic",
"variables": {
"service": {
"description": "Compose service name",
"pattern": "[a-zA-Z0-9][a-zA-Z0-9_-]{0,62}",
"required": true
}
},
"steps": [
{
"id": "status",
"title": "Read status",
"executable": "docker",
"args": ["compose", "ps", "{{service}}"]
}
]
}
Choose diagnostic, mutating, or destructive. Variables must occupy a complete argument such as "{{service}}"; string interpolation is intentionally rejected.
Docker
docker build -t safe-runbook-mcp .
docker run --rm -i \
-v "$PWD:/workspace:ro" \
-e RUNBOOK_WORKSPACE=/workspace \
-e RUNBOOK_DIRECTORY=/app/runbooks \
safe-runbook-mcp
Keep execution disabled for a read-only mount. If a runbook needs Docker, mount only the required socket or remote context after reviewing that trust boundary.
Development
npm run check
npm run typecheck
npm test
npm run build
See CONTRIBUTING.md for the branch workflow and AGENTS.md for repository rules used by coding agents.
References
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.
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.
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.
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.