Skip to main content
Glama

Batch-evaluate OPA policy against input files

opa_exec

Evaluate a policy decision against multiple input files in one call, returning per-file results for CI pipelines; use fail gates to flag any policy failures.

Instructions

Evaluate a policy decision against one or more input files using opa exec --format=json. Unlike rego_eval (single input), opa exec processes every file independently and returns a per-file result -- ideal for CI pipelines that check many config files against a policy in one call. Supply bundle for bundle-based policies or dataPaths for raw policy files; these are mutually exclusive. Each file that fails evaluation appears in results with an error field rather than a result field. Set one of fail/failDefined/failNonEmpty to turn the call into a CI gate: the result then reports failed: true (instead of erroring) when the gate condition is met.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
failNoCI gate: report `failed: true` when any decision is undefined or errors. Mutually exclusive with `failDefined` and `failNonEmpty`.
bundleNoPath to an OPA bundle directory or `.tar.gz` archive to load as the policy source. Mutually exclusive with `dataPaths`.
timeoutNoPer-exec evaluation timeout as a Go duration, e.g. `"30s"` or `"5m"`. Still bounded by the server subprocess timeout (OPA_MCP_TIMEOUT_MS).
decisionYesThe policy entrypoint to evaluate for each input, e.g. `"authz/allow"`. `opa exec` names a decision by slash-separated path with no `data.` prefix; the Rego reference forms (`data.authz.allow`, `authz.allow`) are accepted here and converted, because passing one straight through leaves every file undefined.
dataPathsNoPolicy and/or data file or directory paths, each loaded as an OPA bundle root (opa exec loads policy only via bundles). Mutually exclusive with `bundle`.
inputPathsYesOne or more JSON/YAML input file paths, or a directory containing input files. OPA evaluates each file independently. Every path must be inside an allowed root.
failDefinedNoCI gate: report `failed: true` when any decision is defined or errors. Use when a defined result means a violation. Mutually exclusive with `fail` and `failNonEmpty`.
failNonEmptyNoCI gate: report `failed: true` when any decision result is non-empty or errors. Mutually exclusive with `fail` and `failDefined`.
v1CompatibleNoOpt in to OPA v1.0-compatible behaviors (`--v1-compatible`).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.5.0
    • changedInput schema / properties / decision / description
      Previous value: -"The policy entrypoint to evaluate for each input, e.g. `\"data.authz.allow\"` or `\"data.policy.violations\"`. Must be a fully-qualified Rego reference."New value: +"The policy entrypoint to evaluate for each input, e.g. `\"authz/allow\"`. `opa exec` names a decision by slash-separated path with no `data.` prefix; the Rego reference forms (`data.authz.allow`, `authz.allow`) are accepted here and converted, because passing one straight through leaves every file undefined."
  2. Changed6 schema fields changedv0.1.20
    • changedInput schema / properties / dataPaths / description
      Previous value: -"Policy and/or data file or directory paths to load. Mutually exclusive with `bundle`."New value: +"Policy and/or data file or directory paths, each loaded as an OPA bundle root (opa exec loads policy only via bundles). Mutually exclusive with `bundle`."
    • addedInput schema / properties / fail
      Added value: +{
      +  "description": "CI gate: report `failed: true` when any decision is undefined or errors. Mutually exclusive with `failDefined` and `failNonEmpty`.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / failDefined
      Added value: +{
      +  "description": "CI gate: report `failed: true` when any decision is defined or errors. Use when a defined result means a violation. Mutually exclusive with `fail` and `failNonEmpty`.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / failNonEmpty
      Added value: +{
      +  "description": "CI gate: report `failed: true` when any decision result is non-empty or errors. Mutually exclusive with `fail` and `failDefined`.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / timeout
      Added value: +{
      +  "description": "Per-exec evaluation timeout as a Go duration, e.g. `\"30s\"` or `\"5m\"`. Still bounded by the server subprocess timeout (OPA_MCP_TIMEOUT_MS).",
      +  "type": "string"
      +}
    • addedInput schema / properties / v1Compatible
      Added value: +{
      +  "description": "Opt in to OPA v1.0-compatible behaviors (`--v1-compatible`).",
      +  "type": "boolean"
      +}
  3. Addedv0.1.13

TDQS

A5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond the annotations (readOnlyHint: false, openWorldHint: true), the description discloses key runtime behaviors: each file is evaluated independently, failures appear as error fields instead of result fields, CI gates report failed: true rather than erroring, and the timeout is bounded by the server subprocess. It also flags the decision-name conversion gotcha.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is dense but every sentence earns its place, from the core function to the batch differentiation, input-mode options, per-file error semantics, and CI-gate behavior. It is front-loaded with the most important purpose and alternative-routing information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 9 parameters, no output schema, and complex mutual exclusions, the description covers the key success criteria: when to use it, how policies and inputs are supplied, how failures are represented, how CI gating works, and the decision-name gotcha. The combination of description and schema gives an agent enough context to invoke it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Although schema coverage is 100%, the description adds substantial meaning: bundle and dataPaths are mutually exclusive, fail gates convert results into CI pass/fail signals, and decision accepts Rego reference forms and converts them because passing them straight through leaves every file undefined. These are critical operational details not evident from the schema alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Evaluate a policy decision against one or more input files using opa exec --format=json.' It also explicitly distinguishes itself from rego_eval, which handles a single input, so an agent can unambiguously identify when this tool applies.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It states the ideal context ('ideal for CI pipelines that check many config files against a policy in one call'), names the alternative rego_eval, and explains the conditional selection between bundle and dataPaths. It also clarifies when to enable CI-gate flags (fail/failDefined/failNonEmpty), leaving little to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.