cfn-lint MCP Server

cfn-lint MCP Server

Validate AWS CloudFormation templates using cfn-lint, with tools for validation, version checking, and automatic upgrades.

Category
访问服务器

README

cfn-lint MCP Server (POC)

Validate AWS CloudFormation templates via cfn-lint exposed as MCP tools.

Installation

# Clone repository
git clone <repository-url>
cd cfn-lint-mcp-server

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e .

Claude Desktop Configuration

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "cfn-lint": {
      "command": "/opt/homebrew/bin/uv",
      "args": [
        "--directory",
        "[YOUR DIRECTORY TO THE MPC SERVER]",
        "run",
        "-m",
        "cfnlintmcp.server"
      ],
      "env": {
        "GITHUB_TOKEN": "optional_token_here"
      }
    }
  }
}

Run Standalone

# Using uv (recommended)
uv --directory /Users/brianterry/Documents/repos/guard-mcp run -m cfnlintmcp.server

# Using python directly
python -m cfnlintmcp.server

Testing

pytest -q

How it works

  • The server implements the MCP protocol over stdio and is launched by your MCP host (e.g., Claude Desktop).
  • On startup, it performs a one-time GitHub check for the latest cfn-lint release and caches the result in memory.
  • It exposes MCP tools to validate CloudFormation templates and inspect version info. A dedicated upgrade tool lets the host (LLM) ask users for consent and then update cfn-lint automatically.
  • Validation uses cfnlint.api.lint against in-memory template content; results are returned as structured JSON including rule metadata and locations.

Available tools

  • validate_cloudformation_template

    • Input: { "template_content": string, "regions"?: string[], "ignore_checks"?: string[] }
    • Output: { "valid": boolean, "cfn_lint_version": string, "matches": Match[] }
  • validate_with_guard

    • Input: { "template_content": string, "rules"?: string }
    • Output: Guard result dict (success, matches, guard_version, etc.)
    • Notes: Uses the guardpycfn package when installed; otherwise returns a helpful error. Install via:
      pip install guardpycfn
      
      PyPI: guardpycfn
  • get_server_info

    • Input: {}
    • Output: { "server_version", "cfn_lint_version", "mcp_protocol_version", "latest_cfn_lint_version", "upgrade_available", "last_version_check" }
  • upgrade_cfn_lint

    • Input: { "prefer_uv"?: boolean }
    • Output: { "status": "SUCCESS"|"NOOP"|"FAILED", "before_version", "after_version", "used_command", "message", "restart_required", "logs" }

Example: validate a template

Request (JSON-RPC sent by MCP host):

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "validate_cloudformation_template",
    "arguments": {
      "template_content": "AWSTemplateFormatVersion: '2010-09-09'\nResources:\n  MyBucket:\n    Type: AWS::S3::Bucket\n",
      "regions": ["us-east-1"],
      "ignore_checks": []
    }
  }
}

Response (text content contains JSON):

{
  "valid": true,
  "cfn_lint_version": "1.40.1",
  "matches": []
}

Example invalid response (truncated):

{
  "valid": false,
  "cfn_lint_version": "1.40.1",
  "matches": [
    {
      "rule": {
        "id": "E3030",
        "shortdesc": "Check if properties have a valid value",
        "description": "Check if properties have a valid value in case of an enumator"
      },
      "message": "'invalid.type' is not one of [...]",
      "location": {
        "path": ["Resources", "MyInstance", "Properties", "InstanceType"],
        "start": { "line": 7, "column": 7 },
        "end": { "line": 7, "column": 19 }
      },
      "level": "error"
    }
  ]
}

Example: get server info

{
  "server_version": "0.1.0",
  "cfn_lint_version": "1.40.1",
  "mcp_protocol_version": "2024-11-05",
  "latest_cfn_lint_version": "1.40.1",
  "upgrade_available": false,
  "last_version_check": "2025-10-10T14:30:00Z"
}

Example: upgrade cfn-lint via MCP

  1. Host (LLM) prompts the user: "A new version of cfn-lint is available (1.41.0). Update now?"
  2. On consent, host calls the tool:
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "upgrade_cfn_lint",
    "arguments": { "prefer_uv": true }
  }
}

Possible result:

{
  "status": "SUCCESS",
  "before_version": "1.40.1",
  "after_version": "1.41.0",
  "used_command": ["/opt/homebrew/bin/uv", "pip", "install", "-U", "cfn-lint"],
  "message": "cfn-lint upgraded",
  "restart_required": true,
  "logs": ["..."]
}

Note: The server does not restart itself; your MCP host should restart or relaunch the server to load the new version.

Using with an LLM (Claude Desktop example)

Once configured in Claude Desktop (see configuration above), you can just talk to the LLM naturally. The LLM will decide when to call the MCP tools.

Validate a template inline

You: "Validate this CloudFormation template in us-east-1" and paste your template.

The LLM will call validate_cloudformation_template with your pasted content and return structured findings (rule IDs, messages, and line/column ranges). If there are no matches, the template is valid for the given rules and region.

Check server and cfn-lint versions

You: "What version of cfn-lint is the server using?"

The LLM will call get_server_info and summarize cfn_lint_version, latest_cfn_lint_version, and whether an upgrade is available.

Offer and perform an upgrade (opt-in)

If a newer cfn-lint version is detected, the LLM can ask: "A new cfn-lint version is available (X.Y.Z). Would you like me to upgrade now?"

  • If you say "Yes": the LLM calls upgrade_cfn_lint (optionally with prefer_uv=true). The tool upgrades cfn-lint in the running environment and returns the before/after versions and logs.
  • After a successful upgrade, the LLM will instruct you (or your host) to restart the MCP server so the new version is loaded.

Example prompts

  • "Validate this CloudFormation template for us-west-2 and ignore W2001"
  • "Show me the cfn-lint version and whether an upgrade is available"
  • "Upgrade cfn-lint and then re-validate my template"

Environment Variables

  • GITHUB_TOKEN (optional): Raise GitHub API limits for version checks.
  • CFN_LINT_MCP_LOG_LEVEL (optional): Logging level (default: INFO).

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选