Use case

Guarding infrastructure and DevOps agents

Infrastructure agents hold the keys to production. A pre-execution guard checks each terraform, kubectl, cloud CLI or secrets call against the request and the environment before it runs.

2 min readLast updated

Checks run on our GPUs in Switzerland. Request payloads are not stored.Security

In 30 seconds

  • Infra actions often have a production-wide blast radius and cannot be undone quickly.
  • Send the command, the environment and the on-call engineer’s request to the guard.
  • Allow reads and plans; ask on production changes; block destroys that were not requested.
  • Keep plan/apply separation, scoped roles and change windows.

Code and dense tables are folded away. Open any of them on demand.

Example check

While investigating errors, the agent proposed deleting a production namespace.

POST https://api.mcp-guard.ai/v1/guardjson
{
  "action": {
    "tool": "kubectl",
    "args": {
      "command": "delete namespace payments",
      "cluster": "prod-eu"
    }
  },
  "intent": "Investigate the spike in 5xx errors on checkout",
  "trigger": "tool_result",
  "constraints": [
    "No deletes in production without a change ticket"
  ],
  "context": "SRE agent with cluster-admin on prod-eu for acme.test; no change window is open"
}
Show it as a curl command· shell
Terminalbash
curl https://api.mcp-guard.ai/v1/guard \
  -H "Authorization: Bearer $MCP_GUARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action":{"tool":"kubectl","args":{"command":"delete namespace payments","cluster":"prod-eu"}},"intent":"Investigate the spike in 5xx errors on checkout","trigger":"tool_result","constraints":["No deletes in production without a change ticket"],"context":"SRE agent with cluster-admin on prod-eu for acme.test; no change window is open"}'

What can go wrong

Infra and SRE agents run the commands operators run, often with broad credentials:

  • terraform destroy or an apply whose plan removes resources nobody meant to remove.
  • kubectl delete namespace payments while "cleaning up failed pods".
  • Scaling a deployment to zero to "stop the errors".
  • Printing a secret to the log or chat while debugging, or rotating credentials without coordinating.
  • Widening an IAM policy to * to get past a permission error: a classic scope violation.

The agent is usually trying to help. The harm comes from the gap between the task and what the command actually does.

What to send the guard

Check every mutating command, and optionally reads that expose secrets:

  • action: { tool: "kubectl", args: { command: "delete namespace payments", cluster: "prod-eu" } }.
  • intent: the incident or task, e.g. "investigate 5xx errors on checkout".
  • context: the environment (prod or staging), the cluster or account, and the change window.
  • constraints: "no deletes in prod", "never print secrets", "IAM changes need a ticket".
  • trigger: tool_result when the command was proposed after reading logs, alerts or runbooks; log lines can carry injected text too.

Acting on the verdict

By default the server returns block when P(unsafe) is at least 0.8 or the approval_policy head says reject, ask when P(unsafe) is at least 0.3, the policy head says require_human, or args_grounded is below 0.5, and allow otherwise. You can ignore the default verdict and apply your own thresholds to the scores.

For infrastructure, blast_radius and destructive carry most of the weight: a production-mutating action with an external side effect is the category that deserves a human. exfiltration catches secrets heading to a log, chat or external host. violation distinguishes policy violations and goal drift (the agent doing something other than the task). A practical policy: allow reads, terraform plan and kubectl get; ask for any production change; block deletes of namespaces, databases or state when the task did not ask for them.

Controls to keep alongside the guard

  • Separate plan from apply, and require review of applies to production.
  • Give the agent a role that cannot delete stateful resources; enable deletion protection.
  • Keep backups and infrastructure state versioned.
  • Use change windows and a denylist for commands that are never acceptable.

The guard reduces risk in the space that roles and denylists do not cover. It does not replace them, and a production incident is not the time to find out a single layer was all you had.

Frequently asked questions

Does a check slow down incident response?
A check takes about 15 ms on our GPU (RTX 4090, batch 1) plus network round trip. The larger cost is a human prompt, which is why reads should come back as allow.
Should I send secrets in the check?
No. Replace secret values with placeholders. The guard judges the shape of the action, not the secret itself.

Sources

Last updated . MCP Guard reduces the risk of harmful agent actions; it does not guarantee safety. Keep deterministic controls in place alongside it. Third-party names are used only to describe their products; we are not affiliated with them.