What is a Policy Rule?

2 min read Updated

A policy rule is a single rule within a policy file that specifies an action (allow, deny, or log) for a specific tool or tool pattern, optionally with argument constraints that must be satisfied for the rule to match.

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, Intercept evaluates rules in priority order, finds the first matching rule, and applies its action. 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 tool patterns with argument conditions. A rule can target a single tool by exact name, a group of tools by glob pattern (e.g. read_*), or all tools on a server. Conditions 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.

HOW POLICYLAYER USES THIS

In Intercept, each rule is a YAML block within a policy file specifying: the tool name or pattern to match, an optional list of conditions on tool arguments, and the action to take (allow, deny, or log). Rules are evaluated in priority order — the first matching rule wins. Intercept's rule engine supports exact matches, glob patterns, comparison operators for numeric and string conditions, and boolean logic for combining multiple conditions.

FREQUENTLY ASKED QUESTIONS

What happens if no rule matches a tool call?
The default action depends on your configuration. In fail-closed mode (recommended for production), unmatched tool calls are denied. In fail-open mode, they are allowed. You can also set an explicit default action in your server-level policy.
Can I use wildcards in tool names?
Yes. Intercept supports glob patterns for tool matching, so a rule targeting 'read_*' would match 'read_file', 'read_database', and any other tool starting with 'read_'. This simplifies policies for servers with many similarly named tools.
How do I debug which rule matched a tool call?
Intercept'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

Enforce policies on every tool call

Intercept is the open-source MCP proxy that enforces YAML policies on AI agent tool calls. No code changes needed.

npx -y @policylayer/intercept
github.com/policylayer/intercept →
// GET IN TOUCH

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

Message sent.

We'll get back to you soon.