Skip to main content
Glama
OrygnsCode

opa-mcp-server

Inspect bundle or policy

rego_inspect

Inspect any OPA bundle, directory, or Rego file to retrieve manifest data, namespaces, rule annotations, and signature metadata.

Instructions

Inspect an OPA bundle, policy directory, or single Rego file with opa inspect. Returns manifest data, namespaces, rule annotations, and (if signed) signature metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetYesPath to a bundle archive (`*.tar.gz`), directory, or single Rego file.

Implementation Reference

  • Main tool handler: registers the 'rego_inspect' MCP tool, validates the target path, runs 'opa inspect --format=json', parses the JSON output, and returns structured data (manifest, namespaces, annotations, signatures).
    export function registerRegoInspect(server: McpServer, config: Config): void {
      const opa = new OpaCli(config);
    
      server.registerTool(
        'rego_inspect',
        {
          title: 'Inspect bundle or policy',
          description:
            'Inspect an OPA bundle, policy directory, or single Rego file with `opa inspect`. Returns manifest data, namespaces, rule annotations, and (if signed) signature metadata.',
          inputSchema: RegoInspectInput,
        },
        async ({ target }) => {
          return withToolEnvelope<RegoInspectOutput>(config, async () => {
            const validation = validatePaths([target], config, { mustExist: true });
            if (!validation.ok) return validation.error;
            const [resolved] = validation.resolved;
    
            const result = await opa.inspect({ target: resolved! });
    
            const subprocessFailure = mapSubprocessFailure(result, 'opa');
            if (subprocessFailure) return subprocessFailure;
    
            if (result.exitCode !== 0) {
              return err(
                'INVALID_BUNDLE',
                'opa inspect rejected the target — it is not a valid bundle, directory, or Rego file.',
                {
                  details: { stderr: result.stderr.trim(), stdout: result.stdout.trim() },
                },
              );
            }
    
            const parsed = tryParseJson<RegoInspectOutput>(result.stdout);
            if (parsed === undefined) {
              return err('UNKNOWN_ERROR', 'opa inspect produced no parseable JSON output.', {
                details: { stdout: result.stdout.trim() },
              });
            }
            return ok<RegoInspectOutput>(parsed);
          });
        },
      );
    }
  • Zod input schema for RegoInspect: requires a 'target' string (path to bundle, directory, or .rego file).
    const RegoInspectInput = {
      target: z
        .string()
        .min(1)
        .describe('Path to a bundle archive (`*.tar.gz`), directory, or single Rego file.'),
    };
  • TypeScript interface for the tool output: manifest, namespaces, annotations, and optional signatures.
    export interface RegoInspectOutput {
      manifest?: unknown;
      namespaces?: Record<string, unknown>;
      annotations?: unknown;
      signatures?: unknown;
    }
  • Registration entry point: calls registerRegoInspect() as part of authoring tool registration.
    export function registerAuthoringTools(server: McpServer, config: Config): void {
      registerRegoFormat(server, config);
      registerRegoCheck(server, config);
      registerRegoLint(server, config);
      registerRegoParseAst(server, config);
      registerRegoInspect(server, config);
      registerRegoCapabilities(server, config);
      registerRegoDeps(server, config);
    }
  • OpaCli.inspect() helper: wraps the 'opa inspect --format=json' subprocess call.
    /**
     * Inspect a bundle, directory, or single Rego file. Returns its
     * packages, namespaces, manifest, and annotations as JSON on stdout.
     */
    async inspect(input: InspectInput): Promise<SpawnResult> {
      return this.run(['inspect', '--format=json', input.target]);
    }
Behavior4/5

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

No annotations, so description carries full burden. Accurately describes outputs (manifest, namespaces, annotations, signature metadata). Lacks details on error handling or authentication, but sufficient for a read-only inspection tool.

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 concise sentences with action and expected output. No redundant information, well-structured for quick comprehension.

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?

Describes return values adequately despite no output schema. Could mention format (JSON), but overall complete for a simple inspection tool with one parameter.

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% (only one parameter 'target' with clear description). The tool description adds no additional meaning beyond the schema's parameter description, meeting the baseline for high coverage.

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?

Clearly states the verb 'Inspect' and the specific resources (bundle, policy directory, Rego file). Lists return values, distinguishing it from sibling tools like rego_eval or rego_check.

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 explicit guidance on when to use this tool versus alternatives (e.g., rego_describe_policy, rego_lint). The description lacks context for appropriate usage scenarios.

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