Skip to main content
Glama

Check Rego

rego_check
Read-onlyIdempotent

Validate Rego policies for syntax, type, and compilation errors using inline source or file paths, returning structured file and line diagnostics to fix them.

Instructions

Type-check Rego with opa check. Returns { valid: true, errors: [] } on success, or a list of structured diagnostics with file/line locations on failure. Provide either source for inline checking or paths for file/directory checking.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathsNoFilesystem paths to check. Each path must be inside an allowed root (OPA_MCP_ALLOWED_PATHS).
bundleNoLoad `paths` as bundle files or root directories (`--bundle`). Only valid with `paths`, not inline `source`.
sourceNoInline Rego source. Mutually exclusive with `paths`.
strictNoEnable strict mode -- fail on unused vars, deprecated builtins, etc.
maxErrorsNoMaximum number of errors to collect before `opa check` aborts compilation (`--max-errors`, OPA default 10). Raise it to surface more diagnostics from a badly broken policy in a single pass.
schemaDirNoSchema directory for input/data validation.
capabilitiesNoPath to a capabilities JSON file restricting allowed builtins.
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.

Schema Changelog

Changes observed during successful MCP inspections.

  1. 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."
  2. 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"
      +}
  3. Changed2 schema fields changedv0.1.20
    • addedInput schema / properties / bundle
      Added value: +{
      +  "description": "Load `paths` as bundle files or root directories (`--bundle`). Only valid with `paths`, not inline `source`.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / maxErrors
      Added value: +{
      +  "description": "Maximum number of errors to collect before `opa check` aborts compilation (`--max-errors`, OPA default 10). Raise it to surface more diagnostics from a badly broken policy in a single pass.",
      +  "minimum": 1,
      +  "type": "integer"
      +}
  4. Added
  5. Removedv0.1.5
  6. Addedv0.1.2
  7. Removedv0.1.1
  8. 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 declare readOnlyHint, idempotentHint, and destructiveHint=false, so safety is covered. The description adds real value beyond that: it documents the return shape ('{ valid: true, errors: [] }') and the failure mode (structured diagnostics with file/line locations), which matters given no output schema 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?

Three tight sentences with the core action, the return contract, and the input-mode choice front-loaded in that order. No filler or restated boilerplate.

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?

With no output schema, the description correctly supplies the return contract, and annotations cover the safety profile while the schema covers all parameters. It is nearly complete; only the lack of sibling routing (check vs lint) leaves a minor gap.

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 every one of the 8 parameters is already documented in the schema, setting the baseline at 3. The description's only parameter-level addition is the source/paths mutual exclusivity, which the schema already states, so it adds little beyond the structured fields.

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 resource ('Type-check Rego with `opa check`') plus the exact underlying command, which lets an agent separate it from rego_lint and rego_parse_ast. It does not explicitly name or contrast those siblings, so it falls short of full differentiation.

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?

The description conveys the source-vs-paths usage pattern ('Provide either `source` for inline checking or `paths` for file/directory checking'), which is useful. However, it gives no guidance on when to reach for rego_check versus rego_lint, rego_compile_query, or rego_migrate_v1, so usage is only implied by the verb.

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