Free plan Signups are open now. The full audytx engine — Terraform and CloudFormation — is live. The Free plan is 100 scans a month and stays free — paid tiers arrive Nov 01, 2026 from $20/month for unlimited repositories. Try it on your own code.
MCP · AI coding agents · Terraform security

Secure AI-generated Terraform — the MCP server for AI coding agents

AI coding agents write Terraform in seconds, and most teams merge it after a skim. audytx reviews it with a deterministic, hand-written engine — the same one behind the GitHub App — running as a stateless MCP server at https://audytx.com/mcp. The agent that wrote the code is probabilistic; the reviewer isn't.

Claude Code Cursor any MCP agent scan_terraform autofix_terraform
The short answer

How do you secure AI-generated Terraform?

Point your agent at audytx's MCP server. Before it opens a pull request, the agent calls scan_terraform on its own output — or autofix_terraform to scan, repair, and re-scan in one loop.

Called before the PR

The agent runs scan_terraform on the Terraform it just wrote, in the same session — no CI wait, no second tool.

Deterministic verdicts

Findings come from a hand-written Rust engine, not another LLM. Fixes are deterministic and are applied only when a finding is anchored to exact source lines.

Autofix in the loop

autofix_terraform applies only sound, attribute-precise fixes and re-scans — up to three passes.

The evidence

Valid-looking Terraform is not always correct Terraform

Published research on LLM-written infrastructure code reports low success rates. Our own security study is linked below, with its date.

19.36%
pass@1 of the top model (GPT-4) on the IaC-Eval benchmark — NeurIPS 2024
27.1%
baseline overall success of LLMs writing Terraform in a December 2025 study — arXiv:2512.14792
Research — NeurIPS 2024 · IaC-Eval benchmark
Contemporary LLMs perform poorly on IaC-Eval, with the top-performing model, GPT-4, obtaining a pass@1 accuracy of 19.36%.
IaC-Eval: A Code Generation Benchmark for Cloud Infrastructure-as-Code Programs — NeurIPS 2024
Research — arXiv:2512.14792 · December 2025
Experimental results demonstrated that while baseline LLM performance was poor (27.1% overall success), injecting structured configuration knowledge increased technical validation success to 75.3% and overall success to 62.6%.
Nekrasov et al. — IaC Generation with LLMs: An Error Taxonomy and A Study on Configuration Knowledge Injection

See our AI-generated Terraform security study → (June 2026, measured on engine v0.5.1)

Why a diff review misses it

Where the risk hides

The dangerous configuration is rarely in one file — it's in how three resources relate. A skim can't see that; a context graph can.

The gap

An agent writes a .tf file, the developer skims the diff, it looks fine, the PR merges. The IAM PassRole chain that creates a privilege-escalation path isn't visible in any single file. Seeing it takes reasoning across the three resources the agent touched.

The fix

The agent that wrote the Terraform calls scan_terraform before the PR exists. It gets file and line anchors, severity, and a rationale for every finding (including the false positives audytx suppressed, and why), then fixes the real issues in the same session.

Free plan

Start free

Install the GitHub App, point your agent at the MCP server, and watch the first review land. The Free plan includes 100 scans a month.

Setup · three steps

Add audytx to your AI coding agent

Free with a Client ID. Grab one at /signup, add the header, and point your agent at the endpoint.

01

Add the MCP server

# Claude Code
claude mcp add --transport http audytx https://audytx.com/mcp \
  --header "X-Client-ID: YOUR_CLIENT_ID"

# Cursor: .cursor/mcp.json (set AUDYTX_CLIENT_ID in your environment)
{
  "mcpServers": {
    "audytx": {
      "url": "https://audytx.com/mcp",
      "headers": { "X-Client-ID": "${env:AUDYTX_CLIENT_ID}" }
    }
  }
}

The server is stateless: no session, no persistent connection. Each call is one HTTP POST with JSON-RPC, authenticated by your X-Client-ID header (get a free Client ID). Step-by-step guides: Claude Code, Cursor, GitHub Copilot.

02

Scan Terraform files

