New Your team’s decisions, in one playbook every coding agent works from. Never answer your agent twice

What is a Policy Rule?

2 min read Updated

A policy rule is a single per-tool entry within a policy document that specifies how calls to that tool are handled — allowed, denied, or hidden — optionally with argument conditions that must be satisfied for a call to proceed.

WHY IT MATTERS

Rules are the atomic unit of policy. Each rule answers a precise question: "When an agent tries to call this tool with these arguments, what should happen?" This granularity is essential because blanket allow/deny decisions are rarely sufficient. You might want to allow an agent to create Stripe charges under £100 but deny charges above that threshold — that requires a rule with a condition, not a binary permission.

Rules follow a match-then-act pattern familiar from firewall rules, iptables, and security group configurations. When a tool call arrives, PolicyLayer looks up the entry for that tool, evaluates its conditions, and applies the outcome. This deterministic evaluation model means you can reason about policy behaviour without running the system — critical for security review and compliance.

The expressiveness of rules comes from combining per-tool entries with argument conditions. A rule can target a single tool by name, or every tool on the server through the all-tools section. Conditions in require and deny_if can compare argument values against literals, check types, validate string patterns, and enforce numerical bounds. This covers the vast majority of real-world policy requirements without requiring a full programming language.

Policy Rule isn't theory — define it as policy in PolicyLayer and it's enforced on every tool call.

ENFORCE THIS WITH POLICY →

Enforced before the call runs. Nothing to install.

HOW POLICYLAYER USES THIS

In PolicyLayer, each rule is a per-tool entry within the policy JSON document, specifying conditions the call's arguments must satisfy (require), conditions that deny the call (deny_if), and quota limits (limits). Tools can also be hidden entirely, and a document-level default of allow or deny covers any tool without an entry. Rules are authored in the dashboard's visual policy builder — each tool gets Allow, Deny, Hide, or Custom — with a Raw JSON view for inspecting the exact document.

FREQUENTLY ASKED QUESTIONS

What happens if no rule matches a tool call?
The policy's default applies. With default deny (recommended for production), any tool without its own entry is denied; with default allow, it is allowed. A grant with no policy attached at all denies every call.
Can one rule cover many tools at once?
Yes. The all-tools section applies limits across every tool on a server, the policy default (allow or deny) covers any tool without its own entry, and the hide list removes tools from the agent's view entirely. This simplifies policies for servers with many tools.
How do I debug which rule matched a tool call?
PolicyLayer's decision log records which rule matched, what conditions were evaluated, and the resulting action for every tool call. This makes it straightforward to trace policy decisions during development and in production.

FURTHER READING

// THE REGISTRY

Every MCP server your agents touch has a registry record.

Type a name, get the breakdown: verified identity, auth posture, risk grade, every tool classified, recommended policy. Re-checked continuously.

Teams ship this data inside their own products. See what a licence covers →

Take your agents live. Without losing control.

Route your MCP traffic through PolicyLayer. Every tool call is checked against your policy before it runs: allow, deny, or require approval. Per-identity grants. Full audit log. Live in minutes.

Instant setup, no code required.

46,500+ MCP servers and 515,000+ tools scanned and risk-classified.

// GET IN TOUCH

Have a question or want to learn more? Send us a message.

Message sent.

We'll get back to you soon.