Skip to main content
Glama

Verify OPA bundle signature

opa_bundle_verify
Read-onlyIdempotent

Verify the signature of a signed OPA bundle directory or .tar.gz archive using a public key, and report invalid signatures, scope mismatches, or modified files.

Instructions

Verify the signature of a signed bundle directory or .tar.gz archive with the public key. OPA has no standalone verify command, so this runs opa build --verification-key into a private temp file that is discarded. A directory is verified by name from its parent, matching how opa_bundle_sign signs it. OPA reads the key, checks the JWT in .signatures.json, compares the scope claim, then checks every file: Rego files by digest before parsing, data files and .manifest by parsed value, so an unparseable data file fails before its digest is compared. Failures return INVALID_BUNDLE with details.reason set to one of signature_invalid, scope_mismatch, file_modified, file_added, file_missing, file_unparseable, unsigned, signatures_malformed, delta_bundle, not_a_bundle, bundle_load_error, or unknown when the message is not recognised; the raw output is in details. A delta bundle (one with a patch.json) is never reported as verified: it cannot be signed, and OPA before 1.21.3 loaded one without checking anything. A key or algorithm OPA cannot use returns INVALID_INPUT. Pass scope exactly as the bundle was signed with. With a single key OPA does not check verificationKeyId against the signature keyid claim. verified: true is returned only when OPA loaded the bundle with its signature intact.

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": {
      "bundle": "<bundle>",
      "verificationKey": "<verificationKey>"
    },
    "name": "opa_bundle_verify"
  }
}

Input Schema

NameRequiredDescriptionDefault
scopeNoExpected `scope` claim in the signature. Pass exactly the value the bundle was signed with, and nothing if it was signed without one; the failure reason is scope_mismatch otherwise.
bundleYesPath to the signed bundle directory or `.tar.gz` archive. Must be inside an allowed root.
signingAlgNoSigning algorithm used when the bundle was signed (e.g. `RS256`, `PS256`, `ES256`, `HS256`). Defaults to `RS256`.
v0CompatibleNoLoad the bundle as Rego v0 (`--v0-compatible`). A policy written before Rego v1 otherwise fails to load, after the signature and digests have already been checked.
verificationKeyYesPath to the PEM file containing the RSA or ECDSA public key, or for HMAC algorithms a file holding the secret. Must be inside an allowed root.
verificationKeyIdNoName the key is registered under for OPA (`--verification-key-id`, default `default`). With a single key OPA verifies against it regardless of the signature keyid claim, so this rarely needs setting.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv0.5.0
    • changedInput schema / properties / scope / description
      Previous value: -"Expected `scope` value in the bundle signature. Required when the bundle was signed with `--scope`."New value: +"Expected `scope` claim in the signature. Pass exactly the value the bundle was signed with, and nothing if it was signed without one; the failure reason is scope_mismatch otherwise."
    • addedInput schema / properties / v0Compatible
      Added value: +{
      +  "description": "Load the bundle as Rego v0 (`--v0-compatible`). A policy written before Rego v1 otherwise fails to load, after the signature and digests have already been checked.",
      +  "type": "boolean"
      +}
    • changedInput schema / properties / verificationKey / description
      Previous value: -"Path to the PEM file containing the RSA or ECDSA public key, or the path to the HMAC secret file. Must be inside an allowed root."New value: +"Path to the PEM file containing the RSA or ECDSA public key, or for HMAC algorithms a file holding the secret. Must be inside an allowed root."
    • changedInput schema / properties / verificationKeyId / description
      Previous value: -"Key ID that must match the `keyid` field in the bundle signature. Required when the bundle was signed with `--public-key-id`."New value: +"Name the key is registered under for OPA (`--verification-key-id`, default `default`). With a single key OPA verifies against it regardless of the signature keyid claim, so this rarely needs setting."
  2. Addedv0.1.13

TDQS

A4.4/5.0
Behavior5/5

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

Annotations already declare readOnly/idempotent/non-destructive, yet the description adds substantial behavior beyond them: the tool actually shells out to `opa build --verification-key` into a discarded private temp file, discloses the full verification sequence (JWT in `.signatures.json`, scope claim, digest-before-parse for Rego, parsed-value comparison for data/`.manifest`), and enumerates every failure reason under `INVALID_BUNDLE` plus `INVALID_INPUT`. It also flags a version-specific hazard (OPA before 1.21.3 loading delta bundles unchecked) and the single-key caveat that `verificationKeyId` is not compared to the keyid claim.

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 the core caveat are front-loaded, and nearly every clause carries operational information (error taxonomy, delta-bundle rule, v0 compatibility). It is a single very dense paragraph, though, and the long enumeration of failure reasons plus the repeated single-key keyid note make it heavier than it needs to be for scanning.

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?

With no output schema, the description fully carries the return-value burden: `verified: true` semantics, `INVALID_BUNDLE` with `details.reason` from a closed list, raw output in `details`, and `INVALID_INPUT` for unusable key/algorithm. Combined with the signing/parsing order and the pre-1.21.3 caveat, an agent has everything needed to call it and interpret results.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all six parameters, including the scope-mismatch behavior and the single-key `verificationKeyId` caveat. The description's notes on `scope` ('pass exactly as the bundle was signed with') and single-key keyid handling largely restate schema text rather than adding new per-parameter meaning, so the baseline of 3 applies.

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?

Opens with a specific verb and resource: 'Verify the signature of a signed bundle directory or `.tar.gz` archive with the public key.' It immediately separates itself from `opa_bundle_sign` by describing the inverse operation and notes the directory-vs-archive scope, so an agent can distinguish it from signing/building siblings without opening a schema.

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

Usage Guidelines4/5

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

Gives clear operating context: this is the only way to verify because OPA has no standalone verify command, a directory must be verified by name from its parent 'matching how `opa_bundle_sign` signs it', and `scope` must be passed exactly as signed. It also states a negative case (delta bundles are never reported verified). It stops short of naming alternatives such as `conftest_verify` or `rego_verify` or saying explicitly when to prefer them, so it is strong but not a full when/when-not/alternative map.

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