Skip to main content
Glama

Batch-evaluate OPA policy against input files

opa_exec
Read-onlyIdempotent

Evaluate policy decisions for multiple input files in one call to catch per-file failures in CI pipelines. Set a fail condition to gate CI on undefined, defined, or non-empty results.

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. Dates show when Glama detected each change.

  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

A4.8/5.0
Behavior5/5

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

Although annotations already declare readOnlyHint=true and idempotentHint=true, the description adds substantial behavior beyond that: per-file independent evaluation, error fields instead of result fields for failing files, CI-gate behavior reporting failed: true instead of erroring, and the decision-name normalization that prevents undefined results. No contradiction with annotations exists.

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: the core operation and tool name are front-loaded, the sibling comparison follows immediately, then per-file behavior, CI gates, and mutual exclusions are covered. The length is justified by the tool's complexity.

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

Completeness4/5

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

For a 9-parameter tool with no output schema, the description covers invocation details, mutual exclusions, gate semantics, timeout bounds, and decision-name conversion. It could go slightly further by sketching the successful result envelope shape, but it adequately supports correct selection and invocation.

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

Parameters4/5

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

Schema coverage is 100% and each parameter already has a solid description, so the baseline is 3. The description adds aggregate meaning by clarifying the interaction between fail/failDefined/failNonEmpty and the overall CI-gate result, plus the semantic difference between bundle and dataPaths. It adds value beyond the schema without replacing it.

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 immediately distinguishes itself from the sibling tool rego_eval by noting the single-input vs. batch-input difference, so an agent can tell them apart without inspecting schemas.

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 explicitly names rego_eval as the alternative for single inputs and says opa exec is 'ideal for CI pipelines that check many config files against a policy in one call.' It also explains when to use the fail gates and that bundle and dataPaths are mutually exclusive, giving clear selection and invocation guidance.

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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/OrygnsCode/opa-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server