Documentation
¶
Overview ¶
Package policy restricts which tools can be called, and with which arguments.
A policy is an ordered list of rules. The first rule whose tool glob matches and whose optional CEL condition holds decides; when no rule matches, the call is denied.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Default []byte
Default is the policy used when no policy file is given: read-only access.
Functions ¶
This section is empty.
Types ¶
type Policy ¶
type Policy struct {
Rules []Rule `yaml:"rules"`
}
Policy is an ordered list of rules, first match wins, default deny.
func (*Policy) Allowed ¶
Allowed decides a tool call. Conditions failing to evaluate (e.g. a missing argument) fail closed: an allow rule does not match, a deny rule denies.
func (*Policy) Middleware ¶
func (p *Policy) Middleware(next mcp.MethodHandler) mcp.MethodHandler
Middleware enforces the policy on tool calls and hides tools which can never be called.
type Rule ¶
type Rule struct {
// When is a CEL expression over `tool` (string) and `args` (map); empty always matches.
When string `yaml:"when"`
Action Action `yaml:"action"`
Tools []string `yaml:"tools"`
// contains filtered or unexported fields
}
Rule matches tool calls by tool name glob and an optional CEL condition.