Skip to main content
Glama
AWS CDK MCP Server
by AkM-2018

AWS CDK MCP Server

MCP server for AWS Cloud Development Kit (CDK) best practices, infrastructure as code patterns, and security compliance with CDK Nag.

Features

CDK General Guidance

  • Prescriptive patterns with AWS Solutions Constructs and GenAI CDK libraries

  • Structured decision flow for choosing appropriate implementation approaches

  • Security automation through CDK Nag integration and Lambda Powertools

CDK Nag Integration

  • Work with CDK Nag rules for security and compliance

  • Explain specific CDK Nag rules with AWS Well-Architected guidance

  • Check if CDK code contains Nag suppressions that require human review

AWS Solutions Constructs

  • Search and discover AWS Solutions Constructs patterns

  • Find recommended patterns for common architecture needs

  • Get detailed documentation on Solutions Constructs

Generative AI CDK Constructs

  • Search for GenAI CDK constructs by name or type

  • Discover specialized constructs for AI/ML workloads

  • Get implementation guidance for generative AI applications

Lambda Layer Documentation Provider

  • Access comprehensive documentation for AWS Lambda layers

  • Get code examples for generic Lambda layers and Python-specific layers

  • Retrieve directory structure information and implementation best practices

  • Seamless integration with AWS Documentation MCP Server for detailed documentation

Amazon Bedrock Agent Schema Generation

  • Use this tool when creating Bedrock Agents with Action Groups that use Lambda functions

  • Streamline the creation of Bedrock Agent schemas

  • Convert code files to compatible OpenAPI specifications

Developer Notes

  • Requirements: Your Lambda function must use BedrockAgentResolver from AWS Lambda Powertools

  • Lambda Dependencies: If schema generation fails, a fallback script will be generated. If you see error messages about missing dependencies, install them and then run the script again.

  • Integration: Use the generated schema with bedrock.ApiSchema.fromLocalAsset() in your CDK code

Related MCP server: CDK API MCP Server

CDK Implementation Workflow

This diagram provides a comprehensive view of the recommended CDK implementation workflow:

graph TD
    Start([Start]) --> A["CDKGeneralGuidance"]
    A --> Init["cdk init app"]

    Init --> B{Choose Approach}
    B -->|"Common Patterns"| C1["GetAwsSolutionsConstructPattern"]
    B -->|"GenAI Features"| C2["SearchGenAICDKConstructs"]
    B -->|"Custom Needs"| C3["Custom CDK Code"]

    C1 --> D1["Implement Solutions Construct"]
    C2 --> D2["Implement GenAI Constructs"]
    C3 --> D3["Implement Custom Resources"]

    %% Bedrock Agent with Action Groups specific flow
    D2 -->|"For Bedrock Agents<br/>with Action Groups"| BA["Create Lambda with<br/>BedrockAgentResolver"]

    %% Schema generation flow
    BA --> BS["GenerateBedrockAgentSchema"]
    BS -->|"Success"| JSON["openapi.json created"]
    BS -->|"Import Errors"| BSF["Tool generates<br/>generate_schema.py"]
    BSF -->|"Missing dependencies?"| InstallDeps["Install dependencies"]
    InstallDeps --> BSR["Run script manually:<br/>python generate_schema.py"]
    BSR --> JSON["openapi.json created"]

    %% Use schema in Agent CDK
    JSON --> AgentCDK["Use schema in<br/>Agent CDK code"]
    AgentCDK --> D2

    %% Conditional Lambda Powertools implementation
    D1 & D2 & D3 --> HasLambda{"Using Lambda<br/>Functions?"}
    HasLambda --> UseLayer{"Using Lambda<br/>Layers?"}
    UseLayer -->|"Yes"| LLDP["LambdaLayerDocumentationProvider"]

    HasLambda -->|"No"| SkipL["Skip"]

    %% Rest of workflow
    LLDP["LambdaLayerDocumentationProvider"] --> Synth["cdk synth"]
    SkipL --> Synth

    Synth --> Nag{"CDK Nag<br/>warnings?"}
    Nag -->|Yes| E["ExplainCDKNagRule"]
    Nag -->|No| Deploy["cdk deploy"]

    E --> Fix["Fix or Add Suppressions"]
    Fix --> CN["CheckCDKNagSuppressions"]
    CN --> Synth

    %% Styling with darker colors
    classDef default fill:#424242,stroke:#ffffff,stroke-width:1px,color:#ffffff;
    classDef cmd fill:#4a148c,stroke:#ffffff,stroke-width:1px,color:#ffffff;
    classDef tool fill:#01579b,stroke:#ffffff,stroke-width:1px,color:#ffffff;
    classDef note fill:#1b5e20,stroke:#ffffff,stroke-width:1px,color:#ffffff;
    classDef output fill:#006064,stroke:#ffffff,stroke-width:1px,color:#ffffff;
    classDef decision fill:#5d4037,stroke:#ffffff,stroke-width:1px,color:#ffffff;

    class Init,Synth,Deploy,BSR cmd;
    class A,C1,C2,BS,E,CN,LLDP tool;
    class JSON output;
    class HasLambda,UseLayer,Nag decision;

Available MCP 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

Available MCP Resources

  • 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}

Prerequisites

  1. Install uv from Astral or the GitHub README

  2. Install Python using uv python install 3.10

  3. Install AWS CDK CLI using npm install -g aws-cdk (Note: The MCP server itself doesn't use the CDK CLI directly, but it guides users through CDK application development that requires the CLI)

Installation

Install MCP Server

Configure the MCP server in your MCP client configuration (e.g., 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": []
    }
  }
}

or docker after a successful docker build -t awslabs/cdk-mcp-server .:

  {
    "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": []
      }
    }
  }

Security Considerations

When using this MCP server, you should consider:

  • Reviewing all CDK Nag warnings and errors manually

  • Fixing security issues rather than suppressing them whenever possible

  • Documenting clear justifications for any necessary suppressions

  • Using the CheckCDKNagSuppressions tool to verify no unauthorized suppressions exist

Before applying CDK NAG Suppressions, you should consider conducting your own independent assessment to ensure that your use would comply with your own specific security and quality control practices and standards, as well as the local laws, rules, and regulations that govern you and your content.

Available Tools

7 tools
CDKGeneralGuidanceC

Use this tool to get prescriptive CDK advice for building applications on AWS.

Args:
    ctx: MCP context

Inputs: no named parameters.

CheckCDKNagSuppressionsA

Check if CDK code contains Nag suppressions that require human review.

Scans TypeScript/JavaScript code for NagSuppressions usage to ensure security
suppressions receive proper human oversight and justification.

Args:
    ctx: MCP context
    code: CDK code to analyze (TypeScript/JavaScript)
    file_path: Path to a file containing CDK code to analyze

Returns:
    Analysis results with suppression details and security guidance

Inputs: code, file_path.

ExplainCDKNagRuleC

Explain a specific CDK Nag rule with AWS Well-Architected guidance.

CDK Nag is a crucial tool for ensuring your CDK applications follow AWS security best practices.

Basic implementation:
```typescript
import { App } from 'aws-cdk-lib';
import { AwsSolutionsChecks } from 'cdk-nag';

const app = new App();
// Create your stack
const stack = new MyStack(app, 'MyStack');
// Apply CDK Nag
AwsSolutionsChecks.check(app);
```

Optional integration patterns:

1. Using environment variables:
```typescript
if (process.env.ENABLE_CDK_NAG === 'true') {
  AwsSolutionsChecks.check(app);
}
```

2. Using CDK context parameters:
```typescript
3. Environment-specific application:
```typescript
const environment = app.node.tryGetContext('environment') || 'development';
if (['production', 'staging'].includes(environment)) {
  AwsSolutionsChecks.check(stack);
}
```

For more information on specific rule packs:
- Use resource `cdk-nag://rules/{rule_pack}` to get all rules for a specific pack
- Use resource `cdk-nag://warnings/{rule_pack}` to get warnings for a specific pack
- Use resource `cdk-nag://errors/{rule_pack}` to get errors for a specific pack

Args:
    ctx: MCP context
    rule_id: The CDK Nag rule ID (e.g., 'AwsSolutions-IAM4')

Returns:
    Dictionary with detailed explanation and remediation steps

Inputs: rule_id (required).

GenerateBedrockAgentSchemaA

Generate OpenAPI schema for Bedrock Agent Action Groups from a file.

This tool converts a Lambda file with BedrockAgentResolver into a Bedrock-compatible
OpenAPI schema. It uses a progressive approach to handle common issues:
1. Direct import of the Lambda file
2. Simplified version with problematic imports commented out
3. Fallback script generation if needed

Args:
    ctx: MCP context
    lambda_code_path: Path to Python file containing BedrockAgentResolver app
    output_path: Where to save the generated schema

Returns:
    Dictionary with schema generation results, including status, path to generated schema,
    and diagnostic information if errors occurred

Inputs: lambda_code_path (required), output_path (required).

GetAwsSolutionsConstructPatternA

Search and discover AWS Solutions Constructs patterns.

AWS Solutions Constructs are vetted architecture patterns that combine multiple
AWS services to solve common use cases following AWS Well-Architected best practices.

Key benefits:
- Accelerated Development: Implement common patterns without boilerplate code
- Best Practices Built-in: Security, reliability, and performance best practices
- Reduced Complexity: Simplified interfaces for multi-service architectures
- Well-Architected: Patterns follow AWS Well-Architected Framework principles

