Cedar policies for MCP tool calls: rules on what an agent sends
A per-tool grant decides whether an agent may call refund. It can't say how big a refund. Statio now runs every tool call through Cedar policies that can read the call's arguments, the SQL it carries, who is calling and when.
Grants in Statio have always been per tool. You can give a support agent refund and keep delete_customer from it, and that covers most of what goes wrong with MCP. It doesn't cover the agent that is allowed to refund and refunds $6,000 because a ticket asked nicely. The tool name is the same in both calls. Only the arguments differ, and until now nothing in the gateway read them.
Statio now has policies, written in Cedar, the policy language AWS open-sourced. Every call is checked against your organization's policies after the grant check and before it reaches the server.
A policy that caps refunds
forbid (principal, action == Action::"call", resource)
when { resource.server_name == "billing" && resource.name == "refund" }
unless { context.args has amount && context.args.amount <= 50000 }
unless { principal in Team::"<support team id>" };
The policy refuses any refund on the billing server unless the amount is 50,000 cents or less, or the caller is on the support team. An agent asking for 40,000 goes through. At 60,000 it gets a 403 with this message, which a decent agent will pass on:
Statio policy "refund-cap" refused this call to 'refund'
The call log records the refusal and the name of every policy that refused, so whoever reviews it later knows which rule to read.
The has amount guard matters. Tools take different arguments, so context.args is an open record, and reading a field that isn't there is an error in Cedar. The editor warns about an unguarded read before you save.
Policies can only take access away
Statio accepts forbid policies and refuses to save a permit. Grants still decide who may call a tool, and a policy can only narrow that. I made this choice so a policy can never widen access past what an admin granted on the Permissions page.
The other decision is about errors. Cedar skips a policy that errors while evaluating. For a permit that's safe. For a forbid it means a broken rule lets the call through, which is the opposite of what you wrote it for. Statio refuses the call when any enforced policy errors, and it denies too when policies or the caller's teams can't be loaded. The log says which policy failed, so the fix is usually a missing has guard.
Every call gets a decision record
Policies needed something underneath them first. Before this release, a refused call was logged as STATIO_403 and nothing else. Now every call is recorded with what Statio decided (allow, deny, would deny or approval required), which check refused it if one did (the grant, a policy, the security scan, the plan limit), the reason the caller was told, the policies that matched, and the call's arguments.
The arguments are redacted before they're stored. Secret patterns are masked, keys named like credentials are dropped, and long strings are cut. Only an org admin or the person who made the call can read them, and they never go out in the activity feed or in webhooks. This record is what replay and approvals below are built on.
Each decision takes about 380 nanoseconds. Policy changes reach the gateway within 15 seconds, because it caches an organization's policies for that long.
What a policy can read
Statio publishes the schema its requests follow. You can download it from the Policies page, and the editor checks against it. A policy sees:
- The caller: a person, an agent or a service, its teams, and for an agent the person accountable for it.
- The tool: its name and its server.
- The call: its arguments, the time in UTC (hour, minute, weekday), the MCP session and the caller's IP.
- The SQL, on database servers.
SQL rules on database servers
A database MCP server has one tool that matters, and its argument is a string of SQL. A grant on query can't tell SELECT from DROP TABLE. So on servers that declare which argument holds SQL, the gateway parses it before any policy runs. Postgres goes through the real Postgres parser and MySQL through the TiDB parser. The policy gets the statement kinds, the tables read and written, what gets dropped, the functions called, and whether an UPDATE or DELETE has a WHERE.
The parse walks the whole statement. A DELETE hidden inside a CTE still counts as a delete, and a MySQL multi-table delete resolves its aliases to real table names. SQL the parser can't read refuses the call. This is the Deletion protection template:
forbid (principal, action == Action::"call", resource)
when { context has sql && (!context.sql.parsed ||
context.sql.kinds.containsAny(["delete", "truncate"]) ||
context.sql.drops.containsAny(["table", "schema", "database", "column"])) };
Inserts, updates and ADD COLUMN still work. Statio's own database server, statio-sql, also runs reads in a read-only transaction, so the database refuses a write even if a policy lets one through. Postgres and MySQL catalog entries built on it are on their way into the catalog.
Templates
You don't have to write Cedar. The Policies page leads with two templates that need no answers, Block DROP TABLE and Deletion protection, and applies either one in a click. The others ask a few questions and write the Cedar for you:
| Template | What it refuses |
|---|---|
| Argument rule | A tool call whose argument fails a condition, such as amount at most 50000 |
| Only listed tools | Every tool on a server except the ones you list, including tools the server adds later |
| No deletes | Tools named like delete, remove, destroy, drop or purge |
| Business hours | Calls outside a UTC window, and on weekends unless you turn that off |
| Read-only database | Any SQL statement kind you didn't allow |
| Protected tables | Writes to named tables, or any access to them |
| SQL guardrails | Unfiltered writes, stacked statements, reads over a LIMIT, and functions such as pg_sleep and lo_import |
| Approval required | Nothing outright. It holds matching calls for a person to approve |
Every template except Approval required can exempt a team. The Cedar is always visible, and Customize opens it in the editor.
"Only listed tools" is the one I'd apply first to any server with a long tool list. I counted 302 tools that change something across 18 popular servers, and servers add tools between versions. A default-deny list keeps a new write tool off until someone decides to allow it.
Approvals in Slack
Some calls should happen, but not without a person seeing them first. Mark a policy with @approval and a matching call is held instead of refused:
@approval("admins")
forbid (principal, action == Action::"call", resource)
when { context has sql && (!context.sql.parsed ||
!["select", "explain", "show"].containsAll(context.sql.kinds)) };
The agent is told the call is waiting and to retry it once approved. The request shows up on the Approvals page and, if you've connected the Statio approvals bot, in a Slack channel you pick. The approver can't be the person who made the request or the person accountable for the agent. Once approved, the same call with the same arguments goes through once within 15 minutes. A changed argument is a new request. A request nobody answers expires after 24 hours.
Test a policy before it refuses anything
A policy you write in the editor or push from the CLI starts in dry run. Applying a template saves it enforced. A dry-run match lets the call through and logs it as would_deny, so you can watch a policy for a week before it refuses anything.
You don't have to wait for traffic, either. The editor's "Try it before saving" panel runs a draft against a call you describe, or one from your log, and shows which lines matched. Replay history answers "would this have blocked anything last week?". It runs the draft over up to 30 days of logged calls, the newest 5,000, and counts what it would have refused. The count that matters is newly refused: calls that went through at the time and wouldn't under the draft. That's what breaks when you switch to enforce.
Replay depends on what the log kept. If an argument was cut for size or a secret in it was masked, replay flags that call as inexact.
Every save writes a version. History shows a diff, and Restore writes the old policy back as a new version, so a rollback can be undone too.
Policies in Git
Security teams don't want rules that only exist in a web form. mcphub policy keeps them as files, one .cedar file per policy, with settings in header comments:
// statio:mode dry_run
// statio:description Refunds over $500 need the support team
forbid (principal, action == Action::"call", resource)
when { resource.server_name == "billing" && resource.name == "refund" }
unless { context.args has amount && context.args.amount <= 50000 }
unless { principal in Team::"<support team id>" };
mcphub policy pull policies/
mcphub policy validate policies/
mcphub policy push policies/ --dry-run
validate prints file:line:col errors and exits 1, so it can gate a pull request. push reports each policy as created, updated or unchanged, and --prune deletes policies that aren't in the directory. It authenticates with STATIO_API_KEY.
Policies are on every plan. Anyone with the Developer role can read and test them, and admins write them. Each write lands in the audit log with the old and new source.
Questions
Write your first policy in dry run. Three servers and 10,000 calls a month, free, with no card.