MAQPNADocs

ToolPolicy

ToolPolicy (maqpna.com/v1alpha1): every field, type, default and validation rule, generated from the CRD schema.

ToolPolicy is enforced by the MAQPNA gateway on every MCP tool call.

At a glance#

Property Value
API version maqpna.com/v1alpha1
Kind ToolPolicy
Scope Namespaced
Plural toolpolicies
Short names tp
Categories maqpna
Status subresource yes
kubectl get toolpolicies -A
kubectl get tp <name> -o yaml
kubectl explain toolpolicies.spec

Columns in kubectl get#

Column Type From
Default string .spec.defaultAction
Enforcement string .spec.enforcement
Ready string .status.conditions[?(@.type=="Ready")].status
Age date .metadata.creationTimestamp

Example#

From config/samples/toolpolicy-agent-purchases.yaml:

# Agent purchases: govern a shopping or procurement agent's checkout calls.
# Docs: https://docs.maqpna.com/guides/agent-purchases/
#
# The "shop" MCP server stands for any store, marketplace, travel or
# procurement connector. place_order and create_subscription are the tools
# that commit money; their arguments are total.value (a number),
# total.currency, merchant and recurring. Rename them to match your server.
#
# Rules are evaluated in order and the first match wins, so the strictest
# conditions come first. Anything not matched is denied.
apiVersion: maqpna.com/v1alpha1
kind: ToolPolicy
metadata:
  name: shopper-purchases
  namespace: procurement
spec:
  agents: ["shopper", "shopper-*"]
  defaultAction: deny
  toolLabels:
  # Product pages, reviews and search results are written by sellers and
  # strangers: whatever the agent read there must not steer a payment.
  - servers: [web]
    taints: [untrusted-input]
  - servers: [shop]
    tools: ["search_*", "get_product", "list_reviews"]
    taints: [untrusted-input]
  - servers: [shop]
    tools: [place_order, create_subscription]
    sinks: [payment]
  rules:
  - name: browse
    servers: [shop, web]
    tools: ["search_*", "get_*", "list_*", "fetch"]
    action: allow
    maxCallsPerMinute: 120
  - name: approved-merchants-only
    servers: [shop]
    tools: [place_order, create_subscription]
    when:
    - {arg: merchant, op: nin, values: ["acme-office.example", "travel.example", "cloud.example"]}
    action: deny
    reason: Merchant is not on the approved-vendor list.
  - name: usd-only
    servers: [shop]
    tools: [place_order, create_subscription]
    when:
    - {arg: total.currency, op: neq, value: "USD"}
    action: deny
    reason: Agents may only pay in USD.
  - name: amount-required
    servers: [shop]
    tools: [place_order, create_subscription]
    when:
    - {arg: total.value, op: absent}
    action: deny
    reason: An order without a total cannot be checked against the limits.
  - name: large-order-four-eyes
    servers: [shop]
    tools: [place_order, create_subscription]
    when:
    - {arg: total.value, op: gt, value: "1000"}
    action: require_approval
    approval: {minApprovers: 2, approverGroups: [finance]}
    reason: Orders over 1,000 USD need two finance approvers.
  - name: subscriptions-need-finance
    servers: [shop]
    tools: [create_subscription]
    action: require_approval
    approval: {minApprovers: 1, approverGroups: [finance]}
    reason: Recurring charges need a finance approver.
  - name: recurring-orders-need-finance
    servers: [shop]
    tools: [place_order]
    when:
    - {arg: recurring, op: eq, value: "true"}
    action: require_approval
    approval: {minApprovers: 1, approverGroups: [finance]}
    reason: Recurring charges need a finance approver.
  - name: owner-confirms-mid-size
    servers: [shop]
    tools: [place_order]
    when:
    - {arg: total.value, op: gt, value: "100"}
    action: require_approval
    approval: {userConfirmation: ciba}
    reason: The person the agent buys for confirms orders over 100 USD on their own device.
  - name: small-order-after-untrusted-content
    servers: [shop]
    tools: [place_order]
    sessionTaints: {any: [untrusted-input]}
    when:
    - {arg: total.value, op: gt, value: "25"}
    action: require_approval
    approval: {minApprovers: 1, approverGroups: [finance]}
    reason: The agent read seller-written content this session; a person checks orders over 25 USD.
  - name: small-orders
    servers: [shop]
    tools: [place_order]
    action: allow
    maxCallsPerMinute: 2
    reason: Small orders from approved merchants go through, at most two a minute.

