A

AWS CDK MCP Server

Get prescriptive AWS CDK guidance through the Model Context Protocol. Provides best-practice construct patterns, stack architecture advice, and deployment strategies for AWS infrastructure defined in TypeScript or Python.

MCPCommunityinfrastructurev1.0.0Apache-2.0
0 views0 copies

MCP Server Configuration

Add to .claude/settings.json:

{ "mcpServers": { "aws-cdk": { "command": "npx", "args": ["-y", "@anthropic/claude-mcp-aws-cdk"], "env": { "AWS_REGION": "us-east-1", "AWS_PROFILE": "default" } } } }

Available Tools

ToolDescription
GetConstructAdviceGet best-practice patterns for specific AWS services
ReviewStackAnalyze a CDK stack for anti-patterns and security issues
GenerateConstructGenerate a CDK construct from a description of requirements
ExplainDeploymentExplain what cdk deploy will do for a given stack
MigrateCfnConvert CloudFormation templates to CDK TypeScript

Common Patterns

VPC with Best Practices

import * as ec2 from 'aws-cdk-lib/aws-ec2'; import { Stack, StackProps } from 'aws-cdk-lib'; export class NetworkStack extends Stack { public readonly vpc: ec2.Vpc; constructor(scope: Construct, id: string, props?: StackProps) { super(scope, id, props); this.vpc = new ec2.Vpc(this, 'MainVpc', { maxAzs: 3, natGateways: 1, // Cost optimization: 1 NAT GW for non-prod subnetConfiguration: [ { name: 'Public', subnetType: ec2.SubnetType.PUBLIC, cidrMask: 24, }, { name: 'Private', subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS, cidrMask: 24, }, { name: 'Isolated', subnetType: ec2.SubnetType.PRIVATE_ISOLATED, cidrMask: 24, }, ], flowLogs: { 'FlowLog': { destination: ec2.FlowLogDestination.toCloudWatchLogs(), trafficType: ec2.FlowLogTrafficType.REJECT, }, }, }); } }

Lambda API with API Gateway

import * as lambda from 'aws-cdk-lib/aws-lambda-nodejs'; import * as apigw from 'aws-cdk-lib/aws-apigateway'; const handler = new lambda.NodejsFunction(this, 'ApiHandler', { entry: 'src/handlers/api.ts', runtime: lambda.Runtime.NODEJS_20_X, memorySize: 256, timeout: Duration.seconds(30), tracing: lambda.Tracing.ACTIVE, environment: { TABLE_NAME: table.tableName, }, bundling: { minify: true, sourceMap: true, }, }); const api = new apigw.RestApi(this, 'Api', { restApiName: 'my-service', deployOptions: { stageName: 'prod', throttlingRateLimit: 1000, throttlingBurstLimit: 500, }, });

Setup

  1. Install the AWS CDK CLI: npm install -g aws-cdk
  2. Configure AWS credentials: aws configure or set AWS_PROFILE
  3. Add the MCP server configuration to .claude/settings.json
  4. Bootstrap CDK in your account: cdk bootstrap aws://ACCOUNT/REGION

Security Notes

  • The MCP server uses your local AWS credentials (never transmits them)
  • Review generated IAM policies before deploying -- prefer least-privilege
  • Enable CDK Nag for automated compliance checks: import { AwsSolutionsChecks } from 'cdk-nag'
  • Use cdk diff to review changes before cdk deploy
  • Store secrets in AWS Secrets Manager, reference via secretsmanager.Secret.fromSecretNameV2()
Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates