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
Visit Server

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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured