Skip to main content
Glama

infra-guard

An MCP server that scans Terraform and Dockerfiles for real security misconfigurations — open security groups, public S3 buckets, wildcard IAM policies, hardcoded secrets, containers running as root — and hands back structured findings instead of a guess.

It plugs into Claude Code, Claude Desktop, or Cursor as a tool. Ask your AI assistant to review your infrastructure code, and it calls infra-guard, gets back real findings from Checkov, and explains them to you.

Try it in the browser: infra-guard-frontend-production.up.railway.app — paste Terraform, click Scan, see real findings. No install required.

MCP endpoint: https://infra-guard-production.up.railway.app/mcp

Why this exists

I did cloud infrastructure work at A.P. Moller–Maersk — Terraform, Docker, AWS provisioning at real scale. Most portfolio projects are generic web apps; this one is the tool I actually wished existed: something that turns "does my Terraform have any obvious security holes" into a real, structured answer instead of an AI assistant's best guess.

infra-guard doesn't guess. It runs your file through Checkov, a real static analysis engine with hundreds of built-in checks, and returns the actual findings — check ID, title, affected resource, line range, code snippet. The hosting LLM (Claude, or whatever's on the other end of the MCP connection) explains the findings in plain English. The tool's job is just to be correct.

Related MCP server: MCP Security Scanner

How it works

scanner.py   → core engine: scan_terraform(...) / scan_dockerfile(...) -> structured dict
server.py    → wraps both as MCP tools, served over stdio or Streamable HTTP
api.py       → wraps both as a plain REST API (POST /api/scan, POST /api/scan-dockerfile),
               plus POST /api/explain for optional local AI remediation
frontend/    → React + Vite playground: severity badges, sort/group findings,
               click a finding to scroll/highlight its lines in a CodeMirror
               editor, "Explain & Fix" for AI-generated remediation, calls api.py

scanner.py shells out to the Checkov CLI, parses its JSON output, and returns the same shape regardless of which framework ran:

{
  "summary": { "passed": 14, "failed": 34, "total_checks": 48 },
  "findings": [
    {
      "check_id": "CKV_AWS_24",
      "title": "Ensure no security groups allow ingress from 0.0.0.0:0 to port 22",
      "resource": "aws_security_group.app_sg",
      "severity": "critical",
      "start_line": 6,
      "end_line": 24,
      "code_snippet": "resource \"aws_security_group\" \"app_sg\" { ... }"
    }
  ]
}

server.py exposes two MCP tools, scan_terraform_file(file_content, filename) and scan_dockerfile_file(file_content, filename), with no interpretation layer of its own — the structured data goes straight to whatever LLM is hosting the session.

A note on severity: Checkov's open-source CLI always returns severity: null — real per-check severity only exists when a scan is connected to Bridgecrew/Prisma Cloud's paid platform (--bc-api-key), which means an account and sending scan content to that platform. This project doesn't do that, so scanner.py assigns severity locally from a small _SEVERITY_MAP keyed by check ID, falling back to "info" for anything unmapped. It's a deliberate, disclosed approximation, not a Checkov feature.

insecure_example.tf has four intentional Terraform issues (open SSH ingress, a public+unencrypted S3 bucket, a wildcard IAM policy, a hardcoded RDS password) — 14 passed / 34 failed checks. insecure_example.Dockerfile has five (unpinned base image, ADD instead of COPY, port 22 exposed, no HEALTHCHECK, runs as root) — 26 passed / 5 failed checks.

Running it locally

Requires uv.

git clone https://github.com/SanjanaJanardhan/infra-guard.git
cd infra-guard
uv sync

Run the scanner directly:

uv run python3 scanner.py

Run the MCP server over stdio (for local clients like Claude Code/Desktop):

uv run python3 server.py

Run it over Streamable HTTP (for remote clients, or to reproduce the deployed setup):

uv run python3 server.py --transport streamable-http --port 8000

Connecting it to an MCP client

Claude Code / Claude Desktop — add to .mcp.json (project-level) or your global MCP config:

{
  "mcpServers": {
    "infra-guard": {
      "command": "uv",
      "args": ["--directory", "/absolute/path/to/infra-guard", "run", "python3", "server.py"]
    }
  }
}

