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
3.0K stars

The CDK MCP Server provides a comprehensive toolkit for AWS Cloud Development Kit (CDK) best practices, infrastructure patterns, and security compliance through CDK Nag integration. It helps streamline CDK development with predefined patterns, security automations, and specialized guidance for various AWS services.

Installation

Prerequisites

  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
    

Setup

Configure the MCP server by creating a configuration file. Here are two options:

Option 1: Using uvx (for Amazon Q Developer CLI)

Create or modify ~/.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": []
    }
  }
}

Option 2: Using Docker

First, build the Docker image:

docker build -t awslabs/cdk-mcp-server .

Then configure your MCP configuration:

{
  "mcpServers": {
    "awslabs.cdk-mcp-server": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "--interactive",
        "--env",
        "FASTMCP_LOG_LEVEL=ERROR",
        "awslabs/cdk-mcp-server:latest"
      ],
      "env": {},
      "disabled": false,
      "autoApprove": []
    }
  }
}

Usage

Available Tools

The CDK MCP Server provides several specialized tools:

  • CDKGeneralGuidance: Get prescriptive advice for building AWS applications with CDK
  • GetAwsSolutionsConstructPattern: Find vetted architecture patterns combining AWS services
  • SearchGenAICDKConstructs: Discover GenAI CDK constructs by name or features
  • GenerateBedrockAgentSchema: Create OpenAPI schemas for Bedrock Agent action groups
  • LambdaLayerDocumentationProvider: Access documentation for Lambda layers implementation
  • ExplainCDKNagRule: Get detailed guidance on CDK Nag security rules
  • CheckCDKNagSuppressions: Validate CDK Nag suppressions in your code

Accessing Resources

The server provides access to various resource types:

  • CDK Nag Rules: Access rule packs via cdk-nag://rules/{rule_pack}
  • AWS Solutions Constructs: Access patterns via aws-solutions-constructs://{pattern_name}
  • GenAI CDK Constructs: Access documentation via genai-cdk-constructs://{construct_type}/{construct_name}
  • Lambda Powertools: Get guidance on Lambda Powertools via lambda-powertools://{topic}

Using Bedrock Agent Schema Generation

When creating Bedrock Agents with Action Groups that use Lambda functions:

  1. Create a Lambda function using BedrockAgentResolver from AWS Lambda Powertools
  2. Use the GenerateBedrockAgentSchema tool to convert code files to compatible OpenAPI specifications
  3. If schema generation is successful, an openapi.json file will be created
  4. If dependencies are missing, the tool generates a fallback script (generate_schema.py)
  5. Install any missing dependencies and run the script manually:
    python generate_schema.py
    
  6. Use the generated schema with bedrock.ApiSchema.fromLocalAsset() in your CDK code

CDK Implementation Workflow

The recommended workflow when using the MCP server:

  1. Start with CDKGeneralGuidance to get overall recommendations
  2. Initialize your CDK app with cdk init app
  3. Choose an implementation approach:
    • Use GetAwsSolutionsConstructPattern for common patterns
    • Use SearchGenAICDKConstructs for GenAI features
    • Create custom CDK code for specific needs
  4. For Lambda functions, get documentation with LambdaLayerDocumentationProvider
  5. Synthesize your CDK app with cdk synth
  6. If CDK Nag warnings appear:
    • Use ExplainCDKNagRule to understand them
    • Fix issues or add suppressions as needed
    • Use CheckCDKNagSuppressions to validate suppressions
  7. Deploy your application with cdk deploy

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 the CheckCDKNagSuppressions tool to verify no unauthorized suppressions exist
  • Conduct your own security assessment before applying CDK NAG suppressions

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