# The agent calls scan_terraform with your .tf content
{
  "tool": "scan_terraform",
  "files": [
    { "path": "main.tf", "content": "resource \"aws_iam_role\" ..." },
    { "path": "lambda.tf", "content": "resource \"aws_lambda_function\" ..." }
  ]
}

Pass as many .tf files as the change touches, up to 2,000 per call. Cross-resource reasoning spans every file in the call, the same way the GitHub App spans the repo tree it fetches at PR time (up to 1,000 files).

03

Get findings + suppressed false positives

Each finding includes: resource name, file path, line number, severity, rule ID, human-readable description, and a fix suggestion where one is available. Suppressed findings carry a rationale, so the agent sees what was held back and why.

The interface

MCP tools

The two tools of the Terraform loop. The audytx MCP server has more; see its tool list.

scan_terraform

Runs the full audytx engine on the provided Terraform files and returns structured findings.

  • Every finding anchored to a file path + line number
  • Severity: CRITICAL, HIGH, MEDIUM, LOW, INFO
  • A fix suggestion where one is available
  • Context-suppressed false positives with their rationale
  • Optional: pass the plan JSON via the plan argument for resolved-value precision (variables, count, module internals)
autofix_terraform

Applies the fixes that are anchored to exact source lines to the Terraform files, then re-scans. Loops until clean or no further such fixes remain (max 3 passes).

  • Fixes are deterministic and are applied only when a finding is anchored to exact source lines
  • Re-scans after each pass, so a fix that introduces a new finding gets caught
  • Returns the fixed files + the final findings set
  • A fix replaces the exact source lines a finding points at; the rest of the file is left as it was
The autofix safety checks mirror the ones the GitHub App uses for one-click suggestions in PR comments. A finding that is not anchored to exact source lines is reported, not edited. No AI-generated content is written into your files.
Optional · resolved-value precision

Optional: plan-enhanced scans

Variables, count, and module outputs are opaque to static analysis — var.environment in a tag condition can't be resolved without a plan. Already running terraform plan? Feed it in.

# 1. Generate the plan JSON
terraform init && terraform plan -out plan.tfplan
terraform show -json plan.tfplan > plan.json

# 2. Pass it to scan_terraform
{
  "tool": "scan_terraform",
  "files": [{ "path": "main.tf", "content": "..." }],
  "plan": "{ ... contents of plan.json ... }"
}

Without a plan, audytx marks findings that depend on unresolved values as Incomplete — it flags what it can prove, not what it guesses. With the plan, those findings become precise.

Same engine · two surfaces

What the GitHub App adds

Both paths run the exact same engine. What differs is the context each one sees.

MCP path (agent use)

No repo identity, no diff. The agent passes files directly. Best for: catching issues before the PR, in-agent autofix loops, CI-independent checks.

GitHub App (PR review)

Repo tree fetched at PR time (up to 1,000 files). Only changed files surface. SARIF to Code Scanning. One PR comment per scan.

Run both. The agent checks its own work over MCP while it writes; the GitHub App reviews every PR and catches what slipped through, before insecure infrastructure merges.

FAQ

Frequently asked questions

Is AI-generated Terraform less secure?

In our June 2026 study (one model, Claude Opus 4.8, measured on engine v0.5.1 and not re-run since), AI-written Terraform landed on par with hand-written production modules on findings per 100 resources. The gaps were cross-resource ones, such as Secrets Manager rotation that was never configured. The code compiles and looks correct, so those gaps hide in how resources relate, which a quick diff review misses.

How do I scan AI-written Terraform?

Add audytx as an MCP server in Claude Code, Cursor, or any MCP-compatible agent, then have the agent call scan_terraform on its Terraform before opening the pull request. autofix_terraform can scan, apply fixes, and re-scan in one loop. You can also install the GitHub App to review every pull request.

Give your AI coding agent a security reviewer

The MCP server is live and the free tier is free forever. Your agent is one command away from deterministic Terraform security scanning.

claude mcp add --transport http audytx https://audytx.com/mcp --header "X-Client-ID: YOUR_CLIENT_ID"