Skip to main content
Glama

Upload or replace OPA policy

opa_put_policy
DestructiveIdempotent

Upload a Rego policy under a given ID, replacing any existing policy. OPA compiles it on the server; invalid policies return errors and are not stored.

Instructions

Upload a Rego policy under the given ID. Replaces any existing policy with that ID; replaced says whether one existed. The policy is uploaded as raw text/plain and OPA compiles it on the server, so a policy that does not compile comes back as INVALID_REGO with OPA's errors, and nothing is stored.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesPolicy ID to create or replace.
sourceYesRego source.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.1.13
  2. Removedv0.1.5
  3. Addedv0.1.2
  4. Removedv0.1.1
  5. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

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

Goes well beyond the annotations: it explains the `replaced` return flag, that the source is raw text/plain compiled server-side, and that a non-compiling policy returns INVALID_REGO with OPA's errors and stores nothing. This is exactly the failure/reversibility context an agent needs for a destructive write.

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?

Two sentences, zero filler, with the upsert semantics front-loaded and the validation/failure behavior following. Every clause carries information.

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 still covers the return signal (`replaced`) and the error outcome (INVALID_REGO) plus the atomicity guarantee ('nothing is stored'). An agent has everything needed to call and interpret this tool.

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% so both params are already documented, but the description adds real meaning: that `id` is a create-or-replace key and that `source` is raw Rego text uploaded as text/plain and compiled server-side. That exceeds the baseline for a fully documented schema.

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?

States a specific verb and resource ('Upload a Rego policy under the given ID') and immediately clarifies the upsert semantics ('Replaces any existing policy with that ID'), which cleanly distinguishes it from opa_get_policy, opa_delete_policy and opa_list_policies among the siblings.

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 replace-existing behavior gives clear context for when this tool applies versus a read or delete, but it never names an alternative tool or states an explicit when-not condition. An agent can infer usage, but there is no explicit routing guidance.

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