Skip to main content
Glama

Migrate Rego to v1 syntax

rego_migrate_v1
Read-onlyIdempotent

Migrate Rego v0 to Rego v1 syntax: auto-fix reserved keywords, add import rego.v1, then validate with opa check to report remaining issues for manual fix.

Instructions

Migrate Rego v0 source to Rego v1 syntax in two phases: (1) opa fmt --rego-v1 auto-fixes reserved keywords (if, contains, every, in in rule heads) and adds import rego.v1; (2) opa check --v1-compatible validates the migrated source and reports any remaining issues that cannot be auto-fixed (e.g. removed builtins, semantic conflicts). Returns the migrated source and a changed flag even when check finds remaining errors -- this lets you inspect what changed and fix the remainder manually. If the source cannot be parsed, or uses a built-in that v1 removed and so fails type checking in the first phase, returns INVALID_REGO with opa's own message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYesRego v0 source to migrate to Rego v1 syntax. `opa fmt --rego-v1` auto-fixes reserved keywords and adds `import rego.v1`; any remaining issues are returned in `errors` so you can resolve them manually.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.1.13

TDQS

A4.3/5.0
Behavior5/5

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

The description goes well beyond annotations. It discloses the two-phase mechanism, the 'changed' flag behavior even when errors remain, and the INVALID_REGO fallback with opa's message. The readOnly and idempotent hints are consistent with this read-and-transform tool, and no contradictions exist.

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?

The description is a single compact paragraph with phases numbered and edge cases stated. Every sentence contributes value, though it is slightly denser than necessary. The key purpose is front-loaded.

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?

There is no output schema, so the description carries the burden of explaining return behavior. It covers the main output (migrated source, changed flag), the error-handling behavior, and the remaining-issues scenario. It does not spell out the exact JSON response shape, but that is a minor gap given the detail provided.

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?

The input schema covers the only parameter (source) 100%, including its purpose and behavior. The tool description adds context about phases and return values, but it does not add new meaning about the parameter itself, so the baseline 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?

The description opens with a specific verb and resource: 'Migrate Rego v0 source to Rego v1 syntax' and immediately details the two-phase process. This cleanly distinguishes it from formatting-only tools like rego_format or validation-only tools like rego_check, even though no sibling is explicitly named.

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?

The description clearly communicates the intended use case—migrating v0 to v1—and explains the internal pipeline so an agent knows what will happen. However, it does not explicitly mention when to prefer an alternative (e.g., rego_fix or rego_format) or state exclusions, leaving the exclusion guidance implicit.

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