Note: This is a user-friendly guide to writing AIP policies. For the formal specification, see AIP v1alpha1.Complete reference for AIP policy YAML files (
agent.yaml).
Table of Contents
Overview
AIP policies are declarative YAML files that define what tools an agent can use and under what conditions. The policy is loaded at proxy startup and evaluated for everytools/call request.
Design principle: Default deny. If a tool is not explicitly allowed, it’s blocked.
Schema
Metadata
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique identifier for this policy |
version | string | No | Semantic version (e.g., “1.0.0”) |
owner | string | No | Contact email for policy questions |
signature | string | No | Ed25519 signature for policy integrity (v1alpha2) |
Spec Fields
mode
Controls whether policy violations are enforced or just logged.| Value | Behavior |
|---|---|
enforce | Block violations, return JSON-RPC error (default) |
monitor | Log violations but allow through (dry-run) |
allowed_tools
Allowlist of tool names that the agent can invoke. Tool names must exactly match what the MCP server reports.tool_rules with action: allow, it will be blocked.
Tool Rules
Fine-grained control over individual tools. Each rule can specify an action and argument validation.Structure
Actions
| Action | Description |
|---|---|
allow | Permit the tool call (subject to allow_args validation) |
block | Deny unconditionally |
ask | Prompt user via native OS dialog for approval |
Block Action
Explicitly deny a tool:Ask Action (Human-in-the-Loop)
Require user approval for sensitive operations:- Native OS dialog appears: “Allow tool ‘run_training’?”
- User clicks “Allow” or “Deny”
- If no response in 60 seconds: auto-deny
Argument Validation
Useallow_args to validate tool arguments with regex patterns:
- Regex must match the entire argument value (implicit
^...$) - If any
allow_argspattern fails, the request is blocked - Arguments not in
allow_argsare not validated
Rate Limiting
Limit how often a tool can be called:<count>/<period> where period is second, minute, or hour.
When rate limit is exceeded:
- Request is blocked with JSON-RPC error code
-32003 - Audit log records
RATE_LIMITEDevent
Identity Configuration (v1alpha2)
Configure agent identity and session management.Fields
| Field | Type | Default | Description |
|---|---|---|---|
enabled | bool | false | Enable identity features |
token_ttl | duration | "5m" | Token time-to-live |
rotation_interval | duration | "4m" | When to rotate token |
require_token | bool | false | Block requests without valid token |
session_binding | string | "process" | process, policy, or strict |
audience | string | metadata.name | Token audience URI |
Session Binding Modes
| Mode | Description | Use Case |
|---|---|---|
process | Binds to OS process ID | Single-machine, local agents |
policy | Binds to policy hash | Distributed agents sharing policy |
strict | Binds to process + policy + host | High security, non-ephemeral |
Server Configuration (v1alpha2)
Configure the built-in HTTP server for remote validation.Fields
| Field | Type | Default | Description |
|---|---|---|---|
enabled | bool | false | Enable HTTP server |
listen | string | "127.0.0.1:9443" | Bind address |
failover_mode | string | "fail_closed" | fail_closed, fail_open, local_policy |
timeout | duration | "5s" | Validation timeout |
DLP Configuration
Data Loss Prevention scans tool responses for sensitive patterns and redacts matches.Structure
Built-in Pattern Library
Redaction Output
Matched content is replaced with:[REDACTED:<RuleName>]
Examples
Read-Only Policy
GPU/ML Policy
Prompt Injection Defense
Monitor Mode (Testing)
Validation
Policy File Validation
AIP validates policies at startup. Common errors:| Error | Cause | Fix |
|---|---|---|
invalid apiVersion | Wrong API version | Use aip.io/v1alpha1 |
empty allowed_tools | No tools specified | Add tools or tool_rules |
invalid regex in allow_args | Bad regex pattern | Validate regex syntax |
invalid rate_limit format | Wrong rate limit format | Use <N>/<period> |
rotation_interval >= token_ttl | Rotation must happen before expiry | Reduce rotation_interval |
Common Error Codes
| Code | Name | Description |
|---|---|---|
| -32001 | Forbidden | Tool not allowed |
| -32002 | Rate Limited | Too many requests |
| -32008 | Token Required | Missing identity token (v1alpha2) |
| -32009 | Token Invalid | Expired or invalid token (v1alpha2) |
| -32010 | Signature Invalid | Policy signature verification failed (v1alpha2) |
| -32013 | Schema Mismatch | Tool definition changed (v1alpha2) |
Testing Policies
-
Dry run with monitor mode:
-
Check audit logs:
-
Verbose logging:
Best Practices
- Start restrictive: Begin with minimal
allowed_tools, expand as needed - Use monitor mode first: Test policies before enforcement
- Review audit logs: Regularly check for unexpected tool usage
- Version your policies: Use semantic versioning in metadata
- Document decisions: Add comments explaining why tools are blocked
- Separate policies per agent type: Different agents need different permissions