Skip to main content
Glama

Conftest test

conftest_test

Evaluates configuration files against Rego policies and returns per-file, per-namespace pass/fail/warn results to pinpoint which policy rules fired.

Instructions

Evaluate configuration files (Kubernetes manifests, Terraform plans, Dockerfiles, Helm charts, or any YAML/JSON/HCL/TOML/INI) against Rego policies using conftest test. Returns per-file, per-namespace pass/fail/warn results so you can pinpoint exactly which policy rules fired. Requires conftest on PATH or CONFTEST_BINARY set; returns CONFTEST_NOT_FOUND otherwise. Provide config via files (disk paths) or inlineConfig (inline string). Provide policy via policy (disk path) or inlinePolicy (inline Rego source). Omit policy and inlinePolicy to use conftest's default ./policy directory. Policies are executed by conftest and can call OPA built-ins such as http.send. A run in which no rule was evaluated (wrong namespace, or no deny/violation/warn rules) is reported as passed: false with nothingEvaluated: true and the namespaces that do hold rules, where conftest itself would exit 0. A policy that calls parse_config_file or parse_combined_config_files is refused unless the operator sets OPA_MCP_CONFTEST_FILE_READS: they read files outside the allowed folders.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "conftest_test"
  }
}

Input Schema

NameRequiredDescriptionDefault
dataNoPaths to directories from which additional data will be loaded for the Rego policies. Each path must be inside an allowed root.
filesNoFilesystem paths to configuration files to evaluate (YAML, JSON, HCL, Dockerfile, etc.). Each path must be inside an allowed root (OPA_MCP_ALLOWED_PATHS). Mutually exclusive with `inlineConfig`.
parserNoForce a specific parser for all input `files` via conftest's global `--parser` flag, overriding extension-based detection. Useful for files whose extension does not match their format (e.g. parse a `.tfstate` file as `json`). One of: codeowners, cue, cyclonedx, dockerfile, dotenv, edn, groovy, hcl1, hcl2, hocon, ignore, ini, json, jsonc, jsonnet, nginx, properties, spdx, textproto, toml, vcl, xml, yaml. For `inlineConfig`, prefer `inlineConfigParser`.
policyNoPath to a directory or file containing Rego policies. Must be inside an allowed root (OPA_MCP_ALLOWED_PATHS). Mutually exclusive with `inlinePolicy`. Omit to let conftest use its default `./policy` directory.
combineNoCombine all configuration files into a single input document before evaluating. Useful when policies need to inspect relationships across multiple files.
namespaceNoRego namespace (package name) to test against. Defaults to `main`. Use `allNamespaces: true` to test all discovered namespaces instead.
failOnWarnNoReturn `passed: false` even when only warnings (no hard failures) are present.
inlineConfigNoInline configuration content to evaluate (e.g. a Kubernetes manifest as a YAML string). Mutually exclusive with `files`. Defaults to YAML format; set `inlineConfigParser` to override.
inlinePolicyNoInline Rego policy source. Written to a temporary directory and passed as `--policy`. The policy should declare `package main` (or match the `namespace` parameter). Mutually exclusive with `policy`.
v0CompatibleNoRead the policies as Rego v0 (`--rego-version v0`), the syntax before OPA 1.0: rules without `if`, `deny[msg] { ... }`. conftest reads v1 by default and refuses such a policy.
allNamespacesNoTest policies found in all discovered namespaces. Overrides `namespace`.
inlineConfigParserNoParser to use for `inlineConfig`. One of: codeowners, cue, cyclonedx, dockerfile, dotenv, edn, groovy, hcl1, hcl2, hocon, ignore, ini, json, jsonc, jsonnet, nginx, properties, spdx, textproto, toml, vcl, xml, yaml. Defaults to yaml. Ignored when `files` is used (conftest infers the parser from each file's extension, unless `parser` is set).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv0.12.0
    • changedInput schema / properties / inlineConfigParser / description
      Previous value: -"Parser to use for `inlineConfig`. One of: cue, cyclonedx, dockerfile, dotenv, edn, groovy, hcl1, hcl2, hocon, ignore, ini, json, jsonc, jsonnet, nginx, properties, spdx, textproto, toml, vcl, xml, yaml. Defaults to yaml. Ignored when `files` is used (conftest infers the parser from each file's extension, unless `parser` is set)."New value: +"Parser to use for `inlineConfig`. One of: codeowners, cue, cyclonedx, dockerfile, dotenv, edn, groovy, hcl1, hcl2, hocon, ignore, ini, json, jsonc, jsonnet, nginx, properties, spdx, textproto, toml, vcl, xml, yaml. Defaults to yaml. Ignored when `files` is used (conftest infers the parser from each file's extension, unless `parser` is set)."
    • changedInput schema / properties / inlineConfigParser / enum
      Previous value: -[
      -  "cue",
      -  "cyclonedx",
      -  "dockerfile",
      -  "dotenv",
      -  "edn",
      -  "groovy",
      -  "hcl1",
      -  "hcl2",
      -  "hocon",
      -  "ignore",
      -  "ini",
      -  "json",
      -  "jsonc",
      -  "jsonnet",
      -  "nginx",
      -  "properties",
      -  "spdx",
      -  "textproto",
      -  "toml",
      -  "vcl",
      -  "xml",
      -  "yaml"
      -]New value: +[
      +  "codeowners",
      +  "cue",
      +  "cyclonedx",
      +  "dockerfile",
      +  "dotenv",
      +  "edn",
      +  "groovy",
      +  "hcl1",
      +  "hcl2",
      +  "hocon",
      +  "ignore",
      +  "ini",
      +  "json",
      +  "jsonc",
      +  "jsonnet",
      +  "nginx",
      +  "properties",
      +  "spdx",
      +  "textproto",
      +  "toml",
      +  "vcl",
      +  "xml",
      +  "yaml"
      +]
    • changedInput schema / properties / parser / description
      Previous value: -"Force a specific parser for all input `files` via conftest's global `--parser` flag, overriding extension-based detection. Useful for files whose extension does not match their format (e.g. parse a `.tfstate` file as `json`). One of: cue, cyclonedx, dockerfile, dotenv, edn, groovy, hcl1, hcl2, hocon, ignore, ini, json, jsonc, jsonnet, nginx, properties, spdx, textproto, toml, vcl, xml, yaml. For `inlineConfig`, prefer `inlineConfigParser`."New value: +"Force a specific parser for all input `files` via conftest's global `--parser` flag, overriding extension-based detection. Useful for files whose extension does not match their format (e.g. parse a `.tfstate` file as `json`). One of: codeowners, cue, cyclonedx, dockerfile, dotenv, edn, groovy, hcl1, hcl2, hocon, ignore, ini, json, jsonc, jsonnet, nginx, properties, spdx, textproto, toml, vcl, xml, yaml. For `inlineConfig`, prefer `inlineConfigParser`."
    • changedInput schema / properties / parser / enum
      Previous value: -[
      -  "cue",
      -  "cyclonedx",
      -  "dockerfile",
      -  "dotenv",
      -  "edn",
      -  "groovy",
      -  "hcl1",
      -  "hcl2",
      -  "hocon",
      -  "ignore",
      -  "ini",
      -  "json",
      -  "jsonc",
      -  "jsonnet",
      -  "nginx",
      -  "properties",
      -  "spdx",
      -  "textproto",
      -  "toml",
      -  "vcl",
      -  "xml",
      -  "yaml"
      -]New value: +[
      +  "codeowners",
      +  "cue",
      +  "cyclonedx",
      +  "dockerfile",
      +  "dotenv",
      +  "edn",
      +  "groovy",
      +  "hcl1",
      +  "hcl2",
      +  "hocon",
      +  "ignore",
      +  "ini",
      +  "json",
      +  "jsonc",
      +  "jsonnet",
      +  "nginx",
      +  "properties",
      +  "spdx",
      +  "textproto",
      +  "toml",
      +  "vcl",
      +  "xml",
      +  "yaml"
      +]
  2. Changed1 schema field changedv0.8.0
    • addedInput schema / properties / v0Compatible
      Added value: +{
      +  "description": "Read the policies as Rego v0 (`--rego-version v0`), the syntax before OPA 1.0: rules without `if`, `deny[msg] { ... }`. conftest reads v1 by default and refuses such a policy.",
      +  "type": "boolean"
      +}
  3. Changed4 schema fields changedv0.7.0
    • changedInput schema / properties / inlineConfigParser / description
      Previous value: -"Parser to use for `inlineConfig`. One of: cue, dockerfile, dotenv, edn, hcl1, hcl2, hocon, ignore, ini, json, jsonnet, nginx, properties, spdx, textproto, toml, vcl, xml, yaml. Defaults to yaml. Ignored when `files` is used (conftest infers the parser from each file's extension, unless `parser` is set)."New value: +"Parser to use for `inlineConfig`. One of: cue, cyclonedx, dockerfile, dotenv, edn, groovy, hcl1, hcl2, hocon, ignore, ini, json, jsonc, jsonnet, nginx, properties, spdx, textproto, toml, vcl, xml, yaml. Defaults to yaml. Ignored when `files` is used (conftest infers the parser from each file's extension, unless `parser` is set)."
    • changedInput schema / properties / inlineConfigParser / enum
      Previous value: -[
      -  "cue",
      -  "dockerfile",
      -  "dotenv",
      -  "edn",
      -  "hcl1",
      -  "hcl2",
      -  "hocon",
      -  "ignore",
      -  "ini",
      -  "json",
      -  "jsonnet",
      -  "nginx",
      -  "properties",
      -  "spdx",
      -  "textproto",
      -  "toml",
      -  "vcl",
      -  "xml",
      -  "yaml"
      -]New value: +[
      +  "cue",
      +  "cyclonedx",
      +  "dockerfile",
      +  "dotenv",
      +  "edn",
      +  "groovy",
      +  "hcl1",
      +  "hcl2",
      +  "hocon",
      +  "ignore",
      +  "ini",
      +  "json",
      +  "jsonc",
      +  "jsonnet",
      +  "nginx",
      +  "properties",
      +  "spdx",
      +  "textproto",
      +  "toml",
      +  "vcl",
      +  "xml",
      +  "yaml"
      +]
    • changedInput schema / properties / parser / description
      Previous value: -"Force a specific parser for all input `files` via conftest's global `--parser` flag, overriding extension-based detection. Useful for files whose extension does not match their format (e.g. parse a `.tfstate` file as `json`). One of: cue, dockerfile, dotenv, edn, hcl1, hcl2, hocon, ignore, ini, json, jsonnet, nginx, properties, spdx, textproto, toml, vcl, xml, yaml. For `inlineConfig`, prefer `inlineConfigParser`."New value: +"Force a specific parser for all input `files` via conftest's global `--parser` flag, overriding extension-based detection. Useful for files whose extension does not match their format (e.g. parse a `.tfstate` file as `json`). One of: cue, cyclonedx, dockerfile, dotenv, edn, groovy, hcl1, hcl2, hocon, ignore, ini, json, jsonc, jsonnet, nginx, properties, spdx, textproto, toml, vcl, xml, yaml. For `inlineConfig`, prefer `inlineConfigParser`."
    • changedInput schema / properties / parser / enum
      Previous value: -[
      -  "cue",
      -  "dockerfile",
      -  "dotenv",
      -  "edn",
      -  "hcl1",
      -  "hcl2",
      -  "hocon",
      -  "ignore",
      -  "ini",
      -  "json",
      -  "jsonnet",
      -  "nginx",
      -  "properties",
      -  "spdx",
      -  "textproto",
      -  "toml",
      -  "vcl",
      -  "xml",
      -  "yaml"
      -]New value: +[
      +  "cue",
      +  "cyclonedx",
      +  "dockerfile",
      +  "dotenv",
      +  "edn",
      +  "groovy",
      +  "hcl1",
      +  "hcl2",
      +  "hocon",
      +  "ignore",
      +  "ini",
      +  "json",
      +  "jsonc",
      +  "jsonnet",
      +  "nginx",
      +  "properties",
      +  "spdx",
      +  "textproto",
      +  "toml",
      +  "vcl",
      +  "xml",
      +  "yaml"
      +]
  4. Changed4 schema fields changedv0.5.0
    • changedInput schema / properties / inlineConfigParser / description
      Previous value: -"Parser to use for `inlineConfig`. Valid values: yaml (default), json, toml, hcl1, hcl2, ini, xml, dotenv, cue, jsonnet, properties, edn, hocon, dockerfile. Ignored when `files` is used (conftest infers the parser from each file's extension, unless `parser` is set)."New value: +"Parser to use for `inlineConfig`. One of: cue, dockerfile, dotenv, edn, hcl1, hcl2, hocon, ignore, ini, json, jsonnet, nginx, properties, spdx, textproto, toml, vcl, xml, yaml. Defaults to yaml. Ignored when `files` is used (conftest infers the parser from each file's extension, unless `parser` is set)."
    • addedInput schema / properties / inlineConfigParser / enum
      Added value: +[
      +  "cue",
      +  "dockerfile",
      +  "dotenv",
      +  "edn",
      +  "hcl1",
      +  "hcl2",
      +  "hocon",
      +  "ignore",
      +  "ini",
      +  "json",
      +  "jsonnet",
      +  "nginx",
      +  "properties",
      +  "spdx",
      +  "textproto",
      +  "toml",
      +  "vcl",
      +  "xml",
      +  "yaml"
      +]
    • changedInput schema / properties / parser / description
      Previous value: -"Force a specific parser for all input `files` via conftest's global `--parser` flag, overriding extension-based detection. Useful for files whose extension does not match their format (e.g. parse a `.tfstate` file as `json`). Valid values: yaml, json, toml, hcl1, hcl2, ini, xml, dotenv, cue, jsonnet, properties, edn, hocon, dockerfile. For `inlineConfig`, prefer `inlineConfigParser`."New value: +"Force a specific parser for all input `files` via conftest's global `--parser` flag, overriding extension-based detection. Useful for files whose extension does not match their format (e.g. parse a `.tfstate` file as `json`). One of: cue, dockerfile, dotenv, edn, hcl1, hcl2, hocon, ignore, ini, json, jsonnet, nginx, properties, spdx, textproto, toml, vcl, xml, yaml. For `inlineConfig`, prefer `inlineConfigParser`."
    • addedInput schema / properties / parser / enum
      Added value: +[
      +  "cue",
      +  "dockerfile",
      +  "dotenv",
      +  "edn",
      +  "hcl1",
      +  "hcl2",
      +  "hocon",
      +  "ignore",
      +  "ini",
      +  "json",
      +  "jsonnet",
      +  "nginx",
      +  "properties",
      +  "spdx",
      +  "textproto",
      +  "toml",
      +  "vcl",
      +  "xml",
      +  "yaml"
      +]
  5. Changed2 schema fields changedv0.1.20
    • changedInput schema / properties / inlineConfigParser / description
      Previous value: -"Parser to use for `inlineConfig`. Valid values: yaml (default), json, toml, hcl1, hcl2, ini, xml, dotenv, cue, jsonnet, properties, dockerfile. Ignored when `files` is used (conftest infers the parser from each file's extension)."New value: +"Parser to use for `inlineConfig`. Valid values: yaml (default), json, toml, hcl1, hcl2, ini, xml, dotenv, cue, jsonnet, properties, edn, hocon, dockerfile. Ignored when `files` is used (conftest infers the parser from each file's extension, unless `parser` is set)."
    • addedInput schema / properties / parser
      Added value: +{
      +  "description": "Force a specific parser for all input `files` via conftest's global `--parser` flag, overriding extension-based detection. Useful for files whose extension does not match their format (e.g. parse a `.tfstate` file as `json`). Valid values: yaml, json, toml, hcl1, hcl2, ini, xml, dotenv, cue, jsonnet, properties, edn, hocon, dockerfile. For `inlineConfig`, prefer `inlineConfigParser`.",
      +  "type": "string"
      +}
  6. Addedv0.1.13

TDQS

A4.5/5.0
Behavior5/5

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

Adds substantial behavior beyond the annotations: requires `conftest` on PATH or CONFTEST_BINARY and returns CONFTEST_NOT_FOUND otherwise; discloses a deliberate deviation from conftest (empty runs reported as `passed: false` with `nothingEvaluated: true` plus namespaces where rules exist, where conftest would exit 0); and warns that policies calling parse_config_file are refused unless OPA_MCP_CONFTEST_FILE_READS is set. The note that policies can invoke OPA built-ins such as http.send is consistent with openWorldHint=true, and temp-file writing is consistent with readOnlyHint=false.

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?

Front-loads the purpose and result shape, then moves through prerequisites, input source selection, policy source selection, and edge-case behaviors in a logical order with no filler sentences. It is dense — a single long paragraph covering many behaviors — which makes it harder to scan than a short bulleted structure would be.

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?

For a 12-parameter, zero-required, no-output-schema tool, the description covers the operation, the return shape (per-file/per-namespace pass/fail/warn), the key failure modes, and the input-source matrix — enough to call it correctly without an output schema. Minor incompleteness: the `data` parameter (additional policy data directories) and the allowed-path restriction surface only through the schema, not the description.

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 the baseline is 3, but the description still adds real meaning: default policy directory when `policy`/`inlinePolicy` are omitted, mutual exclusivity of config and policy sources, `namespace` defaulting to `main` with allNamespaces overriding it, and the `parser` vs `inlineConfigParser` split (including that `parser` is ignored for inline content). It does not explain the `data` parameter's role in policy evaluation, which is the one notable gap.

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 — evaluate configuration files (K8s, Terraform, Dockerfile, Helm, YAML/JSON/HCL/TOML/INI) against Rego policies via `conftest test` — and the result shape (per-file, per-namespace pass/fail/warn). This cleanly separates it from siblings like rego_test (Rego unit tests) or opa_exec (raw queries), which operate on policies/queries rather than config documents.

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?

Gives concrete selection rules among its own parameters: config via `files` OR `inlineConfig`, policy via `policy` OR `inlinePolicy`, and 'omit both to use conftest's default ./policy'. It also steers `inlineConfig` users toward `inlineConfigParser`. It does not explicitly contrast with sibling tools (e.g. when to prefer rego_test), so it falls short of a 5.

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