Tool risk in the MCP gateway
An MCP server can say a little about each of its tools: that one only reads, that another may destroy something. Both MCP gateways read what the server says, grade each tool, and record the grade with every call. A rule can then act on the grade, so you do not have to list a server's tools one by one.
The grade is the server's own word. Read What the grade is worth before you rely on it.
What the gateway reads
When an agent asks a server for its tools (tools/list), the answer passes through the gateway unchanged. As it passes, the gateway keeps two things for each tool:
- The hints. MCP calls them annotations. The gateway reads
readOnlyHintanddestructiveHint. - A hash of the definition. It covers the tool's description, its input schema and its hints.
Nothing else in the answer is kept, and nothing is sent to the engine at this point.
The grade
| What the server said | risk |
|---|---|
destructiveHint is true | destructive |
readOnlyHint is true | read |
readOnlyHint is false, or destructiveHint is false | write |
| Neither hint | unknown |
| The tool was never in a list the gateway saw | unknown |
A tool marked both read only and destructive is graded destructive.
The MCP specification says a missing destructiveHint should be read as true. The gateway does not do that. Most servers give no hints at all, and every one of their tools would be graded destructive. A tool with no hints is unknown.
The facts on each call
| Fact | Example | Meaning |
|---|---|---|
risk | write | The grade. Always present on a call through a gateway. |
risk_source | server | server when the grade came from a hint. none when there was no hint or the tool was never listed. |
tool_hash | 9f2c41d07ab35e16 | The first 16 characters of the hash of the definition. Absent when the tool was never listed. |
tool_changed | 1 | Present when the definition differs from the one this gateway saw before. |
They are part of what the agent signs, so each receipt shows what the grade was when the call was decided.
Rules to start from
None of these is switched on for you. Add the ones you want in Policy. Before you sign, the Policy page shows what the new rules would have decided for recent actions. See Check a rule against history. Calls recorded by a gateway older than this feature carry no risk fact, so run the updated gateway for a while first and then look. GET /v1/starter returns the same three rules under gateway.
{"id": "mcp-destructive-blocked", "effect": "deny", "when": "action.attrs.risk == 'destructive'", "reason": "The server marks this tool destructive."}
{"id": "mcp-changed-needs-human", "effect": "escalate", "when": "action.attrs.tool_changed == '1'", "reason": "This tool's definition changed since it was last seen."}
{"id": "mcp-write-needs-human", "effect": "escalate", "when": "action.attrs.risk == 'write' || action.attrs.risk == 'unknown'", "reason": "The server does not mark this tool read only."}
Rules are tried in order and the first match decides, so keep them in this order. A tool with risk of read matches none of them and is decided by the rest of your policy.
An action that did not come through a gateway carries no risk fact and matches none of these rules.
To overrule a grade for one tool, put a rule on its name above these:
{"id": "refunds-are-fine", "effect": "allow", "when": "action.tool == 'mcp__crm__refund' && action.attrs.tool_changed != '1'", "reason": "refunds are within the passport's limits"}
With the third rule on, an agent's first call waits for a person if the agent has not yet asked the server for its tools through this gateway. Most agents ask when they connect.
A definition that changes
A server can change what a tool says about itself after you have looked at it: new words in the description that steer the agent, or a hint that turns a destructive tool into a read only one. The gateway keeps the hash of each definition in ~/.countersign/gateway/ on the machine it runs on. When a later list gives a different hash, every call to that tool carries tool_changed until the gateway is started again.
- The first time a tool is seen there is nothing to compare with, so it is not flagged.
- After a restart the new definition is the known one. Restarting the gateway is how you accept a change.
- To hold a tool to one definition for good, write a rule on its hash:
action.tool == 'mcp__crm__refund' && action.attrs.tool_hash != '9f2c41d07ab35e16'. - The description itself is not recorded. The receipt shows that the definition changed, and its hash, and not the old or new words.
What the grade is worth
- A hint is a claim by the server. A server can mark a tool that deletes things as read only, and the gateway cannot tell. The MCP specification says the same: hints from a server you do not trust should not be used to decide. These rules are a sensible default for servers you already trust. They are no defence against a server that lies.
- A read only tool can still leak. Reading a customer record and sending it somewhere are two different risks. The grade only speaks to the first.
- The change flag catches a change, not a bad definition. A tool that was hostile the first time it was seen is never flagged.
- One list per server. The remote gateway keeps one set of definitions for the server it stands in front of. A server that shows different callers different definitions of the same tool will raise the change flag again and again.
- Hooks do not have this. An agent connected by a hook calls MCP tools directly, and the hook does not see the server's list. Those calls carry no
riskfact. - A list the gateway cannot read is not used. The remote gateway reads answers up to 8 MB. Past that, tools stay
unknown.
What has been checked
- The grading table, the hash, paging and the change flag across a restart are covered by tests (
cmd/countersign/toolrisk_test.go). - Both gateways were run in tests against a real engine and a stand-in MCP server: a call before any list, a read only tool, a tool that writes, a tool with no hint, a destructive tool, and for the remote gateway a tool whose description changed. The ledger was verified offline afterwards.
- The hint names were read from the MCP schema, revisions 2025-06-18 and 2026-07-28, on 27 November 2026.
Not checked: a real MCP server that sends hints, a real agent behind the gateway with these rules on, a server that answers tools/list as an event stream, and a list long enough to arrive in pages from a real server.