safe-runbook-mcp
safe-runbook-mcp
一个基于策略门控的 MCP 服务器,用于运维 runbook。它允许 AI 检查并运行已知命令,而不会给它一个不受限制的 shell。
为什么存在
AI 代理对运维很有用,但把终端交给它是一个很大的信任决定。这个项目将有用的部分——可重复的诊断和维护——保留在一个小而可审查的边界内:
AI 客户端 → 检查计划 → 策略检查 → 可选的人工批准 → 精确命令
Related MCP server: AgentPay MCP Server
安全模型
Runbook 是版本控制的 JSON;AI 不能发明命令。
默认情况下不执行。
可执行文件必须被明确列入白名单。
变量经过正则验证,并成为完整的进程参数。
命令在
shell: false下运行,并限制在 realpath 限定的工作区内。变更性和破坏性计划需要 MCP 之外生成的短期 HMAC 批准令牌。
令牌绑定到 runbook 和精确的计划哈希,因此更改的输入会使它失效。
进程有时间和输出限制;声明的秘密会被编辑。
MCP 工具注解也提供给客户端,而服务器端检查仍然是权威。
技术栈
TypeScript 7、Node.js 22、MCP TypeScript SDK v2、Zod 4、Vitest 4、Biome 2、Docker 和 GitHub Actions。该项目是开源的,没有付费 API 依赖。
快速开始
npm install
npm run cli -- list
npm run cli -- plan docker-service-status --var service=api
npm test必须显式启用执行:
RUNBOOK_EXECUTION_ENABLED=true npm run cli -- run disk-usage对于变更性 runbook,在 MCP 连接之外生成批准,并使用相同的变量进行批准和执行:
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"连接 MCP 客户端
先构建,然后将这个 stdio 服务器添加到兼容 MCP 的客户端。将路径替换为你机器上的绝对路径。
{
"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"
}
}
}
}服务器暴露:
list_runbooks— 发现可用的 runbook 和风险级别。inspect_runbook— 解析变量并返回精确的计划及其哈希。execute_runbook— 在策略检查后执行已定义的计划。runbook://catalog— 只读目录资源。
日志输出到 stderr,因为 stdout 保留给 MCP JSON-RPC 流量。
添加 runbook
在 runbooks/ 中创建一个 JSON 文件:
{
"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}}"]
}
]
}选择 diagnostic、mutating 或 destructive。变量必须占据完整的参数,如 "{{service}}";字符串插值被有意拒绝。
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保持执行禁用,以实现只读挂载。如果 runbook 需要 Docker,在审查该信任边界后,只挂载所需的套接字或远程上下文。
开发
npm run check
npm run typecheck
npm test
npm run build参见 CONTRIBUTING.md 了解分支工作流,以及 AGENTS.md 了解编码代理使用的仓库规则。
参考
许可证
MIT
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityAmaintenanceThe Control Plane for Autonomous AI Enforce policy before execution, require human approvals where risk demands it, and keep a full audit trail — from first action to final result.495
- FlicenseNot gradedqualityAmaintenanceProvides a trust and governance layer for AI agents, enabling secure API access, credential vaulting, paid execution with human approval, and automatic call resume.82
- FlicenseNot gradedqualityAmaintenanceGive AI agents Zero-Trust access to production infrastructure without the risks of granting them shell access. Actions are bounded by policy and an on-host runner.409

AgentsGateofficial
AlicenseNot gradedqualityAmaintenanceEnables AI agents to securely call MCP tools with risk scoring, checkpoints, rollback, and approval workflows.134MIT
Related MCP Connectors
Runtime permission, approval, and audit layer for AI agent tool execution.
Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/PanuwatChinpratan/safe-runbook-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server