infra-guard
infra-guard
一个 MCP 服务器,用于扫描 Terraform 和 Dockerfile 中的真实安全错误配置——开放的安全组、公开的 S3 存储桶、通配符 IAM 策略、硬编码的密钥、以 root 身份运行的容器——并返回结构化发现结果,而不是猜测。
它可以作为工具接入 Claude Code、Claude Desktop 或 Cursor。让你的 AI 助手审查你的基础设施代码,它会调用 infra-guard,从 Checkov 获得真实发现,并向你解释这些发现。
在浏览器中试用: infra-guard-frontend-production.up.railway.app —— 粘贴 Terraform,点击 Scan,即可看到真实发现。无需安装。
MCP 端点: https://infra-guard-production.up.railway.app/mcp
为什么会有这个项目
我之前在 A.P. Moller–Maersk 从事云基础设施工作——在真实规模上使用 Terraform、Docker 和 AWS 进行预置。大多数项目集项目都是普通的 Web 应用;而这个项目正是我希望存在的工具:把“我的 Terraform 是否有明显的安全漏洞”变成一个真实、结构化的答案,而不是 AI 助手的最佳猜测。
infra-guard 不会猜测。它用 Checkov 扫描你的文件,Checkov 是一个包含数百个内置检查的真实静态分析引擎,然后返回实际发现结果——检查 ID、标题、受影响资源、行范围、代码片段。承载会话的 LLM(Claude,或 MCP 连接另一端的任何模型)会用简单的英文解释这些发现。这个工具的职责只是保证正确。
Related MCP server: MCP Security Scanner
工作原理
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)
frontend/ → React + Vite playground that calls api.py, with a Terraform/Dockerfile togglescanner.py 调用 Checkov CLI,解析其 JSON 输出,并无论由哪个框架调用都返回同样的结构:
{
"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",
"start_line": 6,
"end_line": 24,
"code_snippet": "resource \"aws_security_group\" \"app_sg\" { ... }"
}
]
}server.py 暴露两个 MCP 工具:scan_terraform_file(file_content, filename) 和 scan_dockerfile_file(file_content, filename),它自身没有解释层——结构化数据直接发送给托管该会话的 LLM。
insecure_example.tf 包含四个故意留下的 Terraform 问题(开放 SSH 入站、一个公开且加密的 S3 桶、一个通配符 IAM 策略、一个硬编码的 RDS 密码)——14 项通过 / 34 项失败。insecure_example.Dockerfile 包含五个问题(基础镜像未固定版本、使用 ADD 而不是 COPY、暴露 22 端口、没有 HEALTHCHECK、以 root 身份运行)——26 项通过 / 5 项失败。
在本地运行
需要 uv。
git clone https://github.com/SanjanaJanardhan/infra-guard.git
cd infra-guard
uv sync直接运行扫描器:
uv run python3 scanner.py通过 stdio 运行 MCP 服务器(适用于 Claude Code/Desktop 等本地客户端):
uv run python3 server.py通过 Streamable HTTP 运行(适用于远程客户端,或复现已部署的配置):
uv run python3 server.py --transport streamable-http --port 8000连接到 MCP 客户端
Claude Code / Claude Desktop —— 将其添加到 .mcp.json(项目级)或你的全局 MCP 配置中:
{
"mcpServers": {
"infra-guard": {
"command": "uv",
"args": ["--directory", "/absolute/path/to/infra-guard", "run", "python3", "server.py"]
}
}
}任何 Streamable HTTP 客户端(包括上面的在线部署)—— 将其指向:
https://infra-guard-production.up.railway.app/mcp在本地运行演示环境
# terminal 1 — API
uv run python3 api.py
# terminal 2 — frontend
cd frontend
npm install
npm run dev前端从 VITE_API_URL 读取其 API 基础 URL(见 frontend/.env.local),默认值为 http://localhost:8001。
部署
三个服务都部署在 Railway 上,全部由 Docker/Nixpacks 构建,无需手动配置服务器:
MCP 服务器 ——
Dockerfile,Streamable HTTPREST API ——
Dockerfile.api,使用同一个scanner.py核心,驱动演示环境前端 —— Railway 的 Nixpacks 构建器自动检测
frontend/中的 Vite 应用;VITE_API_URL在构建时设置为已部署 API 的 URL
两个 Python 服务都会从环境中读取 PORT,因此无需修改配置即可适配 Railway 分配的任何端口。
技术栈
Python · Checkov · MCP Python SDK · FastAPI · React · Vite · uv · Docker · Railway
路线图
核心 Terraform 扫描引擎
基于 stdio 的 MCP 服务器
Streamable HTTP 传输
部署到 Railway
带实时演示环境的 Web 前端
Dockerfile 扫描,包括演示环境中的 Terraform/Dockerfile 切换
检查结果成本影响估算
许可证
MIT
Available Tools
2 toolsscan_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
Scored across 2 tools
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.
Both tools follow the same scan_<format>_file pattern, and the descriptions mirror each other for symmetry. Naming is predictable and internally consistent.
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.
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
Related MCP Connectors
Security scanner for AI-written code: SAST, secrets, dependencies, IaC, containers and DAST.
Zero-config MCP security scanner for AI-generated apps. 25K+ vulnerability patterns.
Query your team's drift, vulnerability, and upgrade data from any AI assistant. OAuth 2.1, 51 tools.
CVE lookups (NVD) and dependency-manifest audits (OSV) for AI agents. No API keys.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to scan project dependencies and Infrastructure as Code files for security vulnerabilities and misconfigurations. It also provides automated fixing capabilities to remediate identified security issues.183MIT

MCP Security Scannerofficial
AlicenseAqualityDmaintenanceIntegrates Checkov, Semgrep, Bandit, and ASH to provide comprehensive code security analysis for AI coding assistants.1519MIT No Attribution- AlicenseAqualityCmaintenanceEnables local-first scanning of Terraform for security misconfigurations while an AI assistant writes the code, providing fixes and compliance mappings without uploading infrastructure code.87Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables agents to review Terraform/Bicep infrastructure diffs against Checkov or builtin regex policies, returning structured findings for Azure security issues.Apache 2.0