Skip to main content
Glama
safe-runbook-mcp

safe-runbook-mcp

safe-runbook-mcp

運用ランブックのためのポリシーゲート付きMCPサーバー。AIが既知のコマンドを検査・実行できるようにしつつ、無制限のシェルは与えません。

存在理由

AIエージェントは運用に有用ですが、ターミナルを渡すことは大きな信頼の判断です。このプロジェクトは、有用な部分(反復可能な診断とメンテナンス)を、小さくレビュー可能な境界内に保ちます:

AIクライアント → プラン検査 → ポリシーチェック → 任意の人間による承認 → 正確なコマンド

Related MCP server: govmcp

安全モデル

  • ランブックはバージョン管理されたJSONです。AIがコマンドを発明することはできません。

  • 実行はデフォルトで無効です。

  • 実行可能ファイルは明示的に許可リストに登録する必要があります。

  • 変数は正規表現で検証され、完全なプロセス引数になります。

  • コマンドはrealpathで制限されたワークスペース内でshell: falseで実行されます。

  • 変更・破壊的なプランには、MCPの外部で作成された短命のHMAC承認トークンが必要です。

  • トークンはランブックと正確なプランハッシュに紐付けられるため、入力が変わると無効になります。

  • プロセスには時間と出力の制限があり、宣言されたシークレットは編集されます。

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

変更を伴うランブックの場合は、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 — 利用可能なランブックとリスクレベルを発見します。

  • inspect_runbook — 変数を解決し、正確なプランとそのハッシュを返します。

  • execute_runbook — ポリシーチェック後に、すでに定義されたプランを実行します。

  • runbook://catalog — 読み取り専用のカタログリソース。

ログはstderrに出力されます。stdoutはMCP JSON-RPCトラフィック用に予約されているためです。

ランブックを追加する

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

読み取り専用マウントでは実行を無効にしておきます。ランブックがDockerを必要とする場合は、その信頼境界を確認した上で、必要なソケットまたはリモートコンテキストのみをマウントします。

開発

npm run check
npm run typecheck
npm test
npm run build

ブランチワークフローについてはCONTRIBUTING.mdを、コーディングエージェントが使用するリポジトリルールについてはAGENTS.mdを参照してください。

参考

ライセンス

MIT

Available Tools

3 tools
execute_runbookExecute an approved runbookA
Destructive

Execute only commands declared in a version-controlled runbook. Requires the global execution gate; mutating plans also require an out-of-band approval token.

Inputs: id (required), variables, approvalToken.

inspect_runbookInspect a resolved runbook planA
Read-onlyIdempotent

Validate variables and return the exact commands, plan hash, risk, and approval requirement without executing.

Inputs: id (required), variables.

list_runbooksList safe runbooksA
Read-onlyIdempotent

List version-controlled runbooks and their risk levels. Does not execute anything.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: inspect validates and previews, execute runs commands, and list enumerates available runbooks. There is no overlap or ambiguity between them.

    Naming Consistency5/5

    All three tool names follow a consistent verb_noun pattern: inspect, execute, and list all pair with 'runbook'. The naming is uniform and predictable.

    Tool Count4/5

    With only three tools, the server is lean but covers the essential operations for runbook management: discover, preview, and execute. It is slightly minimal but appropriate for a focused purpose.

    Completeness4/5

    The server provides the core lifecycle for runbooks: list, inspect, and execute. Missing are update/delete operations, but since runbooks are version-controlled externally, those may be intentionally out of scope. No critical gaps for safe execution.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables controlled AI-agent access to enterprise-shaped tools with a deny-by-default gated write path, human approval, dry-run execution, and append-only audit logging.
      1
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to operate a simulated IT operations environment through policy-enforced, risk-tiered tool calls with human approval for risky writes, dry-run previews, rate limits, emergency lockdown, and tamper-evident auditing.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants to safely interact with operations systems such as cloud inventory, runbooks, and ticketing while enforcing role-based access, JWT authentication, write confirmation, secret and PII redaction, rate limits, and audit logging.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to perform safe, auditable Kubernetes write actions such as scaling, restarting and rolling back Deployments through a plan → policy-check → approve → apply → audit flow, with server-side guards, single-use plans and scoped RBAC. Read-only planning and Prometheus SLO/alert tools support the same guarded workflow.
      Apache 2.0