Pre-Beta Pre-beta signups are open now. The full audytx engine is live for pre-beta. Everything free today stays free — paid tiers arrive Sep 01, 2026 from $20/month for unlimited repositories.
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, so the reviewer never hallucinates the fix.

Autofix in the loop

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

The evidence

The AI-generated Terraform security gap

LLMs write valid-looking Terraform fast. The research on LLM code security is blunt: valid isn't secure.

<35%
LLM score on the IaC-Eval correctness benchmark — ICSE 2026
8 min
from AI-written Terraform to admin access in a documented incident — Sysdig
45%
of AI-generated code ships a known vulnerability, unguided — Veracode
1.57×
the security findings of human-written code across 470 PRs — CodeRabbit
Research — ICSE 2026 · IaC-Eval benchmark
LLMs score below 35% on the IaC-Eval benchmark for infrastructure-as-code correctness, with security misconfigurations among the most common failure modes.
IaC-Eval: A Multi-Dimensional Evaluation Framework for Infrastructure-as-Code Generation — ICSE 2026
Real-world incident · Sysdig threat research
An AI-generated Terraform configuration granted IAMFullAccess to a publicly-accessible, unauthenticated Lambda function — leading to admin access within 8 minutes of deployment.
Sysdig Threat Research Team — documented incident, 2024
Industry data · Veracode
45% of AI-generated code introduces a known security vulnerability when no security guidance is given.
Veracode — GenAI Code Security Report, Spring 2026
Industry data · CodeRabbit
Across 470 pull requests, AI-co-authored code showed 1.57× the overall security findings of human-written code — rising to 2.74× for specific vulnerability classes such as XSS.
CodeRabbit — State of AI vs Human Code Generation

See the full AI-generated Terraform security research →

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.

Open beta

Start free during the open beta

Install the GitHub App, point your agent at the MCP server, and watch the first review land. Free for every team while the beta is open.

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"

# Or in .cursor/mcp.json / claude_desktop_config.json:
{
  "audytx": {
    "url": "https://audytx.com/mcp",
    "headers": { "X-Client-ID": "YOUR_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).

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. 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 400 files).

03

Get findings + suppressed false positives

Each finding includes: resource name, file path, line number, severity, rule ID, human-readable description, and a sound fix suggestion. Suppressed findings carry the suppression axis and rationale, so the agent sees what was reasoned away and why.

The interface

MCP tools

Two tools on the audytx MCP server, callable from any MCP-compatible agent.

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
  • Sound fix suggestion for applicable findings
  • Context-suppressed false positives with their rationale, each suppression axis named
  • Optional: pass the plan JSON via the plan argument for resolved-value precision (variables, count, module internals)
autofix_terraform

Applies sound, precisely-anchored fixes to the Terraform files, then re-scans. Loops until clean or no further sound fixes remain (max 3 passes).

  • Applies sound fixes only, never a corrupting or partial edit
  • Re-scans after each pass, so a fix that introduces a new finding gets caught
  • Returns the fixed files + the final findings set
  • Fixes anchor to exact attribute lines: no reformatting, no structural rewrites
The autofix soundness gates are the same gates the GitHub App uses for one-click suggestions in PR comments. Only fixes that are provably safe at the attribute level get applied. No regex substitutions, no AI-generated content, no speculative changes.
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. No baseline suppressions (no repo to load them from). 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 400 files). Only changed files surface. Baseline suppressions from .audytx-baseline.yaml. 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?

Independent research finds it is. CodeRabbit measured 1.57× the security findings of human-written code, rising to 2.74× for classes such as XSS. The code compiles and looks correct, so the misconfigurations hide in cross-resource relationships 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 sound 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