From config/samples/toolpolicy-coder.yaml:

apiVersion: maqpna.com/v1alpha1
kind: ToolPolicy
metadata:
  name: coder-policy
  namespace: team-a
spec:
  agents: ["coder", "coder-*"]
  defaultAction: deny
  rules:
  - name: github-read
    servers: [github]
    tools: ["get_*", "list_*", "search_*"]
    action: allow
    maxCallsPerMinute: 120
  - name: github-write-needs-approval
    servers: [github]
    tools: ["create_pull_request", "merge_pull_request"]
    action: require_approval
    reason: Writes to source control require human approval.
  - name: k8s-read
    servers: [kubernetes]
    tools: ["get", "list", "describe", "logs"]
    action: allow
    maxCallsPerMinute: 60
  - name: k8s-no-prod-mutations
    servers: [kubernetes]
    tools: ["apply", "delete", "scale", "patch"]
    argMatch:
      namespace: "prod-*"
    action: deny
    reason: Mutations in production namespaces are forbidden for agents.

Spec fields#

ToolPolicySpec governs which MCP tool calls agents may make.

Field Type Required Description
agents []string agents this policy applies to (globs over agent names).
cedar string cedar is optional Cedar policy text (F-24) evaluated together with rules; the most restrictive decision wins and defaultAction applies only when neither a rule nor a Cedar policy is determining. Schema: config/cedar/maqpna.cedarschema. Gateways built without the Cedar adapter (-tags cedar) deny every call this policy applies to. Max length: 65536.
defaultAction string DefaultAction is the fallback verdict when no rule matches. One of: allow, deny. Default: "deny".
dryRunFallback string dryRunFallback: what a dryRun policy contributes: allow (default) or defaultAction. One of: allow, defaultAction.
enforcement string enforcement: enforce (default) or dryRun. A dryRun policy is evaluated and its would-be decisions are audited (ext.dryRun=true), but it only contributes dryRunFallback to the enforced decision. One of: enforce, dryRun.
rules []object Max items: 256.
rules[].action string yes PolicyAction is the gateway's verdict for a tool call. One of: allow, deny, require_approval.
rules[].approval object approval sets approval requirements (require_approval only).
rules[].approval.approverGroups []string approverGroups whose members may approve (globs). Max items: 16.
rules[].approval.minApprovers integer (int32) minApprovers distinct approvers required (default 1). Minimum: 1. Maximum: 10.
rules[].approval.userConfirmation string userConfirmation "ciba" requires the delegating end user's own confirmation on their device (OpenID CIBA to the customer IdP, F-30) instead of approver votes; approvers may still deny. When CIBA is unavailable the gateway falls back per its ciba.fallback setting. One of: ciba.
rules[].argMatch map[string]string argMatch maps argument JSON paths to glob/regex patterns.
rules[].maxCallsPerMinute integer (int32) maxCallsPerMinute caps the calls matching this rule per session over a sliding 60 s window; further calls are denied with reason rate_limited (0 = unlimited). Rate unit: calls (MCP tools/call, A2A messages; docs/api-conventions.md, "Rates"). Minimum: 0.
rules[].name string yes Min length: 1.
rules[].principals object principals restricts the rule to human principals (policy v2). Rule: at least one of users, groups, notUsers, notGroups is required.
rules[].principals.groups []string Max items: 64.
rules[].principals.notGroups []string Max items: 64.
rules[].principals.notUsers []string Max items: 64.
rules[].principals.users []string Max items: 64.
rules[].reason string
rules[].schedule object schedule restricts when the rule matches. Rule: windows or exceptWindows is required.
rules[].schedule.exceptWindows []string Max items: 32.
rules[].schedule.timezone string timezone is an IANA name (default UTC). Max length: 64.
rules[].schedule.windows []string Max items: 32.
rules[].scopes []string scopes the agent token must all hold (globs in granted scopes apply). Max items: 32.
rules[].servers []string servers (MCP server / tool names, globs allowed).
rules[].sessionTaints object sessionTaints matches the session's taint labels (F-13). Rule: any or all is required.
rules[].sessionTaints.all []string Max items: 16.
rules[].sessionTaints.any []string Max items: 16.
rules[].sinks []string sinks matches tools labelled as exfiltration sinks (toolLabels.sinks); globs allowed. Max items: 16.
rules[].substrate object substrate matches where the session runs, as the identity broker verified it before minting (token claim maqpna_substrate); a session no check ran for has isolation and attestation "none". Rule: substrate needs at least one of isolation, notIsolation, attestation, notAttestation, checks.
rules[].substrate.attestation []string attestation: the rule applies only to these levels. Max items: 3.
rules[].substrate.checks []string checks: the rule applies only to sessions verified by these identity checks (e.g. kosa8). Max items: 8.
rules[].substrate.isolation []string isolation: the rule applies only to these classes. Max items: 7.
rules[].substrate.notAttestation []string notAttestation: the rule does not apply to these levels. Max items: 3.
rules[].substrate.notIsolation []string notIsolation: the rule does not apply to these classes. Max items: 7.
rules[].tools []string tools (MCP tool names, globs allowed).
rules[].when []object when lists typed argument conditions; all must hold. Max items: 32.
rules[].when[].arg string yes arg is a top-level argument name or a dotted path (a.b.c). Min length: 1. Max length: 256.
rules[].when[].op string yes ConditionOperator is a typed argument operator. One of: eq, neq, glob, regex, in, nin, lt, lte, gt, gte, exists, absent, cidr, len_gt, len_lt.
rules[].when[].value string Max length: 1024.
rules[].when[].values []string Min items: 1. Max items: 256.
toolLabels []object toolLabels label tools as taint sources, exfiltration sinks or taint cleaners (F-13). Max items: 64.
toolLabels[].clearTaints []string Max items: 16.
toolLabels[].servers []string Max items: 64.
toolLabels[].sinks []string Max items: 16.
toolLabels[].taints []string Max items: 16.
toolLabels[].tools []string Max items: 256.
toolPins []object toolPins pin MCP tool definitions per server (F-04). Max items: 64.
toolPins[].allowUnpinned boolean allowUnpinned lets tools without a pin through in enforce mode.
toolPins[].mode string mode: off | learn (default: record and audit, never block) | enforce. One of: off, learn, enforce.
toolPins[].onChange string onChange in enforce mode: hide (default: drop from tools/list and deny calls) | approve (require approval) | alert (allow and audit). One of: hide, approve, alert.
toolPins[].pins map[string]string
toolPins[].server string yes server is the MCP server name (as in /mcp/{server}). Min length: 1. Max length: 63.
  • Rule on spec: dryRunFallback requires enforcement dryRun

Status fields#

ToolPolicyStatus is the observed state of a ToolPolicy.

The operator writes status; do not set it yourself.

Field Type Required Description
conditions []object
conditions[].lastTransitionTime string (date-time) yes lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
conditions[].message string yes message is a human readable message indicating details about the transition. This may be an empty string. Max length: 32768.
conditions[].observedGeneration integer (int64) observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. Minimum: 0.
conditions[].reason string yes reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty. Min length: 1. Max length: 1024. Pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$.
conditions[].status string yes status of the condition, one of True, False, Unknown. One of: True, False, Unknown.
conditions[].type string yes type of condition in CamelCase or in foo.example.com/CamelCase. Max length: 316. Pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$.
observedGeneration integer (int64)

Last updated