When to use Solutions Constructs:
- Implementing common architecture patterns (e.g., API + Lambda + DynamoDB)
- You want secure defaults and best practices applied automatically
- You need to quickly prototype or build production-ready infrastructure

This tool provides metadata about patterns. For complete documentation,
use the resource URI returned in the 'documentation_uri' field.

Args:
    ctx: MCP context
    pattern_name: Optional name of the specific pattern (e.g., 'aws-lambda-dynamodb')
    services: Optional list of AWS services to search for patterns that use them
             (e.g., ['lambda', 'dynamodb'])

Returns:
    Dictionary with pattern metadata including description, services, and documentation URI

Inputs: pattern_name, services.

LambdaLayerDocumentationProviderB

Provide documentation sources for Lambda layers.

This tool returns information about where to find documentation for Lambda layers
and instructs the MCP Client to fetch and process this documentation.

Args:
    ctx: MCP context
    layer_type: Type of layer ("generic" or "python")

Returns:
    Dictionary with documentation source information

Inputs: layer_type (required).

SearchGenAICDKConstructsA

Search for GenAI CDK constructs by name or type.

The search is flexible and will match any of your search terms (OR logic).
It handles common variations like singular/plural forms and terms with/without spaces.
Content is fetched dynamically from GitHub to ensure the most up-to-date documentation.

Examples:
- "bedrock agent" - Returns all agent-related constructs
- "knowledgebase vector" - Returns knowledge base constructs related to vector stores
- "agent actiongroups" - Returns action groups for agents
- "opensearch vector" - Returns OpenSearch vector constructs

The search supports subdirectory content (like knowledge bases and their sections)
and will find matches across all available content.

Args:
    ctx: MCP context
    query: Search term(s) to find constructs by name or description
    construct_type: Optional filter by construct type ('bedrock', 'opensearchserverless', etc.)

Returns:
    Dictionary with matching constructs and resource URIs

Inputs: query, construct_type.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 7 tools

    Disambiguation4/5

    Most tools have distinct purposes focused on different aspects of CDK development: guidance, security analysis, construct discovery, and documentation. However, 'ExplainCDKNagRule' and 'CheckCDKNagSuppressions' both relate to CDK Nag security analysis and could potentially overlap in usage scenarios, though their specific functions differ (rule explanation vs. suppression checking).

    Naming Consistency2/5

    The naming is highly inconsistent with multiple patterns: 'CDKGeneralGuidance' (CamelCase), 'CheckCDKNagSuppressions' (CamelCase with verb prefix), 'ExplainCDKNagRule' (CamelCase with verb prefix), 'GenerateBedrockAgentSchema' (CamelCase with verb prefix), 'GetAwsSolutionsConstructPattern' (CamelCase with verb prefix), 'LambdaLayerDocumentationProvider' (CamelCase), and 'SearchGenAICDKConstructs' (CamelCase with verb prefix). There's no unified naming convention across the toolset.

    Tool Count4/5

    With 7 tools, the count is reasonable for a CDK-focused server. The tools cover guidance, security analysis, construct discovery, and documentation - a well-scoped set that doesn't feel overly sparse or bloated. However, the scope is somewhat broad (covering both general CDK and specific GenAI/Bedrock constructs), which slightly reduces the appropriateness.

    Completeness3/5

    The toolset covers several important CDK areas: guidance, security analysis (Nag), construct discovery (Solutions Constructs and GenAI constructs), and documentation. However, there are notable gaps in core CDK operations - no tools for actually deploying, synthesizing, or managing CDK stacks/applications. The focus is heavily on advisory and discovery functions rather than operational capabilities.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      Not graded
      maintenance
      Provides comprehensive documentation about AWS AgentCore framework to GenAI tools, enabling users to build production-ready AI agents with enterprise-grade security, observability, and scalability. Offers guidance on identity management, API integration, monitoring, code execution, memory storage, and tool integration for AI agents.
      7
      Apache 2.0
    • A
      license
      Not graded
      quality
      F
      maintenance
      Provides offline access to AWS CDK API references and integration test code samples for both stable (aws-cdk-lib) and alpha (@aws-cdk) modules, enabling developers to browse CDK documentation through MCP resources.
      73 PyPI
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      36 enterprise MCP tools for AWS security, infrastructure generation, AI workflows, and agent governance. IAM validation, MFA compliance, CloudFormation/SAM generation, DynamoDB design, OAuth validation, vector embeddings, error analysis, data lake readiness, 12 ACI governance tools for AI agent safety, and 4 local interview tools.
      58 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to assess AWS environments against the AWS Security Reference Architecture (SRA) by providing tools to discover, describe, and run security checks across AWS services and accounts.
      5
      3
      Apache 2.0