Skip to main content
Glama

Build OPA bundle

opa_bundle_build
DestructiveIdempotent

Builds a deployable .tar.gz policy bundle from Rego/data paths via opa build, with optional signing, optimization, custom revisions, and WASM output for OPA deployment.

Instructions

Build a deployable bundle from policy / data paths using opa build. Output is a .tar.gz archive with optional inline signing. Supports optimization, custom revision strings, and the WASM target. The paths go to opa relative to the folder that holds them all, so modules are named by their place under it, not by absolute path. OPA 1.23 and later root a bundle directory at the folder holding its .manifest, even a nested one, and leave out the files above it; what opa warns about comes back in warnings.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "paths": "<paths>",
      "output": "<output>"
    },
    "name": "opa_bundle_build"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathsYesPolicy / data paths to include. Each must be in an allowed root.
bundleNoLoad `paths` as bundle files or root directories (`--bundle`). Implied by `signingKey` and `verificationKey`; set it explicitly to rebuild an existing bundle without signing.
ignoreNoFile/directory name patterns to ignore during loading (`--ignore`), e.g. `[".*"]` to skip hidden files. These are name patterns, not filesystem paths.
outputYesOutput bundle path (typically `*.tar.gz`). Must be in an allowed root.
targetNoBuild target (default `rego`; `wasm` compiles to WebAssembly).
optimizeNoOptimization level (0 = none, 2 = aggressive).
revisionNoBundle revision string written to the manifest.
claimsFileNoPath to a claims file for inline signing.
signingAlgNoSigning algorithm (e.g. RS256).
signingKeyNoPath to a PEM private key for signing the built bundle (`--signing-key`). Implies `bundle: true`, which OPA requires for signing.
entrypointsNoEntrypoint refs (required when `target=wasm` or `optimize > 0`).
pruneUnusedNoExclude dependents of entrypoints that are not reachable from them (`--prune-unused`). Most useful alongside `entrypoints`.
capabilitiesNoPath to a capabilities JSON file.
v0CompatibleNoRead the policy as Rego v0 (`--v0-compatible`), the syntax OPA used before 1.0: rules without `if`, partial sets as `deny[msg] { ... }`. Needed for a policy that has not been migrated, which OPA 1.x otherwise refuses to load. Where the tool also takes a query, the query is read as v0 too, with the future keywords imported so `in`, `every` and `some x in` still work in it.
v1CompatibleNoOpt in to OPA v1.0-compatible behaviors (`--v1-compatible`). Affects the built bundle's runtime semantics.
verificationKeyNoPath to a PEM public key (or HMAC secret file) used to re-verify an existing signed bundle during the build (`--verification-key`). Implies `bundle: true`, which OPA requires for verification. A delta bundle (one with a `patch.json`) cannot be signed, so it fails as `INVALID_BUNDLE` with `details.reason` delta_bundle and leaves no output.
verificationKeyIdNoKey ID for verification (`--verification-key-id`, OPA default `default`).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.9.2
    • changedInput schema / properties / verificationKey / description
      Previous value: -"Path to a PEM public key (or HMAC secret file) used to re-verify an existing signed bundle during the build (`--verification-key`). Implies `bundle: true`, which OPA requires for verification."New value: +"Path to a PEM public key (or HMAC secret file) used to re-verify an existing signed bundle during the build (`--verification-key`). Implies `bundle: true`, which OPA requires for verification. A delta bundle (one with a `patch.json`) cannot be signed, so it fails as `INVALID_BUNDLE` with `details.reason` delta_bundle and leaves no output."
  2. Changed1 schema field changedv0.8.0
    • changedInput schema / properties / v0Compatible / description
      Previous value: -"Read the policy as Rego v0 (`--v0-compatible`), the syntax OPA used before 1.0: rules without `if`, partial sets as `deny[msg] { ... }`. Needed for a policy that has not been migrated, which OPA 1.x otherwise refuses to load."New value: +"Read the policy as Rego v0 (`--v0-compatible`), the syntax OPA used before 1.0: rules without `if`, partial sets as `deny[msg] { ... }`. Needed for a policy that has not been migrated, which OPA 1.x otherwise refuses to load. Where the tool also takes a query, the query is read as v0 too, with the future keywords imported so `in`, `every` and `some x in` still work in it."
  3. Changed1 schema field changedv0.7.0
    • addedInput schema / properties / v0Compatible
      Added value: +{
      +  "description": "Read the policy as Rego v0 (`--v0-compatible`), the syntax OPA used before 1.0: rules without `if`, partial sets as `deny[msg] { ... }`. Needed for a policy that has not been migrated, which OPA 1.x otherwise refuses to load.",
      +  "type": "boolean"
      +}
  4. Changed3 schema fields changedv0.5.0
    • changedInput schema / properties / bundle / description
      Previous value: -"Load `paths` as bundle files or root directories (`--bundle`). Required when rebuilding or re-signing an existing bundle."New value: +"Load `paths` as bundle files or root directories (`--bundle`). Implied by `signingKey` and `verificationKey`; set it explicitly to rebuild an existing bundle without signing."
    • changedInput schema / properties / signingKey / description
      Previous value: -"Path to a signing key for inline signing."New value: +"Path to a PEM private key for signing the built bundle (`--signing-key`). Implies `bundle: true`, which OPA requires for signing."
    • changedInput schema / properties / verificationKey / description
      Previous value: -"Path to a PEM public key (or HMAC secret file) used to re-verify an existing signed bundle during the build (`--verification-key`). Pair with `bundle: true`."New value: +"Path to a PEM public key (or HMAC secret file) used to re-verify an existing signed bundle during the build (`--verification-key`). Implies `bundle: true`, which OPA requires for verification."
  5. Changed6 schema fields changedv0.1.20
    • addedInput schema / properties / bundle
      Added value: +{
      +  "description": "Load `paths` as bundle files or root directories (`--bundle`). Required when rebuilding or re-signing an existing bundle.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / ignore
      Added value: +{
      +  "description": "File/directory name patterns to ignore during loading (`--ignore`), e.g. `[\".*\"]` to skip hidden files. These are name patterns, not filesystem paths.",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedInput schema / properties / pruneUnused
      Added value: +{
      +  "description": "Exclude dependents of entrypoints that are not reachable from them (`--prune-unused`). Most useful alongside `entrypoints`.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / v1Compatible
      Added value: +{
      +  "description": "Opt in to OPA v1.0-compatible behaviors (`--v1-compatible`). Affects the built bundle's runtime semantics.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / verificationKey
      Added value: +{
      +  "description": "Path to a PEM public key (or HMAC secret file) used to re-verify an existing signed bundle during the build (`--verification-key`). Pair with `bundle: true`.",
      +  "type": "string"
      +}
    • addedInput schema / properties / verificationKeyId
      Added value: +{
      +  "description": "Key ID for verification (`--verification-key-id`, OPA default `default`).",
      +  "type": "string"
      +}
  6. Addedv0.1.13
  7. Removedv0.1.5
  8. Addedv0.1.2
  9. Removedv0.1.1
  10. First observedv0.1.0

TDQS

A3.8/5.0
Behavior4/5

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

Annotations already flag destructiveHint=true and idempotentHint=true, and the description adds real context on top: the produced artifact type, that signing can be inline, the OPA 1.23+ rule that the bundle root is the directory holding `.manifest` with files above it excluded, and that OPA's warnings surface in `warnings`. It does not say what happens if the output path already exists, which is the main residual gap given destructiveHint=true.

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

Conciseness4/5

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

Purpose and output artifact are front-loaded, and the following sentences each add distinct facts (signing option, path rooting rule, manifest rooting behavior, warnings). The path-relativity sentence is awkwardly worded ('the paths go to opa relative to the folder that holds them all') but is not padding.

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 17-parameter build tool with no output schema, the description covers the artifact produced, the warning channel, and the two behaviors most likely to surprise an agent (path re-rooting and `.manifest`-based bundle rooting). Missing elements are overwrite semantics for an existing `output` file and any statement of failure modes, which would matter more given destructiveHint=true.

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% with 17 well-documented parameters, so a 3 baseline applies, but the description genuinely adds meaning the schema lacks: how `paths` are re-rooted for `opa` (modules named by position under the shared parent, not absolute path) and that `target`/`optimize`/`entrypoints` interact around the WASM toolchain. The path-relativity sentence is the kind of semantic detail an agent cannot get from the schema alone.

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

Purpose4/5

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

States a specific verb and artifact: 'Build a deployable bundle from policy / data paths using `opa build`', and names the output format (.tar.gz) plus the optional signing mode. It implicitly separates itself from opa_bundle_sign and opa_bundle_verify by framing signing as an inline option of the build, but never names those siblings, so an agent must infer the boundary.

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

Usage Guidelines3/5

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

Usage is implied (compile and package policy into a distributable archive) rather than stated with when/when-not conditions. There is no guidance about choosing this over opa_bundle_sign, opa_compile_query, or rego_check, and no prerequisite conditions such as an allowed output root. The most useful conditional detail (set `bundle` explicitly to rebuild an existing bundle without signing) lives in the schema, not the description.

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