Skip to main content
Glama

ops-agent-mcp

An MCP server that lets an AI agent (any MCP client) help with on-call. It can investigate Kubernetes and Prometheus on its own. It can only change something after a human approves that exact change, outside the agent's reach.

This is the pattern I run in production for a team on-call assistant: let the model read everything it needs, keep every write behind a person.

Tools the agent gets

Tool

Kind

What it does

firing_alerts

read

Firing and pending Prometheus alerts, newest first

prometheus_query

read

Instant PromQL, capped at limit series so one broad query cannot flood the context

pod_summary

read

One line per pod: phase, ready, restarts, waiting reason (CrashLoopBackOff, …), node

recent_events

read

Namespace events, newest first

pod_logs

read

Log tail (max 2,000 lines), optionally the previous crashed container

kube_get

read

Objects as JSON from an allowlist of kinds, managedFields stripped. Secrets are never readable

propose_change

propose

rollout_restart or scale, with a required reason. Returns an id and the command a human runs to approve it

change_status

read

Where a proposal stands

apply_change

write

Runs an approved change once. Anything not approved, expired, rejected or already used is refused

There is deliberately no approve tool. Approval lives only in the CLI:

$ ops-agent-mcp pending
3f9a1c2e: rollout_restart(namespace=shop, deployment=api) - workers stuck after config reload [pending]
$ ops-agent-mcp approve 3f9a1c2e
3f9a1c2e: rollout_restart(namespace=shop, deployment=api) - workers stuck after config reload [pending]
approved by istvan

Related MCP server: mimiops-mcp

Guardrails

  • Namespace allowlists for reads (OPS_AGENT_READ_NAMESPACES) and writes (OPS_AGENT_WRITE_NAMESPACES, empty by default, so a fresh install is read-only).

  • Bounded actions: only restart and scale, replicas capped by OPS_AGENT_MAX_REPLICAS.

  • Approvals expire (OPS_AGENT_APPROVAL_TTL, 15 minutes) and run once.

  • Audit log: every tool call, proposal, decision and result goes to audit.jsonl in the state directory (ops-agent-mcp audit).

  • Tool annotations: read tools are marked read-only and apply_change destructive, so MCP clients can ask for confirmation on their side too.

  • Errors come back as {"error": ...} the model can read, not as stack traces.

Run it

pip install .
export KUBECONFIG=~/.kube/config
export OPS_AGENT_PROMETHEUS_URL=http://127.0.0.1:9090
export OPS_AGENT_READ_NAMESPACES=s3-slo-probe,storage,monitoring
export OPS_AGENT_WRITE_NAMESPACES=s3-slo-probe
ops-agent-mcp serve

MCP client config (mcp.json or your client's equivalent):

{
  "mcpServers": {
    "ops": {
      "command": "ops-agent-mcp",
      "args": ["serve"],
      "env": {
        "OPS_AGENT_PROMETHEUS_URL": "http://127.0.0.1:9090",
        "OPS_AGENT_READ_NAMESPACES": "s3-slo-probe,storage,monitoring",
        "OPS_AGENT_WRITE_NAMESPACES": "s3-slo-probe"
      }
    }
  }
}

k8s-platform-lab gives you a cluster with Prometheus and the s3-slo-probe SLO alerts to try it on: break the S3 gateway, then ask the agent why the error budget is burning.

Tests

pip install -e '.[dev]'
pytest -q && ruff check . && mypy src

Run against k8s-platform-lab over a real stdio MCP session, the agent saw the S3ProbeErrorBudgetSlowBurn alert left by an injected S3 outage, read the probe's metrics and pods, was refused Secrets and namespaces outside the allowlist, proposed a restart, was refused until ops-agent-mcp approve ran, restarted the deployment once, and was refused a second time.

The tests cover the guarantees, not only the happy path: no tool can approve, Secrets cannot be read, an approval runs once, approvals expire, rejected changes never run, writes outside the allowlist are refused, and a full propose → human approve (CLI) → apply round trip through the MCP tool interface.

License

MIT

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to safely observe and troubleshoot Kubernetes workloads, with limited recovery actions like pod deletion and Helm rollbacks, while preventing dangerous modifications.
      18
      Apache 2.0
    • 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