Skip to main content
Glama
OrygnsCode

opa-mcp-server

Delete OPA policy

opa_delete_policy

Delete a policy from a running OPA server by providing its policy ID.

Instructions

Delete a policy by ID from the running OPA server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesPolicy ID to delete.

Implementation Reference

  • Handler function for opa_delete_policy. Sends a DELETE request to OPA's /v1/policies/{id} endpoint. Returns { id, deleted: true } on success, or maps OPA client errors (with POLICY_NOT_FOUND for 404).
    async ({ id }) => {
      return withToolEnvelope<{ id: string; deleted: boolean }>(config, async () => {
        try {
          await opa.request({
            method: 'DELETE',
            path: `/v1/policies/${encodeURIComponent(id)}`,
          });
          return ok({ id, deleted: true });
        } catch (e) {
          return mapOpaClientError(e, 'POLICY_NOT_FOUND');
        }
      });
    },
  • Registration and input schema for opa_delete_policy. Accepts a single 'id' parameter (string, min 1) describing the Policy ID to delete.
    server.registerTool(
      'opa_delete_policy',
      {
        title: 'Delete OPA policy',
        description: 'Delete a policy by ID from the running OPA server.',
        inputSchema: {
          id: z.string().min(1).describe('Policy ID to delete.'),
        },
      },
  • Top-level registration entry point. registerTools() calls registerServerManagementTools() which in turn calls registerPolicyTools() that registers opa_delete_policy on the MCP server.
    export function registerTools(server: McpServer, config: Config): void {
      registerAuthoringTools(server, config);
      registerEvaluationTools(server, config);
      registerBundleTools(server, config);
      registerServerManagementTools(server, config);
      registerHelperTools(server, config);
    }
  • Server management registration dispatcher. registerServerManagementTools() calls registerPolicyTools() to register policy tools including opa_delete_policy.
    export function registerServerManagementTools(server: McpServer, config: Config): void {
      registerPolicyTools(server, config);
      registerDataTools(server, config);
      registerDecisionTools(server, config);
      registerStatusTools(server, config);
    }
  • mapOpaClientError helper used by opa_delete_policy handler to translate OPA client errors into structured error envelopes (e.g., POLICY_NOT_FOUND for 404).
    export function mapOpaClientError(
      e: unknown,
      notFoundCode: ToolErrorCode = 'UNKNOWN_ERROR',
    ): ToolEnvelope<never> {
      if (e instanceof OpaUnreachableError) {
        return err('OPA_UNREACHABLE', `OPA server unreachable at ${e.url}`, {
          hint: 'Confirm OPA_URL points at a running OPA server (e.g. `curl $OPA_URL/health`).',
          details: { url: e.url },
        });
      }
      if (e instanceof OpaAuthError) {
        return err('OPA_AUTH_FAILED', 'OPA rejected the request with 401 Unauthorized.', {
          hint: 'Set OPA_TOKEN to a valid bearer token, or remove the auth requirement on the OPA server.',
        });
      }
      if (e instanceof OpaHttpError) {
        if (e.status === 404) {
          return err(notFoundCode, `OPA returned 404 Not Found.`, {
            details: { status: e.status, body: e.body },
          });
        }
        return err('UNKNOWN_ERROR', `OPA returned HTTP ${e.status}.`, {
          details: { status: e.status, body: e.body },
        });
      }
      const message = e instanceof Error ? e.message : 'Unknown error';
      return err('UNKNOWN_ERROR', message, {
        details: e instanceof Error ? { stack: e.stack } : { value: e },
      });
    }
Behavior2/5

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

No annotations provided. The description simply states 'delete' without disclosing side effects (e.g., immediate vs. pending, impact on other policies, error handling for non-existent policies).

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?

Single concise sentence that is front-loaded with the key action and resource. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

While the tool is simple with one parameter and no output schema, the description lacks information about return values (e.g., success confirmation) and does not help differentiate among 33 sibling tools.

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 coverage is 100% with one parameter 'id' described as 'Policy ID to delete.' The description adds no extra meaning beyond the schema, so baseline 3 is appropriate.

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 clearly identifies the action (delete), the resource (policy by ID), and the context (running OPA server), distinguishing it from sibling tools like opa_get_policy and opa_put_policy.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives (e.g., opa_put_policy to overwrite, or opa_list_policies to view). No prerequisites or conditions for deletion are mentioned.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/OrygnsCode/opa-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server