Concepts
Policy Engine
Configurable rules for controlling tool access with allow, deny, and confirmation actions.
The policy engine determines whether a tool call should be allowed, denied, or require human confirmation.
In current gateway flow:
- Primary policy source: provider access rules in
provider_access_rules(see MCP Access Control) - Fallback policy source: static config rules in
src/config.ts(used when DB rules are unavailable for a direct policy evaluation path)
Configuration
Default fallback policies are configured in src/config.ts:
const policies = [
{ tool: 'transfer_money', action: 'require_confirmation', risk: 'high' },
{ tool: 'delete_*', action: 'require_confirmation', risk: 'critical' },
{ tool: 'write_*', action: 'require_confirmation', risk: 'medium' },
{ tool: 'read_*', action: 'allow', risk: 'low' },
{ tool: '*', action: 'allow', risk: 'low' },
];Tool names support wildcard matching with *.
Actions
| Action | Behavior |
|---|---|
allow | Request proceeds immediately |
deny | Request is blocked with 403 Forbidden |
require_confirmation | Request is paused until a human confirms via SSE |
Risk Levels
| Risk Level | Description |
|---|---|
low | Read-only operations |
medium | Write operations |
high | Financial or sensitive operations |
critical | Destructive operations |
How It Works
When an MCP tool call arrives at the Gateway:
- The auth middleware authenticates the request (JWT or API key)
- The provider access service checks provider ACL (default deny / whitelist model)
- The tool policy evaluator selects the best matching DB rule for
toolPattern(exact > glob > wildcard, user > agent, deny > require_confirmation > allow) - If there are zero DB rules for that subject/provider evaluation, the config fallback policy from
src/config.tsis used - Based on the final action:
allow: The request is forwarded to the upstream serverdeny: A 403 response is returned immediatelyrequire_confirmation: The request is paused and a confirmation notification is sent via SSE
- After confirmation (or rejection), the request is either forwarded or denied
- The audit service logs the result
See Confirmations for details on the human-in-the-loop confirmation flow.