Natural Language Policies
Tollgate supports defining policies using natural language statements. Write policies in plain English and Tollgate will parse them into structured tool policies.Quick Start
Add apolicies array to your configuration:
Syntax
Natural language policies follow this general structure:Actions
Start your policy with an action verb:| Action | Aliases | Meaning |
|---|---|---|
Allow | Permit, Enable, Grant | Allow automatically |
Deny | Block, Reject, Forbid | Block the operation |
Prompt | Ask, Confirm, Require approval | Ask user for approval |
Risk Levels
Specify which risk level(s) to target:| Level | Aliases | Description |
|---|---|---|
safe | - | No-risk operations |
read | Read-only, Select, Query | Read operations |
write | Insert, Create | Write operations |
destructive | Update, Delete, Modify | Data modification |
dangerous | Drop, Truncate, Admin | High-risk operations |
mutations- write + destructive + dangerousall/any- all risk levelsoperations- contextual, infers from analyzer
Server Targets
Specify which servers the policy applies to:Examples
Database Policies
Filesystem Policies
Shell Policies
HTTP/API Policies
Combining with YAML Policies
Natural language policies merge with explicit YAML policies. YAML policies take precedence for specific rules:How Parsing Works
Tollgate parses natural language policies into structured rules:Analyzer Inference
The parser automatically infers the appropriate analyzer:| Keywords | Inferred Analyzer |
|---|---|
| database, db, queries, sql | sql |
| file, filesystem, path | filesystem |
| shell, command, bash | shell |
| http, fetch, request, api | http |
Partial Policies
When you specify a single risk level, only that level is set in the policy. This allows multiple policies to combine:Validation
Tollgate validates policies during configuration loading:Error Messages
Invalid policies produce helpful error messages:Common Patterns
Read-Only Database Access
Safe Shell Environment
Restrictive Default
Development vs Production
Use environment-specific config files:Best Practices
Start Restrictive
Begin with deny/prompt policies and selectively allow. Safer than allowing by default.
Be Specific
Target specific servers when possible.
"on postgres" is clearer than "on any database".Layer Policies
Use multiple focused policies rather than one complex one. Easier to understand and maintain.
Document Intent
Natural language policies are self-documenting. Write them clearly for future readers.
Limitations
Natural language policies have some limitations:-
Tool-level granularity: NL policies apply to
*(all tools) by default. Use YAML for tool-specific rules. - Simple patterns only: Complex conditions (regex, multiple fields) require YAML policies.
- Server must exist: Policies targeting specific servers require those servers to be defined.
- English only: The parser currently only supports English language policies.