AWS Cloud Development Kit MCP server

Integration for AWS Cloud Development Kit (CDK) best practices, infrastructure as code patterns, and security compliance with CDK Nag.
Back to servers
Provider
AWS
Release date
Apr 04, 2025
Language
Python
Package
Stats
2.5K stars

The AWS CDK MCP Server provides a specialized MCP (Model Context Protocol) server for AWS Cloud Development Kit (CDK) best practices, infrastructure as code patterns, and security compliance with CDK Nag. It serves as a companion tool to help developers implement CDK solutions following best practices and security guidelines.

Prerequisites

Before installing the MCP server, you'll need to prepare your environment:

  1. Install uv from Astral or the GitHub README
  2. Install Python using uv:
    uv python install 3.10
    
  3. Install AWS CDK CLI:
    npm install -g aws-cdk
    

Installation

To configure the MCP server, you need to update your MCP configuration file. For Amazon Q Developer CLI, edit ~/.aws/amazonq/mcp.json:

{
  "mcpServers": {
    "awslabs.cdk-mcp-server": {
      "command": "uvx",
      "args": ["awslabs.cdk-mcp-server@latest"],
      "env": {
        "FASTMCP_LOG_LEVEL": "ERROR"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

Available Tools

The MCP server offers several specialized tools:

  • CDKGeneralGuidance: Get prescriptive advice for CDK application development
  • GetAwsSolutionsConstructPattern: Find vetted architecture patterns
  • SearchGenAICDKConstructs: Discover GenAI-specific CDK constructs
  • GenerateBedrockAgentSchema: Create OpenAPI schemas for Bedrock Agent action groups
  • LambdaLayerDocumentationProvider: Get documentation for Lambda layers
  • ExplainCDKNagRule: Get detailed guidance on security rules
  • CheckCDKNagSuppressions: Validate CDK Nag suppressions

Using the CDK MCP Server

Working with CDK Nag

The server helps you understand and comply with CDK Nag security rules:

  1. When you encounter CDK Nag warnings during cdk synth:
    • Use ExplainCDKNagRule to get detailed information about specific rules
    • Fix the issue or add well-documented suppressions
    • Use CheckCDKNagSuppressions to validate your suppressions

Using AWS Solutions Constructs

To find and implement AWS Solutions Constructs:

  1. Use GetAwsSolutionsConstructPattern to search for appropriate patterns
  2. Follow the implementation guidance provided
  3. Access detailed documentation via aws-solutions-constructs://{pattern_name}

Working with Generative AI Constructs

For generative AI applications:

  1. Use SearchGenAICDKConstructs to find specialized GenAI constructs
  2. Access additional documentation via genai-cdk-constructs://{construct_type}/{construct_name}

Creating Bedrock Agent Schemas

When building Bedrock Agents with Action Groups:

  1. Create a Lambda function using BedrockAgentResolver from AWS Lambda Powertools
  2. Use GenerateBedrockAgentSchema to create the OpenAPI specification
  3. If schema generation succeeds, an openapi.json file will be created
  4. If there are import errors, the tool will generate a fallback script:
    • Install any missing dependencies
    • Run the script manually: python generate_schema.py
  5. Use the generated schema in your Agent CDK code with bedrock.ApiSchema.fromLocalAsset()

Lambda Layer Documentation

When working with Lambda layers:

  1. Use LambdaLayerDocumentationProvider to access comprehensive documentation
  2. Get code examples for various layer types
  3. Review best practices for implementation

Security Considerations

When using this MCP server:

  • Review all CDK Nag warnings and errors manually
  • Fix security issues rather than suppressing them when possible
  • Document clear justifications for any necessary suppressions
  • Use CheckCDKNagSuppressions to verify no unauthorized suppressions exist

Always conduct your own security assessment to ensure compliance with your organization's security practices and standards.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later