Any Streamable HTTP client (including the live deployment above) — point it at:

https://infra-guard-production.up.railway.app/mcp

Running the playground locally

# terminal 1 — API
uv run python3 api.py

# terminal 2 — frontend
cd frontend
npm install
npm run dev

The frontend reads its API base URL from VITE_API_URL (see frontend/.env.local), defaulting to http://localhost:8001.

Enabling "Explain & Fix" (optional, local-only)

Clicking a finding shows an "Explain & Fix" button that calls Claude (Haiku) to generate a plain-English explanation and a suggested fixed code snippet, grounded in that finding's real check_id/resource/code_snippet.

This deliberately isn't enabled on the public deployment — the playground is public and unauthenticated, so wiring a paid API behind a button there means anyone's clicks spend your API credits. Instead, api.py looks for ANTHROPIC_API_KEY in the environment (via .env, loaded with python-dotenv) and returns {"configured": false} if it's missing, which the frontend renders as a plain "not enabled" message rather than a broken button.

To try it locally:

cp .env.example .env
# edit .env and add your own key from https://console.anthropic.com/
uv run python3 api.py

.env is gitignored — never commit a real key, and never set ANTHROPIC_API_KEY on the Railway API service.

Deployment

Three services on Railway, all built from Docker/Nixpacks with no manual server config:

  • MCP server — Dockerfile, Streamable HTTP

  • REST API — Dockerfile.api, same scanner.py core, powers the playground

  • Frontend — Railway's Nixpacks builder auto-detects the Vite app in frontend/; VITE_API_URL is set at build time to the deployed API's URL

Both Python services read PORT from the environment, so they adapt to whatever port Railway assigns with no config changes.

Stack

Python · Checkov · MCP Python SDK · FastAPI · React · Vite · uv · Docker · Railway

Roadmap

  • Core Terraform scanning engine

  • MCP server over stdio

  • Streamable HTTP transport

  • Deployed to Railway

  • Web frontend with a live playground

  • Dockerfile scanning, including a Terraform/Dockerfile toggle in the playground

  • AI-generated remediation ("Explain & Fix"), local-only by design

  • Cost-impact estimate for findings

License

MIT

Available Tools

2 tools
scan_dockerfile_fileA

Scan Dockerfile content for security misconfigurations using Checkov and return structured findings, in the same shape as scan_terraform_file (check ID, title, resource, line range, code snippet). Use this whenever the user asks to review, audit, or check the security of a Dockerfile.

Args: file_content: the raw text of a Dockerfile filename: original filename, used only for a friendlier label in output

Inputs: file_content (required), filename. Returns: object

scan_terraform_fileA

Scan Terraform (.tf) file content for security misconfigurations using Checkov and return structured findings.

Each finding includes the Checkov check ID, a human-readable title, the affected resource, its line range in the file, and the offending code snippet. Use this whenever the user asks to review, audit, or check the security of Terraform code.

Args: file_content: the raw text of a .tf file filename: original filename, used only for a friendlier label in output

Inputs: file_content (required), filename. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools are cleanly separated by file type: one handles Terraform files and the other handles Dockerfiles. There is no functional overlap or realistic risk of selecting the wrong tool.

    Naming Consistency5/5

    Both tools follow the same scan_<format>_file pattern, and the descriptions mirror each other for symmetry. Naming is predictable and internally consistent.

    Tool Count3/5

    Two tools is a thin set: they cover exactly Terraform and Dockerfile scanning, but the server named infra-guard feels narrow. The count is coherent but borderline for the apparent purpose.

    Completeness3/5

    For the supported file types, the scanning workflow is functional, but common IaC targets such as Kubernetes manifests or CloudFormation templates are absent. There is also no batch or exception-handling capability, leaving notable coverage gaps.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Enables local-first scanning of Terraform for security misconfigurations while an AI assistant writes the code, providing fixes and compliance mappings without uploading infrastructure code.
      8
      7
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables agents to review Terraform/Bicep infrastructure diffs against Checkov or builtin regex policies, returning structured findings for Azure security issues.
      Apache 2.0