awslabs.cdk-mcp-server 0.0.81650__py3-none-any.whl → 0.0.101004__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,6 +63,7 @@ mcp.tool(name='CheckCDKNagSuppressions')(tools.check_cdk_nag_suppressions_tool)
63
63
  mcp.tool(name='GenerateBedrockAgentSchema')(tools.bedrock_schema_generator_from_file)
64
64
  mcp.tool(name='GetAwsSolutionsConstructPattern')(tools.get_aws_solutions_construct_pattern)
65
65
  mcp.tool(name='SearchGenAICDKConstructs')(tools.search_genai_cdk_constructs)
66
+ mcp.tool(name='LambdaLayerDocumentationProvider')(tools.lambda_layer_documentation_provider)
66
67
 
67
68
 
68
69
  def main():
@@ -22,6 +22,7 @@ from awslabs.cdk_mcp_server.data.cdk_nag_parser import (
22
22
  from awslabs.cdk_mcp_server.data.genai_cdk_loader import (
23
23
  list_available_constructs,
24
24
  )
25
+ from awslabs.cdk_mcp_server.data.lambda_layer_parser import LambdaLayerParser
25
26
  from awslabs.cdk_mcp_server.data.schema_generator import generate_bedrock_schema_from_file
26
27
  from awslabs.cdk_mcp_server.data.solutions_constructs_parser import (
27
28
  fetch_pattern_list,
@@ -476,3 +477,55 @@ async def search_genai_cdk_constructs(
476
477
  }
477
478
  except Exception as e:
478
479
  return {'error': f'Error searching constructs: {str(e)}', 'status': 'error'}
480
+
481
+
482
+ async def lambda_layer_documentation_provider(
483
+ ctx: Context,
484
+ layer_type: str, # "generic" or "python"
485
+ ) -> Dict[str, Any]:
486
+ """Provide documentation sources for Lambda layers.
487
+
488
+ This tool returns information about where to find documentation for Lambda layers
489
+ and instructs the MCP Client to fetch and process this documentation.
490
+
491
+ Args:
492
+ ctx: MCP context
493
+ layer_type: Type of layer ("generic" or "python")
494
+
495
+ Returns:
496
+ Dictionary with documentation source information
497
+ """
498
+ if layer_type.lower() == 'python':
499
+ # For Python layers, use AWS Documentation MCP Server
500
+ return {
501
+ 'layer_type': 'python',
502
+ 'documentation_source': {
503
+ 'server': 'awslabs.aws-documentation-mcp-server',
504
+ 'tool': 'read_documentation',
505
+ 'parameters': {'url': LambdaLayerParser.PYTHON_LAYER_URL, 'max_length': 10000},
506
+ },
507
+ 'documentation_usage_guide': {
508
+ 'when_to_fetch_full_docs': 'Fetch full documentation to view detailed property definitions, learn about optional parameters, and find additional code examples',
509
+ 'contains_sample_code': True,
510
+ 'contains_props_documentation': True,
511
+ },
512
+ 'code_generation_guidance': {
513
+ 'imports': [
514
+ "import { PythonLayerVersion } from '@aws-cdk/aws-lambda-python-alpha'"
515
+ ],
516
+ 'construct_types': {'python': 'PythonLayerVersion'},
517
+ 'required_properties': {'python': ['entry']},
518
+ 'sample_code': "new python.PythonLayerVersion(this, 'MyLayer', {\n entry: '/path/to/my/layer', // point this to your library's directory\n})",
519
+ },
520
+ }
521
+ else:
522
+ # For all other layer types (including generic), use the existing parser
523
+ docs = await LambdaLayerParser.fetch_lambda_layer_docs()
524
+ layer_docs = docs['generic_layers']
525
+
526
+ return {
527
+ 'layer_type': 'generic',
528
+ 'code_examples': layer_docs['examples'],
529
+ 'directory_structure': layer_docs['directory_structure'],
530
+ 'source_url': layer_docs['url'],
531
+ }
@@ -0,0 +1,231 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
4
+ # with the License. A copy of the License is located at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
9
+ # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
10
+ # and limitations under the License.
11
+
12
+ """Lambda layer documentation parser module."""
13
+
14
+ import httpx
15
+ import logging
16
+ from bs4 import BeautifulSoup
17
+ from bs4.element import Tag
18
+ from typing import Any, Dict, List, Optional
19
+
20
+
21
+ # Set up logging
22
+ logger = logging.getLogger(__name__)
23
+
24
+
25
+ class LambdaLayerParser:
26
+ """Parser for Lambda layer documentation from AWS docs."""
27
+
28
+ # Documentation URLs
29
+ GENERIC_LAYER_URL = (
30
+ 'https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda-readme.html#layers'
31
+ )
32
+ PYTHON_LAYER_URL = 'https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-lambda-python-alpha.PythonLayerVersion.html'
33
+
34
+ # Search patterns to directly find sections when headers aren't working
35
+ LAYER_SECTION_PATTERNS = ['layers', 'layer version', 'layerversion']
36
+
37
+ @classmethod
38
+ async def fetch_page(cls, url: str) -> Optional[str]:
39
+ """Fetch a page from AWS documentation."""
40
+ try:
41
+ async with httpx.AsyncClient() as client:
42
+ response = await client.get(url)
43
+ if response.status_code == 200:
44
+ return response.text
45
+ else:
46
+ logger.error(f'Failed to fetch {url}: HTTP {response.status_code}')
47
+ return None
48
+ except Exception as e:
49
+ logger.error(f'Error fetching {url}: {str(e)}')
50
+ return None
51
+
52
+ @classmethod
53
+ def extract_code_examples(cls, html_section: Optional[str]) -> List[Dict[str, str]]:
54
+ """Extract code examples from an HTML section."""
55
+ if not html_section:
56
+ return []
57
+
58
+ soup = BeautifulSoup(html_section, 'html.parser')
59
+ code_blocks = soup.find_all('pre')
60
+
61
+ examples = []
62
+ for block in code_blocks:
63
+ # Make sure we're working with a Tag
64
+ if not isinstance(block, Tag):
65
+ continue
66
+
67
+ # Try to determine the language
68
+ language = 'typescript' # Default
69
+ classes = block.attrs.get('class', [])
70
+
71
+ # Make sure classes is a list of strings
72
+ if not isinstance(classes, list):
73
+ classes = [str(classes)]
74
+
75
+ class_str = ' '.join(classes)
76
+
77
+ if 'python' in class_str.lower():
78
+ language = 'python'
79
+ elif 'javascript' in class_str.lower():
80
+ language = 'javascript'
81
+
82
+ # Get the code content
83
+ code = block.get_text()
84
+ examples.append({'language': language, 'code': code})
85
+
86
+ return examples
87
+
88
+ @classmethod
89
+ def extract_directory_structure(cls, html_section: Optional[str]) -> Optional[str]:
90
+ """Extract directory structure information from HTML section."""
91
+ if not html_section:
92
+ return None
93
+
94
+ soup = BeautifulSoup(html_section, 'html.parser')
95
+
96
+ # Look for pre blocks that might contain directory structure
97
+ pre_blocks = soup.find_all('pre')
98
+ for block in pre_blocks:
99
+ text = block.get_text()
100
+ if '/' in text and (
101
+ 'directory' in text.lower()
102
+ or 'structure' in text.lower()
103
+ or 'layer' in text.lower()
104
+ ):
105
+ return text
106
+
107
+ # Look for paragraphs that might describe directory structure
108
+ paragraphs = soup.find_all('p')
109
+ for p in paragraphs:
110
+ text = p.get_text()
111
+ if (
112
+ 'directory' in text.lower() and 'structure' in text.lower()
113
+ ) or 'layer' in text.lower():
114
+ return text
115
+
116
+ return None
117
+
118
+ @classmethod
119
+ def find_layer_content(cls, html: Optional[str]) -> Optional[str]:
120
+ """Find Lambda layer content using multiple strategies."""
121
+ if not html:
122
+ return None
123
+
124
+ soup = BeautifulSoup(html, 'html.parser')
125
+
126
+ # Strategy 1: Find section by id
127
+ section = soup.find(id='layers')
128
+ if section and isinstance(section, Tag):
129
+ # If we found an anchor, get its parent and look for the actual content
130
+ if section.name == 'a':
131
+ parent = section.parent
132
+ if parent and isinstance(parent, Tag) and parent.name and parent.name[0] == 'h':
133
+ # We found a header, extract all content until the next header of same or higher level
134
+ content = []
135
+ content.append(str(parent))
136
+
137
+ header_level = int(parent.name[1])
138
+ sibling = parent.next_sibling
139
+
140
+ while sibling:
141
+ if (
142
+ isinstance(sibling, Tag)
143
+ and sibling.name
144
+ and sibling.name[0] == 'h'
145
+ and int(sibling.name[1]) <= header_level
146
+ ):
147
+ break
148
+ if isinstance(sibling, Tag) and sibling.name:
149
+ content.append(str(sibling))
150
+ sibling = sibling.next_sibling
151
+
152
+ return ''.join(content)
153
+
154
+ # Strategy 2: Look for headers containing layer keywords
155
+ for tag in ['h1', 'h2', 'h3', 'h4']:
156
+ headers = soup.find_all(tag)
157
+ for header in headers:
158
+ if not isinstance(header, Tag):
159
+ continue
160
+
161
+ text = header.get_text().lower()
162
+ if any(pattern in text for pattern in cls.LAYER_SECTION_PATTERNS):
163
+ # Found a relevant header, extract all content until the next header of same or higher level
164
+ content = []
165
+ content.append(str(header))
166
+
167
+ if not header.name:
168
+ continue
169
+
170
+ header_level = int(header.name[1])
171
+ sibling = header.next_sibling
172
+
173
+ while sibling:
174
+ if (
175
+ isinstance(sibling, Tag)
176
+ and sibling.name
177
+ and sibling.name[0] == 'h'
178
+ and int(sibling.name[1]) <= header_level
179
+ ):
180
+ break
181
+ if isinstance(sibling, Tag) and sibling.name:
182
+ content.append(str(sibling))
183
+ sibling = sibling.next_sibling
184
+
185
+ return ''.join(content)
186
+
187
+ # Strategy 3: Look for content div with class="api" or class="props"
188
+ content_divs = soup.find_all('div', class_=['api', 'props'])
189
+ if content_divs:
190
+ return ''.join(str(div) for div in content_divs)
191
+
192
+ # Strategy 4: Look for table with class containing 'cdk'
193
+ tables = soup.find_all('table')
194
+ for table in tables:
195
+ if not isinstance(table, Tag):
196
+ continue
197
+
198
+ classes = table.attrs.get('class', [])
199
+ if not isinstance(classes, list):
200
+ classes = [str(classes)]
201
+
202
+ if any('cdk' in str(cls_name) for cls_name in classes):
203
+ return str(table)
204
+
205
+ return None
206
+
207
+ @classmethod
208
+ async def fetch_lambda_layer_docs(cls) -> Dict[str, Any]:
209
+ """Fetch Lambda layer documentation from AWS docs."""
210
+ logger.info('Fetching Lambda layer documentation from AWS')
211
+
212
+ # Fetch only the generic page
213
+ generic_html = await cls.fetch_page(cls.GENERIC_LAYER_URL)
214
+
215
+ # Extract relevant sections using our specialized finder
216
+ generic_layers_section = cls.find_layer_content(generic_html)
217
+
218
+ # Extract code examples and directory structure
219
+ generic_examples = cls.extract_code_examples(generic_layers_section)
220
+ generic_dir_structure = cls.extract_directory_structure(generic_layers_section)
221
+
222
+ # Compile the results
223
+ result = {
224
+ 'generic_layers': {
225
+ 'examples': generic_examples,
226
+ 'directory_structure': generic_dir_structure,
227
+ 'url': cls.GENERIC_LAYER_URL,
228
+ }
229
+ }
230
+
231
+ return result
@@ -288,7 +288,7 @@ def extract_services_from_pattern_name(pattern_name: str) -> List[str]:
288
288
  'iot': 'IoT Core',
289
289
  'elasticsearch': 'Elasticsearch',
290
290
  'opensearch': 'OpenSearch',
291
- 'secretsmanager': 'Secrets Manager',
291
+ 'secretsmanager': 'Secrets Manager', # pragma: allowlist secret
292
292
  'sagemakerendpoint': 'SageMaker Endpoint',
293
293
  'stepfunctions': 'Step Functions',
294
294
  'wafwebacl': 'WAF Web ACL',
@@ -45,84 +45,106 @@ cdk diff
45
45
  - Generates CloudFormation templates for inspection
46
46
  - Provides more informative error messages for debugging
47
47
 
48
- ## Decision Flow for CDK Implementation
49
-
50
- When implementing AWS infrastructure with CDK, consider these complementary approaches:
51
-
52
- 1. **For Common Architecture Patterns: AWS Solutions Constructs**
53
- - Use the `GetAwsSolutionsConstructPattern` tool to search for patterns that match your use case
54
- - Example: `GetAwsSolutionsConstructPattern(services=["lambda", "dynamodb"])`
55
- - AWS Solutions Constructs implement AWS best practices by default
56
- - For complete documentation: `aws-solutions-constructs://{pattern_name}`
57
- - Ideal for REST APIs, serverless backends, data processing pipelines, etc.
58
-
59
- 2. **For GenAI/AI/ML Use Cases: GenAI CDK Constructs**
60
- - Use the `SearchGenAICDKConstructs` tool for specialized AI/ML constructs
61
- - These simplify implementation of Bedrock, SageMaker, and other AI services
62
- - Perfect for agents, knowledge bases, vector stores, and other GenAI components
63
-
64
- **Installation:**
65
-
66
- ```typescript
67
- // TypeScript
68
- // Create or use an existing CDK application
69
- cdk init app --language typescript
70
- // Install the package
71
- npm install @cdklabs/generative-ai-cdk-constructs
72
- // Import the library
73
- import * as genai from '@cdklabs/generative-ai-cdk-constructs';
74
- ```
75
-
76
- ```python
77
- # Python
78
- # Create or use an existing CDK application
79
- cdk init app --language python
80
- # Install the package
81
- pip install cdklabs.generative-ai-cdk-constructs
82
- # Import the library
83
- import cdklabs.generative_ai_cdk_constructs
84
- ```
85
-
86
- 3. **For All Projects: Apply CDK Nag**
87
- - Always apply CDK Nag to ensure security best practices
88
- - Use the `ExplainCDKNagRule` tool to understand specific rules
48
+ ## CDK Implementation Approach and Workflow
89
49
 
90
- 4. **For Custom Requirements: Custom Implementation**
91
- - Create custom CDK code when no suitable constructs exist
92
- - Follow AWS Well-Architected best practices
50
+ # Compare deployed stack with current state
93
51
 
94
- > **IMPORTANT**: AWS Solutions Constructs and GenAI CDK Constructs are complementary and can be used together in the same project. For example, you might use GenAI CDK Constructs for Bedrock components and AWS Solutions Constructs for the REST API and database layers of your application.
52
+ ### Common Architecture Patterns
95
53
 
96
- ## Key Principles
54
+ **For standard application architectures:**
97
55
 
98
- - **Security First**: Always implement security best practices by default
99
- - **Cost Optimization**: Design resources to minimize costs while meeting requirements
100
- - **Operational Excellence**: Implement proper monitoring, logging, and observability
101
- - **Serverless-First**: Prefer serverless services when possible
102
- - **Infrastructure as Code**: Use CDK to define all infrastructure
103
- - **Use Vetted Patterns**: Prefer AWS Solutions Constructs over custom implementations
104
- - **Regional Awareness**: Consider regional availability and constraints for services
56
+ - Use the `GetAwsSolutionsConstructPattern` tool to find pre-built patterns
57
+ - AWS Solutions Constructs implement AWS best practices by default
58
+ - Ideal for REST APIs, serverless backends, data processing pipelines, etc.
59
+ - Example: `GetAwsSolutionsConstructPattern(services=["lambda", "dynamodb"])`
60
+ - For complete documentation: `aws-solutions-constructs://{pattern_name}`
105
61
 
106
- ## Amazon Bedrock Cross-Region Inference Profiles
62
+ **Key benefits:**
63
+ - Accelerated development with vetted patterns
64
+ - Built-in security and best practices
65
+ - Reduced complexity for multi-service architectures
107
66
 
108
- When working with Amazon Bedrock foundation models, many models (including Claude models, Meta Llama models, and Amazon's own Nova models) require the use of inference profiles rather than direct on-demand usage in specific regions.
67
+ ### GenAI/AI/ML Implementations
109
68
 
110
- ### Key Considerations
69
+ **For AI/ML and generative AI workloads:**
111
70
 
112
- - **Required for Many Models**: Foundation models like Claude 3 often require inference profiles
113
- - **Regional Configuration**: Profiles are configured for specific geographic regions (US, EU, APAC)
114
- - **Error Prevention**: Prevents errors like "Invocation with on-demand throughput isn't supported"
115
- - **Implementation**: Use the `CrossRegionInferenceProfile` class from the GenAI CDK constructs
71
+ - Use the `SearchGenAICDKConstructs` tool for specialized AI/ML constructs
72
+ - These simplify implementation of Bedrock, SageMaker, and other AI services
73
+ - Perfect for agents, knowledge bases, vector stores, and other GenAI components
116
74
 
117
- For detailed implementation examples, see the `genai-cdk-constructs://bedrock/profiles` resource.
75
+ **Installation:**
118
76
 
119
- ### Regional Considerations
77
+ ```typescript
78
+ // TypeScript
79
+ npm install @cdklabs/generative-ai-cdk-constructs
80
+ import * as genai from '@cdklabs/generative-ai-cdk-constructs';
81
+ ```
82
+
83
+ ```python
84
+ # Python
85
+ pip install cdklabs.generative-ai-cdk-constructs
86
+ import cdklabs.generative_ai_cdk_constructs
87
+ ```
120
88
 
121
- - **Model Availability**: Not all foundation models are available in all regions
122
- - **Performance**: Choose the region closest to your users for optimal latency
123
- - **Compliance**: Consider data residency requirements when selecting regions
89
+ **Regional considerations for Bedrock:**
90
+ - Many foundation models require inference profiles in specific regions
91
+ - Use `CrossRegionInferenceProfile` class for proper configuration
92
+ - For details: `genai-cdk-constructs://bedrock/profiles`
124
93
 
125
- Always check the [Amazon Bedrock documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html) for the latest information on model availability and regional constraints.
94
+ ### Combined Implementation Patterns
95
+
96
+ **Important:** AWS Solutions Constructs and GenAI CDK Constructs can be used together in the same project:
97
+
98
+ - Use GenAI CDK Constructs for Bedrock components (agents, knowledge bases)
99
+ - Use AWS Solutions Constructs for REST APIs, databases, and other infrastructure
100
+ - Apply CDK Nag across all components for security validation
101
+
102
+ **Example combined architecture:**
103
+ - REST API backend using aws-apigateway-lambda-dynamodb construct
104
+ - Bedrock Agent using GenAI CDK constructs for natural language processing
105
+ - Shared data layer between traditional and AI components
106
+
107
+ ### Implementation Workflow
108
+
109
+ Follow this step-by-step workflow for developing AWS CDK applications:
110
+
111
+ 1. **Get CDK Guidance**: Start with the **CDKGeneralGuidance** tool to understand best practices.
112
+
113
+ 2. **Initialize CDK Project**: Use `cdk init app` to create your project with proper structure.
114
+
115
+ 3. **Choose Implementation Approach**:
116
+ - For common patterns: Use **GetAwsSolutionsConstructPattern** tool
117
+ - For GenAI applications: Use **SearchGenAICDKConstructs** tool
118
+ - For custom requirements: Develop custom CDK code following best practices
119
+
120
+ 4. **For Lambda Functions**:
121
+ - For observability: Implement Lambda Powertools (see `lambda-powertools://cdk` for details)
122
+ - For Lambda layers: Use **LambdaLayerDocumentationProvider** tool
123
+
124
+ 5. **For Bedrock Agents with Action Groups**:
125
+ - Create Lambda function with BedrockAgentResolver from Lambda Powertools
126
+ - Use **GenerateBedrockAgentSchema** tool to generate OpenAPI schema
127
+ - Integrate schema into Agent CDK code
128
+
129
+ 6. **Apply Security Best Practices**:
130
+ - Always apply CDK Nag to ensure security best practices
131
+ - Use **ExplainCDKNagRule** tool to understand specific rules
132
+ - Validate suppressions with **CheckCDKNagSuppressions** tool
133
+
134
+ 7. **Validate and Deploy**:
135
+ - Run `cdk synth` to check for errors and generate CloudFormation
136
+ - Ensure all CDK Nag warnings are resolved or properly justified
137
+ - Deploy using `cdk deploy`
138
+
139
+ ## Key Principles
140
+
141
+ - **Security First**: Always implement security best practices by default
142
+ - **Cost Optimization**: Design resources to minimize costs while meeting requirements
143
+ - **Operational Excellence**: Implement proper monitoring, logging, and observability
144
+ - **Serverless-First**: Prefer serverless services when possible
145
+ - **Infrastructure as Code**: Use CDK to define all infrastructure
146
+ - **Use Vetted Patterns**: Prefer AWS Solutions Constructs over custom implementations
147
+ - **Regional Awareness**: Consider regional availability and constraints for services
126
148
 
127
149
  ## AWS Solutions Constructs
128
150
 
@@ -148,10 +170,12 @@ To discover available patterns, use the `GetAwsSolutionsConstructPattern` tool.
148
170
  CDK Nag ensures your CDK applications follow AWS security best practices. **Always apply CDK Nag to all stacks.**
149
171
 
150
172
  **When to use CDK Nag tools:**
173
+
151
174
  - **ExplainCDKNagRule**: When encountering warnings that need remediation
152
175
  - **CheckCDKNagSuppressions**: During code reviews to verify suppression justifications
153
176
 
154
177
  Key security practices:
178
+
155
179
  - Follow least privilege for IAM
156
180
  - Secure S3 buckets with encryption and access controls
157
181
  - Implement secure authentication with Cognito
@@ -161,6 +185,10 @@ Key security practices:
161
185
 
162
186
  **Always implement Lambda Powertools** for structured logging, tracing, and metrics. For detailed guidance, use the `lambda-powertools://cdk` resource.
163
187
 
188
+ > **CRITICAL**: Lambda Powertools libraries are NOT included in the default Lambda runtime. You MUST create a Lambda layer to include these dependencies. Use the **LambdaLayerDocumentationProvider** tool for comprehensive guidance on creating and configuring Lambda layers.
189
+
190
+ **Critical for Bedrock Agents**: When creating Bedrock Agents with Action Groups, use BedrockAgentResolver from Lambda Powertools with the **GenerateBedrockAgentSchema** tool to generate the required OpenAPI schema.
191
+
164
192
  ## Tool Selection Guide
165
193
 
166
194
  Match CDK tasks to appropriate tools:
@@ -171,110 +199,6 @@ Match CDK tasks to appropriate tools:
171
199
  | Understand CDK Nag rules | ExplainCDKNagRule | ❌ Ignoring security warnings without understanding remediation steps |
172
200
  | Find architecture patterns | GetAwsSolutionsConstructPattern | ❌ Building common patterns from scratch instead of using vetted constructs |
173
201
  | Implement GenAI features | SearchGenAICDKConstructs | ❌ Building GenAI components without specialized constructs |
174
- | Add Lambda observability | lambda-powertools://cdk | ❌ Missing Layer creation, structured logging and monitoring |
202
+ | Access Lambda layer docs | LambdaLayerDocumentationProvider | ❌ Missing proper Lambda layer structure or configuration |
203
+ | Add Lambda observability | lambda-powertools://cdk | ❌ Missing Lambda layer for Powertools or incomplete monitoring setup |
175
204
  | Audit CDK Nag suppressions | CheckCDKNagSuppressions | ❌ Insufficient documentation for security suppressions |
176
-
177
- ## Lambda Powertools Implementation
178
-
179
- > **CRITICAL:** All Lambda functions should implement Lambda Powertools for proper observability.
180
-
181
- **Key requirements:**
182
- - Use language-specific constructs (PythonFunction, NodejsFunction)
183
- - Include Powertools dependencies with appropriate extras
184
- - Configure required environment variables
185
- - Create Lambda layers when needed
186
-
187
- **Example Lambda layer for Python:**
188
- ```typescript
189
- const lambdaPowertoolsLayer = new PythonLayerVersion(this, "LambdaPowertoolsLayer", {
190
- entry: path.join("src", "layers", "aws_lambda_powertools"),
191
- compatibleRuntimes: [Runtime.PYTHON_3_13],
192
- description: "Lambda Powertools for Python",
193
- });
194
- ```
195
-
196
- For complete implementation details and examples for all languages, see the [lambda-powertools://cdk](lambda-powertools://cdk) resource.
197
-
198
- ## CDK Implementation Workflow
199
-
200
- ```mermaid
201
- graph TD
202
- Start([Start]) --> Init["cdk init app"]
203
-
204
- Init --> B{Choose Approach}
205
- B -->|"Common Patterns"| C1["GetAwsSolutionsConstructPattern"]
206
- B -->|"GenAI Features"| C2["SearchGenAICDKConstructs"]
207
- B -->|"Custom Needs"| C3["Custom CDK Code"]
208
-
209
- C1 --> D1["Implement Solutions Construct"]
210
- C2 --> D2["Implement GenAI Constructs"]
211
- C3 --> D3["Implement Custom Resources"]
212
-
213
- %% Bedrock Agent with Action Groups specific flow
214
- D2 -->|"For Bedrock Agents<br/>with Action Groups"| BA["Create Lambda with<br/>BedrockAgentResolver"]
215
-
216
- %% Schema generation flow
217
- BA --> BS["GenerateBedrockAgentSchema"]
218
- BS -->|"Success"| JSON["openapi.json created"]
219
- BS -->|"Import Errors"| BSF["Tool generates<br/>generate_schema.py"]
220
- BSF --> BSR["Run script manually:<br/>python generate_schema.py"]
221
- BSR --> JSON["openapi.json created"]
222
-
223
- %% Use schema in Agent CDK
224
- JSON --> AgentCDK["Use schema in<br/>Agent CDK code"]
225
- AgentCDK --> D2
226
-
227
- %% Conditional Lambda Powertools implementation
228
- D1 & D2 & D3 --> HasLambda{"Using Lambda<br/>Functions?"}
229
- HasLambda -->|"Yes"| L["Add Lambda Powertools<br/>and create Layer"]
230
- HasLambda -->|"No"| SkipL["Skip Lambda<br/>Powertools"]
231
-
232
- %% Rest of workflow
233
- L --> Synth["cdk synth"]
234
- SkipL --> Synth
235
-
236
- Synth --> Nag{"CDK Nag<br/>warnings?"}
237
- Nag -->|Yes| E["ExplainCDKNagRule"]
238
- Nag -->|No| Deploy["cdk deploy"]
239
-
240
- E --> Fix["Fix or Add Suppressions"]
241
- Fix --> CN["CheckCDKNagSuppressions"]
242
- CN --> Synth
243
-
244
- %% Styling with darker colors
245
- classDef default fill:#424242,stroke:#ffffff,stroke-width:1px,color:#ffffff;
246
- classDef cmd fill:#4a148c,stroke:#ffffff,stroke-width:1px,color:#ffffff;
247
- classDef tool fill:#01579b,stroke:#ffffff,stroke-width:1px,color:#ffffff;
248
- classDef note fill:#1b5e20,stroke:#ffffff,stroke-width:1px,color:#ffffff;
249
- classDef output fill:#006064,stroke:#ffffff,stroke-width:1px,color:#ffffff;
250
- classDef decision fill:#5d4037,stroke:#ffffff,stroke-width:1px,color:#ffffff;
251
-
252
- class Init,Synth,Deploy,BSR cmd;
253
- class C1,C2,BS,E,CN tool;
254
- class JSON output;
255
- class HasLambda,Nag decision;
256
- ```
257
-
258
- ## Available MCP Tools
259
-
260
- This MCP server provides several tools to help you implement AWS CDK best practices:
261
-
262
- 1. **CDKGeneralGuidance**: This document - general CDK best practices
263
- 2. **ExplainCDKNagRule**: Explain a specific CDK Nag rule with AWS Well-Architected guidance
264
- 3. **CheckCDKNagSuppressions**: Check if CDK code contains Nag suppressions that require human review
265
- 4. **GenerateBedrockAgentSchema**: Generate OpenAPI schema for Bedrock Agent Action Groups from Lambda functions
266
- 5. **GetAwsSolutionsConstructPattern**: Search and discover AWS Solutions Constructs patterns
267
- 6. **SearchGenAICDKConstructs**: Search for GenAI CDK constructs by name or type
268
-
269
- ## Available MCP Resources
270
-
271
- This MCP server also provides several resources for accessing documentation:
272
-
273
- 1. **cdk-nag://rules/{rule_pack}**: Get all rules for a specific CDK Nag rule pack
274
- 2. **cdk-nag://warnings/{rule_pack}**: Get warnings for a specific CDK Nag rule pack
275
- 3. **cdk-nag://errors/{rule_pack}**: Get errors for a specific CDK Nag rule pack
276
- 4. **lambda-powertools://{topic}**: Get Lambda Powertools guidance on a specific topic
277
- 5. **aws-solutions-constructs://{pattern_name}**: Get complete documentation for an AWS Solutions Constructs pattern
278
- 6. **genai-cdk-constructs://{construct_type}/{construct_name}**: Get documentation for a GenAI CDK construct
279
-
280
- Always check for these tools and resources when implementing CDK infrastructure to ensure you're following AWS best practices.
@@ -8,7 +8,7 @@ import { pinecone, bedrock } from '@cdklabs/generative-ai-cdk-constructs';
8
8
 
9
9
  const pineconeds = new pinecone.PineconeVectorStore({
10
10
  connectionString: 'https://your-index-1234567.svc.gcp-starter.pinecone.io',
11
- credentialsSecretArn: 'arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name',
11
+ credentialsSecretArn: 'arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name', # pragma: allowlist secret
12
12
  textField: 'question',
13
13
  metadataField: 'metadata',
14
14
  });
@@ -43,7 +43,7 @@ from cdklabs.generative_ai_cdk_constructs import (
43
43
 
44
44
  pineconevs = pinecone.PineconeVectorStore(
45
45
  connection_string='https://your-index-1234567.svc.gcp-starter.pinecone.io',
46
- credentials_secret_arn='arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name',
46
+ credentials_secret_arn='arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name', # pragma: allowlist secret
47
47
  text_field='question',
48
48
  metadata_field='metadata'
49
49
  )
@@ -1,12 +1,20 @@
1
1
  # Bedrock Agent Integration
2
2
 
3
+ ## Lambda Layer Requirement
4
+
5
+ > **CRITICAL**: Lambda Powertools libraries are NOT included in the default Lambda runtime. You MUST create a Lambda layer to include these dependencies. Use the **LambdaLayerDocumentationProvider** tool for comprehensive guidance
6
+
7
+ This is especially important for Bedrock Agent integration, as the BedrockAgentResolver is required for generating proper OpenAPI schemas.
8
+
9
+ ## Implementation
10
+
3
11
  Use Lambda Powertools with Bedrock Agent actions:
4
12
 
5
13
  ```python
6
14
  from typing import Dict, List, Optional
7
15
  from aws_lambda_powertools import Logger
8
16
  from aws_lambda_powertools.event_handler import BedrockAgentResolver
9
- from aws_lambda_powertools.event_handler.openapi.params import Body, Path, Query
17
+ from aws_lambda_powertools.event_handler.openapi.params import Query
10
18
  from pydantic import BaseModel, Field
11
19
 
12
20
  # Initialize Powertools
@@ -47,35 +55,14 @@ def lambda_handler(event, context):
47
55
 
48
56
  ## Generating OpenAPI Schema
49
57
 
50
- To generate a Bedrock-compatible OpenAPI schema:
51
-
52
- ```python
53
- # Generate schema from a file
54
- result = await use_mcp_tool(
55
- server_name="awslabs.cdk-mcp-server",
56
- tool_name="GenerateBedrockAgentSchema",
57
- arguments={
58
- "lambda_code_path": "/path/to/your/agent_actions.py",
59
- "output_path": "/path/to/output/schema.json"
60
- }
61
- )
62
- ```
63
-
64
- ## Common Schema Issues
65
-
66
- - **OpenAPI version**: Must be exactly 3.0.0
67
- - **operationId**: Each operation needs a unique operationId
68
- - **Response schemas**: All responses must have properly defined schemas
69
- - **Parameter descriptions**: All parameters should have descriptions
58
+ To generate a Bedrock-compatible OpenAPI schema, use **GenerateBedrockAgentSchema** tool.
70
59
 
71
60
  ## Best Practices
72
61
 
73
62
  1. **Use Pydantic models**: Define request and response models with Pydantic
74
63
  2. **Add descriptions**: Add descriptions to all fields and parameters
75
64
  3. **Use type hints**: Specify return types for all route handlers
76
- 4. **Handle errors gracefully**: Return appropriate error responses
77
- 5. **Log with context**: Use structured logging with business context
78
- 6. **Validate inputs**: Use the validation features to ensure valid inputs
65
+ 4. **Log with context**: Use structured logging with business context
79
66
 
80
67
  ## CDK Integration
81
68
 
@@ -83,30 +70,35 @@ result = await use_mcp_tool(
83
70
  import { bedrock } from '@cdklabs/generative-ai-cdk-constructs';
84
71
  import { PythonFunction } from '@aws-cdk/aws-lambda-python-alpha';
85
72
  import { Runtime, Tracing } from 'aws-cdk-lib/aws-lambda';
73
+ import { PythonLayerVersion } from '@aws-cdk/aws-lambda-python-alpha';
86
74
  import * as path from 'path';
87
75
 
76
+ // Create Lambda layer for Powertools
77
+ const powertoolsLayer = new PythonLayerVersion(this, "PowertoolsLayer", {
78
+ entry: path.join(__dirname, '../layers/powertools'),
79
+ compatibleRuntimes: [Runtime.PYTHON_3_13],
80
+ description: "Lambda Powertools for Python",
81
+ });
82
+
88
83
  // Create Lambda function for Bedrock Agent actions
89
84
  const actionFunction = new PythonFunction(this, 'AgentActionFunction', {
90
85
  entry: path.join(__dirname, '../src/agent_actions'),
91
86
  runtime: Runtime.PYTHON_3_13,
92
87
  tracing: Tracing.ACTIVE,
88
+ layers: [powertoolsLayer], // Attach the Powertools layer
93
89
  environment: {
94
90
  POWERTOOLS_SERVICE_NAME: "agent-actions",
95
91
  LOG_LEVEL: "INFO",
96
92
  },
97
93
  });
98
94
 
99
- // Create a Bedrock Agent
95
+ // Create a Bedrock Agent with action group
100
96
  const agent = new bedrock.Agent(this, 'Agent', {
101
97
  name: 'PowertoolsAgent',
102
98
  foundationModel: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_HAIKU_V1_0,
103
- shouldPrepareAgent: true,
104
- userInputEnabled: true,
105
99
  instruction: 'You are a helpful assistant that can perform product-related actions.',
106
- description: 'Agent for product management',
107
100
  });
108
101
 
109
- // Add action group to the agent
110
102
  agent.addActionGroup(
111
103
  new bedrock.AgentActionGroup({
112
104
  name: 'product-actions',
@@ -117,11 +109,4 @@ agent.addActionGroup(
117
109
  ),
118
110
  })
119
111
  );
120
-
121
- // Create agent alias for deployment
122
- const agentAlias = new bedrock.AgentAlias(this, 'AgentAlias', {
123
- aliasName: 'latest',
124
- agent: agent,
125
- description: 'Latest agent alias',
126
- });
127
112
  ```
@@ -1,99 +1,53 @@
1
1
  # CDK Integration
2
2
 
3
- Integrate Lambda Powertools with CDK:
3
+ ## Lambda Layer Requirement
4
4
 
5
- > **IMPORTANT**: When using Tracer functionality with CDK, ensure your dependency management includes the tracer extras. For Python, your package specification should use `aws-lambda-powertools[tracer]` or `aws-lambda-powertools[all]` rather than just `aws-lambda-powertools`.
5
+ > **CRITICAL**: Lambda Powertools libraries are NOT included in the default Lambda runtime. You MUST create a Lambda layer to include these dependencies. Use the **LambdaLayerDocumentationProvider** tool for comprehensive guidance:
6
+ >
7
+ > ```
8
+ > LambdaLayerDocumentationProvider(layer_type="python")
9
+ > ```
10
+
11
+ ## Basic Implementation
6
12
 
7
13
  ```typescript
8
14
  import * as path from "path";
9
- import { Duration } from 'aws-cdk-lib';
10
15
  import { PythonFunction } from "@aws-cdk/aws-lambda-python-alpha";
11
16
  import { Runtime, Tracing } from "aws-cdk-lib/aws-lambda";
12
- import { RetentionDays } from 'aws-cdk-lib/aws-logs';
13
-
14
- // Create Lambda function with Powertools
15
- const paymentFunction = new PythonFunction(this, 'PaymentFunction', {
16
- entry: path.join(__dirname, '../src/payment_function'), // Directory containing requirements.txt
17
- runtime: Runtime.PYTHON_3_13, // Always use the latest available runtime
17
+ import { PythonLayerVersion } from "@aws-cdk/aws-lambda-python-alpha";
18
18
 
19
- // Enable X-Ray tracing
20
- tracing: Tracing.ACTIVE,
19
+ // Create Lambda layer for Powertools
20
+ const powertoolsLayer = new PythonLayerVersion(this, "PowertoolsLayer", {
21
+ entry: path.join(__dirname, '../layers/powertools'), // Directory with requirements.txt
22
+ compatibleRuntimes: [Runtime.PYTHON_3_13],
23
+ description: "Lambda Powertools for Python",
24
+ });
21
25
 
22
- // Configure Powertools environment variables
26
+ // Create Lambda function with Powertools
27
+ const myFunction = new PythonFunction(this, 'MyFunction', {
28
+ entry: path.join(__dirname, '../src/my_function'),
29
+ runtime: Runtime.PYTHON_3_13,
30
+ layers: [powertoolsLayer], // Attach the Powertools layer
31
+ tracing: Tracing.ACTIVE, // Enable X-Ray tracing
23
32
  environment: {
24
- POWERTOOLS_SERVICE_NAME: "payment-service",
25
- POWERTOOLS_METRICS_NAMESPACE: "PaymentService",
33
+ POWERTOOLS_SERVICE_NAME: "my-service",
34
+ POWERTOOLS_METRICS_NAMESPACE: "MyService",
26
35
  LOG_LEVEL: "INFO",
27
- POWERTOOLS_LOGGER_LOG_EVENT: "true", // Log event for debugging
28
36
  },
29
-
30
- // Set appropriate log retention
31
- logRetention: RetentionDays.ONE_WEEK,
32
37
  });
33
38
  ```
34
39
 
35
40
  ## Best Practices
36
41
 
37
42
  - **Always use language-specific function constructs** instead of the generic Function construct
43
+ - **Create a dedicated Lambda layer** for Powertools dependencies
38
44
  - **Enable X-Ray tracing** by setting `tracing: Tracing.ACTIVE`
39
45
  - **Configure Powertools environment variables** for consistent naming
40
- - **Set appropriate log retention** to manage CloudWatch Logs costs
41
- - **Ensure requirements.txt includes the correct extras** (e.g., `aws-lambda-powertools[tracer]`)
42
-
43
- ## Language-Specific Function Constructs
44
46
 
45
- When implementing Lambda functions with CDK, it's recommended to use language-specific constructs instead of the generic Function construct:
46
-
47
- ### PythonFunction Benefits
48
-
49
- - **Automatic Dependency Management**: Bundles Python dependencies from requirements.txt without manual packaging
50
- - **Proper Python Runtime Configuration**: Sets up the correct Python runtime environment with appropriate file permissions
51
- - **Simplified Asset Bundling**: Handles asset bundling with appropriate exclusions for Python-specific files
52
- - **Poetry/Pipenv Support**: Works with modern Python dependency management tools
53
- - **Layer Management**: Simplifies the creation and attachment of Lambda layers
54
-
55
- ### NodeJSFunction Benefits
56
-
57
- - **TypeScript Support**: Automatically transpiles TypeScript to JavaScript
58
- - **Dependency Bundling**: Uses esbuild to bundle only required dependencies for smaller packages
59
- - **Source Map Support**: Maintains source maps for easier debugging
60
- - **Minification Options**: Provides options for code minification
61
- - **Tree Shaking**: Eliminates unused code from the final bundle
62
-
63
- ## Example requirements.txt
64
-
65
- For a Python Lambda function using Powertools with tracing:
66
-
67
- ```
68
- aws-lambda-powertools[tracer]>=2.0.0
69
- ```
70
-
71
- Or for all Powertools features:
72
-
73
- ```
74
- aws-lambda-powertools[all]>=2.0.0
75
- ```
76
-
77
- ## Combining with Lambda Insights
78
-
79
- For comprehensive observability, combine Lambda Powertools with Lambda Insights:
80
-
81
- ```typescript
82
- import { LambdaInsightsVersion } from 'aws-cdk-lib/aws-lambda';
83
-
84
- const function = new PythonFunction(this, 'MyFunction', {
85
- // ... other configuration
86
-
87
- // Enable Lambda Insights
88
- insightsVersion: LambdaInsightsVersion.VERSION_1_0_119_0,
89
-
90
- // Configure Powertools
91
- environment: {
92
- POWERTOOLS_SERVICE_NAME: "my-service",
93
- POWERTOOLS_METRICS_NAMESPACE: "MyService",
94
- // ... other environment variables
95
- },
96
- });
97
- ```
47
+ ## Feature-Specific Resources
98
48
 
99
- This approach provides both system-level metrics (Lambda Insights) and business-level metrics (Powertools) for complete observability. See the [Lambda Insights](lambda-powertools://insights) section for more details.
49
+ For implementation details of specific features, refer to:
50
+ - `lambda-powertools://logging`
51
+ - `lambda-powertools://metrics`
52
+ - `lambda-powertools://tracing`
53
+ - `lambda-powertools://bedrock`
@@ -17,39 +17,30 @@ Lambda Insights is an extension of CloudWatch that provides system-level metrics
17
17
 
18
18
  ## CDK Integration
19
19
 
20
- ```typescript
21
- import { LambdaInsightsVersion } from 'aws-cdk-lib/aws-lambda';
22
- import { PythonFunction } from '@aws-cdk/aws-lambda-python-alpha';
23
-
24
- // Create Lambda function with Lambda Insights enabled
25
- const function = new PythonFunction(this, 'MyFunction', {
26
- entry: path.join(__dirname, '../src/my_function'),
27
- runtime: Runtime.PYTHON_3_13,
28
-
29
- // Enable Lambda Insights with specific version
30
- insightsVersion: LambdaInsightsVersion.VERSION_1_0_119_0,
31
-
32
- // Other configuration...
33
- });
34
- ```
35
-
36
- ## Combining with Lambda Powertools
37
-
38
- Lambda Insights works seamlessly alongside Lambda Powertools to provide a complete observability solution:
20
+ > **REMINDER**: Lambda Powertools requires a Lambda layer. See `lambda-powertools://cdk` for details.
39
21
 
40
22
  ```typescript
41
23
  import { LambdaInsightsVersion } from 'aws-cdk-lib/aws-lambda';
42
24
  import { PythonFunction } from '@aws-cdk/aws-lambda-python-alpha';
25
+ import { Runtime, Tracing } from 'aws-cdk-lib/aws-lambda';
26
+ import { PythonLayerVersion } from '@aws-cdk/aws-lambda-python-alpha';
27
+ import * as path from 'path';
43
28
 
44
29
  // Create Lambda function with both Lambda Insights and Powertools
45
- const function = new PythonFunction(this, 'MyFunction', {
30
+ const myFunction = new PythonFunction(this, 'MyFunction', {
46
31
  entry: path.join(__dirname, '../src/my_function'),
47
32
  runtime: Runtime.PYTHON_3_13,
48
33
 
34
+ // Attach Lambda layer (see lambda-powertools://cdk)
35
+ layers: [powertoolsLayer],
36
+
49
37
  // Enable Lambda Insights
50
38
  insightsVersion: LambdaInsightsVersion.VERSION_1_0_119_0,
51
39
 
52
- // Configure Powertools for business metrics
40
+ // Enable X-Ray tracing
41
+ tracing: Tracing.ACTIVE,
42
+
43
+ // Configure Powertools environment variables
53
44
  environment: {
54
45
  POWERTOOLS_SERVICE_NAME: "my-service",
55
46
  POWERTOOLS_METRICS_NAMESPACE: "MyService",
@@ -55,39 +55,8 @@ def lambda_handler(event, context: LambdaContext):
55
55
  5. **Track both success and failure metrics**: Record metrics for both outcomes
56
56
  6. **Use consistent naming**: Follow a consistent naming convention for metrics
57
57
 
58
- ## CloudWatch Dashboard Integration
59
-
60
- You can create CloudWatch dashboards to visualize your metrics:
61
-
62
- ```typescript
63
- import { Dashboard, GraphWidget, Metric } from 'aws-cdk-lib/aws-cloudwatch';
64
-
65
- // Create a dashboard
66
- const dashboard = new Dashboard(this, 'PaymentsDashboard', {
67
- dashboardName: 'PaymentsDashboard',
68
- });
69
-
70
- // Add a widget for payment metrics
71
- dashboard.addWidgets(
72
- new GraphWidget({
73
- title: 'Payment Processing',
74
- left: [
75
- new Metric({
76
- namespace: 'PaymentService',
77
- metricName: 'SuccessfulPayment',
78
- dimensionsMap: {
79
- service: 'payment-service',
80
- },
81
- statistic: 'Sum',
82
- }),
83
- new Metric({
84
- namespace: 'PaymentService',
85
- metricName: 'FailedPayment',
86
- dimensionsMap: {
87
- service: 'payment-service',
88
- },
89
- statistic: 'Sum',
90
- }),
91
- ],
92
- })
93
- );
58
+ ## CDK Integration
59
+
60
+ > **REMINDER**: Lambda Powertools requires a Lambda layer. See `lambda-powertools://cdk` for CDK integration details.
61
+
62
+ For CloudWatch dashboard integration and other CDK-specific guidance, refer to `lambda-powertools://cdk`.
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: awslabs.cdk-mcp-server
3
- Version: 0.0.81650
3
+ Version: 0.0.101004
4
4
  Summary: An AWS CDK MCP server that provides guidance on AWS Cloud Development Kit best practices, infrastructure as code patterns, and security compliance with CDK Nag. This server offers tools to validate infrastructure designs, explain CDK Nag rules, analyze suppressions, generate Bedrock Agent schemas, and discover Solutions Constructs patterns.
5
5
  Requires-Python: >=3.10
6
6
  Requires-Dist: aws-lambda-powertools>=2.30.0
7
+ Requires-Dist: bs4>=0.0.2
7
8
  Requires-Dist: httpx>=0.27.0
8
9
  Requires-Dist: mcp[cli]>=1.6.0
9
10
  Requires-Dist: pydantic>=2.10.6
@@ -39,6 +40,13 @@ MCP server for AWS Cloud Development Kit (CDK) best practices, infrastructure as
39
40
  - Discover specialized constructs for AI/ML workloads
40
41
  - Get implementation guidance for generative AI applications
41
42
 
43
+ ### Lambda Layer Documentation Provider
44
+
45
+ - Access comprehensive documentation for AWS Lambda layers
46
+ - Get code examples for generic Lambda layers and Python-specific layers
47
+ - Retrieve directory structure information and implementation best practices
48
+ - Seamless integration with AWS Documentation MCP Server for detailed documentation
49
+
42
50
  ### Amazon Bedrock Agent Schema Generation
43
51
 
44
52
  - Use this tool when creating Bedrock Agents with Action Groups that use Lambda functions
@@ -57,20 +65,21 @@ This diagram provides a comprehensive view of the recommended CDK implementation
57
65
 
58
66
  ```mermaid
59
67
  graph TD
60
- Start([Start]) --> Init["cdk init app"]
61
-
68
+ Start([Start]) --> A["CDKGeneralGuidance"]
69
+ A --> Init["cdk init app"]
70
+
62
71
  Init --> B{Choose Approach}
63
72
  B -->|"Common Patterns"| C1["GetAwsSolutionsConstructPattern"]
64
73
  B -->|"GenAI Features"| C2["SearchGenAICDKConstructs"]
65
74
  B -->|"Custom Needs"| C3["Custom CDK Code"]
66
-
75
+
67
76
  C1 --> D1["Implement Solutions Construct"]
68
77
  C2 --> D2["Implement GenAI Constructs"]
69
78
  C3 --> D3["Implement Custom Resources"]
70
-
79
+
71
80
  %% Bedrock Agent with Action Groups specific flow
72
81
  D2 -->|"For Bedrock Agents<br/>with Action Groups"| BA["Create Lambda with<br/>BedrockAgentResolver"]
73
-
82
+
74
83
  %% Schema generation flow
75
84
  BA --> BS["GenerateBedrockAgentSchema"]
76
85
  BS -->|"Success"| JSON["openapi.json created"]
@@ -78,28 +87,30 @@ graph TD
78
87
  BSF -->|"Missing dependencies?"| InstallDeps["Install dependencies"]
79
88
  InstallDeps --> BSR["Run script manually:<br/>python generate_schema.py"]
80
89
  BSR --> JSON["openapi.json created"]
81
-
90
+
82
91
  %% Use schema in Agent CDK
83
92
  JSON --> AgentCDK["Use schema in<br/>Agent CDK code"]
84
93
  AgentCDK --> D2
85
-
94
+
86
95
  %% Conditional Lambda Powertools implementation
87
96
  D1 & D2 & D3 --> HasLambda{"Using Lambda<br/>Functions?"}
88
- HasLambda -->|"Yes"| L["Add Lambda Powertools<br/>and create Layer"]
89
- HasLambda -->|"No"| SkipL["Skip Lambda<br/>Powertools"]
90
-
97
+ HasLambda --> UseLayer{"Using Lambda<br/>Layers?"}
98
+ UseLayer -->|"Yes"| LLDP["LambdaLayerDocumentationProvider"]
99
+
100
+ HasLambda -->|"No"| SkipL["Skip"]
101
+
91
102
  %% Rest of workflow
92
- L --> Synth["cdk synth"]
103
+ LLDP["LambdaLayerDocumentationProvider"] --> Synth["cdk synth"]
93
104
  SkipL --> Synth
94
-
105
+
95
106
  Synth --> Nag{"CDK Nag<br/>warnings?"}
96
107
  Nag -->|Yes| E["ExplainCDKNagRule"]
97
108
  Nag -->|No| Deploy["cdk deploy"]
98
-
109
+
99
110
  E --> Fix["Fix or Add Suppressions"]
100
111
  Fix --> CN["CheckCDKNagSuppressions"]
101
112
  CN --> Synth
102
-
113
+
103
114
  %% Styling with darker colors
104
115
  classDef default fill:#424242,stroke:#ffffff,stroke-width:1px,color:#ffffff;
105
116
  classDef cmd fill:#4a148c,stroke:#ffffff,stroke-width:1px,color:#ffffff;
@@ -107,24 +118,35 @@ graph TD
107
118
  classDef note fill:#1b5e20,stroke:#ffffff,stroke-width:1px,color:#ffffff;
108
119
  classDef output fill:#006064,stroke:#ffffff,stroke-width:1px,color:#ffffff;
109
120
  classDef decision fill:#5d4037,stroke:#ffffff,stroke-width:1px,color:#ffffff;
110
-
121
+
111
122
  class Init,Synth,Deploy,BSR cmd;
112
- class C1,C2,BS,E,CN tool;
123
+ class A,C1,C2,BS,E,CN,LLDP tool;
113
124
  class JSON output;
114
- class HasLambda,Nag decision;
125
+ class HasLambda,UseLayer,Nag decision;
115
126
  ```
116
127
 
117
- ## Tools and Resources
128
+ ## Available MCP Tools
129
+
130
+ - **CDKGeneralGuidance**: Get prescriptive advice for building AWS applications with CDK
131
+ - **GetAwsSolutionsConstructPattern**: Find vetted architecture patterns combining AWS services
132
+ - **SearchGenAICDKConstructs**: Discover GenAI CDK constructs by name or features
133
+ - **GenerateBedrockAgentSchema**: Create OpenAPI schemas for Bedrock Agent action groups
134
+ - **LambdaLayerDocumentationProvider**: Access documentation for Lambda layers implementation
135
+ - **ExplainCDKNagRule**: Get detailed guidance on CDK Nag security rules
136
+ - **CheckCDKNagSuppressions**: Validate CDK Nag suppressions in your code
137
+
138
+ ## Available MCP Resources
118
139
 
119
140
  - **CDK Nag Rules**: Access rule packs via `cdk-nag://rules/{rule_pack}`
120
- - **Lambda Powertools**: Get guidance on Lambda Powertools via `lambda-powertools://{topic}`
121
141
  - **AWS Solutions Constructs**: Access patterns via `aws-solutions-constructs://{pattern_name}`
122
142
  - **GenAI CDK Constructs**: Access documentation via `genai-cdk-constructs://{construct_type}/{construct_name}`
143
+ - **Lambda Powertools**: Get guidance on Lambda Powertools via `lambda-powertools://{topic}`
123
144
 
124
145
  ## Prerequisites
125
146
 
126
147
  1. Install `uv` from [Astral](https://docs.astral.sh/uv/getting-started/installation/) or the [GitHub README](https://github.com/astral-sh/uv#installation)
127
148
  2. Install Python using `uv python install 3.10`
149
+ 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)
128
150
 
129
151
  ## Installation
130
152
 
@@ -4,16 +4,17 @@ awslabs/cdk_mcp_server/server.py,sha256=Mom-3sv93jLG-KdESEfbrIEo3isXdAMhHcyTxANF
4
4
  awslabs/cdk_mcp_server/core/__init__.py,sha256=P5jMlOb_nAqCEM22QnIe9RZMUCLVHwmAnwqJInvcQfc,605
5
5
  awslabs/cdk_mcp_server/core/resources.py,sha256=DBIgjzhBorbjtDp-qRxq16oGnK39KHtZlKlUXXhKKC4,10152
6
6
  awslabs/cdk_mcp_server/core/search_utils.py,sha256=GLaNJBFzmDgwM8OY98R4VHfgj2Cw7GEBk-Y2lLZcPjM,6144
7
- awslabs/cdk_mcp_server/core/server.py,sha256=FmEb02_yu8kjr7PL-8fZ51Tu7ywl8kbMsxWMjrhvRlY,3145
8
- awslabs/cdk_mcp_server/core/tools.py,sha256=m_GkmypslKBbhOA8VcDQmXRhwaLUi9BvSi0OO0zqINs,19279
7
+ awslabs/cdk_mcp_server/core/server.py,sha256=KsxXYBcS5TahpAcj0CnBmLvVcMDaZXddQhAKl2yU8pc,3238
8
+ awslabs/cdk_mcp_server/core/tools.py,sha256=txBmmu-qeXWDDOm19gi7fkZ-fhpdb4r_xHwczdAHrIs,21562
9
9
  awslabs/cdk_mcp_server/data/__init__.py,sha256=8o7-TnXbiVvfwc_xc6LGnDfERnD9GMPRFfnWcgf--0Y,605
10
10
  awslabs/cdk_mcp_server/data/cdk_nag_parser.py,sha256=AKJU0O9lkzeVLAElzgBkV7rpKNUktywIXwmA52m3Vec,11477
11
11
  awslabs/cdk_mcp_server/data/construct_descriptions.py,sha256=CBfKFM_pJo6Sn_NA7hr-0oVB8piXdncQ_A5ewnTCx30,3164
12
12
  awslabs/cdk_mcp_server/data/genai_cdk_loader.py,sha256=detHbuKZYmJrsJi5UzZYZsU0hZJyykI_-QLw36itbE8,16156
13
+ awslabs/cdk_mcp_server/data/lambda_layer_parser.py,sha256=TWInqjN56Vkhs-sXqLnIvhAPCBbq3Zlm1bAerUGb1cQ,8611
13
14
  awslabs/cdk_mcp_server/data/lambda_powertools_loader.py,sha256=XtJb8tTYhmAQ6Ulor6nhKWLQ56aIh2eElpBuw2D9sco,2411
14
15
  awslabs/cdk_mcp_server/data/schema_generator.py,sha256=hAVRE2Hue7nQVf61BjYWBhyqQx7s5_YmfPXxYR3t_sg,29251
15
- awslabs/cdk_mcp_server/data/solutions_constructs_parser.py,sha256=ceIZwKlj_zdxC1Z17NZ2FKCeVFwNZCoj7GwTjDlC_Q4,28215
16
- awslabs/cdk_mcp_server/static/CDK_GENERAL_GUIDANCE.md,sha256=aFUZvhfELhS7UEffFIzJM-tRS8a7Aj13X9O7FnGN0UI,12245
16
+ awslabs/cdk_mcp_server/data/solutions_constructs_parser.py,sha256=NVOKV0cZl-9PdyoRtPo2JspSAEbCdebE8XR10dpCxyE,28243
17
+ awslabs/cdk_mcp_server/static/CDK_GENERAL_GUIDANCE.md,sha256=-O0LIpmeDXr1JoVxxbQnVp0oNqvSbX20xOgcZqknr_c,8532
17
18
  awslabs/cdk_mcp_server/static/CDK_NAG_GUIDANCE.md,sha256=zJtHJp9ruaaJ-xa68k9kDrPmEaXpiWCZZf7JIy8NK0w,5839
18
19
  awslabs/cdk_mcp_server/static/__init__.py,sha256=Tq3PnIhXqHDYM8JWmGYaLz4rKX23X2zVxP_DpLVBeZo,770
19
20
  awslabs/cdk_mcp_server/static/genai_cdk/bedrock/bedrockguardrails.md,sha256=CX00B7XgDpLbVxvf6B-a13O4NERAJMiaPPeTuKK-8Sw,7386
@@ -34,18 +35,18 @@ awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/transformation.md
34
35
  awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/aurora.md,sha256=CjiJDoaui2H4-nu99Sem4rK_8pQGB_ciI5So5pKWMSQ,5766
35
36
  awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/creation.md,sha256=jXxrwnor7_YUJc9sYCHjrQnCnHQrVItPI7YttcX-mX8,4491
36
37
  awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/opensearch.md,sha256=mM8nILHaFaLfHUaIl7c8Eh0NFx8Z5H4yu5LbC-DmnSU,1368
37
- awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/pinecone.md,sha256=OnKjSXB6CHBxnXJFGbsIRqpLyA6_S2AiHOJslxQVaOw,2053
38
+ awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/pinecone.md,sha256=VmUGQ8ggMycrqA09RjUot_9gcBMO7H6gYspThGMkEDw,2107
38
39
  awslabs/cdk_mcp_server/static/genai_cdk/opensearch-vectorindex/overview.md,sha256=0aSuBwX4ubI5WqwEfrnX1MH2UJlJOzdXZQ003fRIrGM,4121
39
40
  awslabs/cdk_mcp_server/static/genai_cdk/opensearchserverless/overview.md,sha256=aUO1BRana_xqUPENP3GQyOSCAvV9mI-ZWls7x0g8ruA,746
40
- awslabs/cdk_mcp_server/static/lambda_powertools/bedrock.md,sha256=iqmnsoOQlXHOwsvF9U5quIclIBQvv4mEf2TGFnZI_SA,4284
41
- awslabs/cdk_mcp_server/static/lambda_powertools/cdk.md,sha256=XBj-31YcphHb1BjCYz4nRpAfPuVJVRmDYI2K7e6Ti8E,3826
41
+ awslabs/cdk_mcp_server/static/lambda_powertools/bedrock.md,sha256=vxYfQvp2UcXSszAB4oQQ7xPY808WjKSPRgOnIA31nLk,4114
42
+ awslabs/cdk_mcp_server/static/lambda_powertools/cdk.md,sha256=rcYvoKOEj9R2Ptd5H61spys8j09nLgmpkD_o2niynvs,1900
42
43
  awslabs/cdk_mcp_server/static/lambda_powertools/dependencies.md,sha256=nZ2Fv54rG1rUmD_YHkM9h5VNvB81-Hk8Qx3ZNQSFZLY,1520
43
44
  awslabs/cdk_mcp_server/static/lambda_powertools/index.md,sha256=yivjInZAZ3tENKGrrAv7geICzUvKUTskWuaNj9nuPbI,1819
44
- awslabs/cdk_mcp_server/static/lambda_powertools/insights.md,sha256=t-lgyx2AstqXuY7LeWyhQxknrPN27-nAcwW-GTjI058,3445
45
+ awslabs/cdk_mcp_server/static/lambda_powertools/insights.md,sha256=jcyOHZvKHk2CgJwIu0B5SkP1SRMAhIOQ4FtWHlUs_IE,3212
45
46
  awslabs/cdk_mcp_server/static/lambda_powertools/logging.md,sha256=6CSgD8QB3Bs4s_x4RnbKwZoWvG6aG4etCnmDH6HU9XY,1797
46
- awslabs/cdk_mcp_server/static/lambda_powertools/metrics.md,sha256=XpQHtNSQRKN3GUqQWkk1lTfQSRC0LmW6VoX1dlwEvnQ,3182
47
+ awslabs/cdk_mcp_server/static/lambda_powertools/metrics.md,sha256=DQlznxRizJep8jphzFgbk7crH5LwWjSjdygP-1K6mxk,2559
47
48
  awslabs/cdk_mcp_server/static/lambda_powertools/tracing.md,sha256=Q3dSCvgktb9sUsuuQ5ONU2Qdb1OTwbNOYpK--MDzBNw,2539
48
- awslabs_cdk_mcp_server-0.0.81650.dist-info/METADATA,sha256=z_gF-UvglmZxcwqGBNmjT3JGlfKUOMm5R_xFxMaqIO4,6508
49
- awslabs_cdk_mcp_server-0.0.81650.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
50
- awslabs_cdk_mcp_server-0.0.81650.dist-info/entry_points.txt,sha256=LertzmID_mUU1YYZPySAF1IY1zE7ySTvzFxiGyo3VjY,78
51
- awslabs_cdk_mcp_server-0.0.81650.dist-info/RECORD,,
49
+ awslabs_cdk_mcp_server-0.0.101004.dist-info/METADATA,sha256=qmFg6QAO3xhcbVS-qL8HP7ALvcrvU_d1uc1tdPEO5yQ,7763
50
+ awslabs_cdk_mcp_server-0.0.101004.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
51
+ awslabs_cdk_mcp_server-0.0.101004.dist-info/entry_points.txt,sha256=LertzmID_mUU1YYZPySAF1IY1zE7ySTvzFxiGyo3VjY,78
52
+ awslabs_cdk_mcp_server-0.0.101004.dist-info/RECORD,,