awslabs.cdk-mcp-server 0.0.31004__py3-none-any.whl → 0.0.71717__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.
Files changed (32) hide show
  1. awslabs/cdk_mcp_server/core/server.py +1 -1
  2. awslabs/cdk_mcp_server/core/tools.py +111 -0
  3. awslabs/cdk_mcp_server/data/lambda_powertools_loader.py +6 -4
  4. awslabs/cdk_mcp_server/static/CDK_GENERAL_GUIDANCE.md +114 -66
  5. awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/actiongroups.md +1 -1
  6. awslabs/cdk_mcp_server/static/lambda_powertools/bedrock.md +1 -1
  7. awslabs_cdk_mcp_server-0.0.71717.dist-info/METADATA +151 -0
  8. {awslabs_cdk_mcp_server-0.0.31004.dist-info → awslabs_cdk_mcp_server-0.0.71717.dist-info}/RECORD +10 -31
  9. awslabs/cdk_mcp_server/static/bedrock/agent/actiongroups.md +0 -137
  10. awslabs/cdk_mcp_server/static/bedrock/agent/alias.md +0 -39
  11. awslabs/cdk_mcp_server/static/bedrock/agent/collaboration.md +0 -91
  12. awslabs/cdk_mcp_server/static/bedrock/agent/creation.md +0 -149
  13. awslabs/cdk_mcp_server/static/bedrock/agent/custom_orchestration.md +0 -74
  14. awslabs/cdk_mcp_server/static/bedrock/agent/overview.md +0 -78
  15. awslabs/cdk_mcp_server/static/bedrock/agent/prompt_override.md +0 -70
  16. awslabs/cdk_mcp_server/static/bedrock/bedrockguardrails.md +0 -188
  17. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/chunking.md +0 -137
  18. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/datasources.md +0 -225
  19. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/kendra.md +0 -81
  20. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/overview.md +0 -116
  21. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/parsing.md +0 -36
  22. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/transformation.md +0 -30
  23. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/aurora.md +0 -185
  24. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/creation.md +0 -80
  25. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/opensearch.md +0 -56
  26. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/pinecone.md +0 -66
  27. awslabs/cdk_mcp_server/static/bedrock/profiles.md +0 -153
  28. awslabs/cdk_mcp_server/static/opensearch-vectorindex/overview.md +0 -135
  29. awslabs/cdk_mcp_server/static/opensearchserverless/overview.md +0 -17
  30. awslabs_cdk_mcp_server-0.0.31004.dist-info/METADATA +0 -79
  31. {awslabs_cdk_mcp_server-0.0.31004.dist-info → awslabs_cdk_mcp_server-0.0.71717.dist-info}/WHEEL +0 -0
  32. {awslabs_cdk_mcp_server-0.0.31004.dist-info → awslabs_cdk_mcp_server-0.0.71717.dist-info}/entry_points.txt +0 -0
@@ -49,7 +49,7 @@ mcp.resource('genai-cdk-constructs://{construct_type}')(resources.get_genai_cdk_
49
49
  mcp.tool(name='CDKGeneralGuidance')(tools.cdk_guidance)
50
50
  mcp.tool(name='ExplainCDKNagRule')(tools.explain_cdk_nag_rule)
51
51
  mcp.tool(name='CheckCDKNagSuppressions')(tools.check_cdk_nag_suppressions_tool)
52
- mcp.tool(name='GenerateBedrockAgentSchemaFromFile')(tools.bedrock_schema_generator_from_file)
52
+ mcp.tool(name='GenerateBedrockAgentSchema')(tools.bedrock_schema_generator_from_file)
53
53
  mcp.tool(name='GetAwsSolutionsConstructPattern')(tools.get_aws_solutions_construct_pattern)
54
54
  mcp.tool(name='SearchGenAICDKConstructs')(tools.search_genai_cdk_constructs)
55
55
 
@@ -142,6 +142,65 @@ async def check_cdk_nag_suppressions_tool(
142
142
  return check_cdk_nag_suppressions(code=code, file_path=file_path)
143
143
 
144
144
 
145
+ def save_fallback_script_to_file(
146
+ script_content: str, lambda_code_path: str, output_path: str
147
+ ) -> str:
148
+ """Save fallback script to a file instead of including it in the response.
149
+
150
+ Args:
151
+ script_content: The script content to save
152
+ lambda_code_path: Original Lambda file path (used for naming)
153
+ output_path: Schema output path (used for directory)
154
+
155
+ Returns:
156
+ Path to the saved script file
157
+ """
158
+ # Sanitize paths to prevent path traversal attacks
159
+ output_dir = os.path.dirname(os.path.abspath(output_path))
160
+
161
+ # Create scripts directory in the same directory as the output file
162
+ scripts_dir = os.path.join(output_dir, 'scripts')
163
+
164
+ try:
165
+ os.makedirs(scripts_dir, exist_ok=True)
166
+ except (OSError, IOError) as e:
167
+ logger.error(f'Failed to create scripts directory: {e}')
168
+ # Fall back to output directory if scripts dir creation fails
169
+ scripts_dir = output_dir
170
+
171
+ # Sanitize file name - remove any path components and ensure it's just a base name
172
+ lambda_file_name = os.path.basename(lambda_code_path)
173
+ # Remove extension and any potentially problematic characters
174
+ sanitized_name = os.path.splitext(lambda_file_name)[0]
175
+ sanitized_name = re.sub(r'[^a-zA-Z0-9_-]', '', sanitized_name)
176
+
177
+ # Generate script name
178
+ script_file_name = f'generate_schema_{sanitized_name}.py'
179
+ script_path = os.path.join(scripts_dir, script_file_name)
180
+
181
+ # Validate the resulting path is still within the expected directory
182
+ if not os.path.abspath(script_path).startswith(os.path.abspath(scripts_dir)):
183
+ logger.error(f'Path traversal attempt detected: {script_path}')
184
+ # Fall back to a safe default
185
+ script_path = os.path.join(scripts_dir, 'generate_schema.py')
186
+
187
+ try:
188
+ # Write the script to file with restricted permissions
189
+ # Open with restricted permissions from the start (only owner can read/write)
190
+ with open(os.open(script_path, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f:
191
+ f.write(script_content)
192
+
193
+ # Update to executable permissions (only for the owner)
194
+ os.chmod(script_path, 0o700) # rwx------ permissions (owner only)
195
+
196
+ logger.info(f'Successfully created script at {script_path}')
197
+ return script_path
198
+
199
+ except (OSError, IOError) as e:
200
+ logger.error(f'Failed to save script: {e}')
201
+ return f'Error saving script: {str(e)}'
202
+
203
+
145
204
  async def bedrock_schema_generator_from_file(
146
205
  ctx: Context, lambda_code_path: str, output_path: str
147
206
  ) -> Dict[str, Any]:
@@ -171,6 +230,58 @@ async def bedrock_schema_generator_from_file(
171
230
  output_path=output_path,
172
231
  )
173
232
 
233
+ # If fallback script was generated, save it to a file instead of returning it in the response
234
+ if result.get('status') == 'error' and result.get('fallback_script'):
235
+ # Save the script to a file
236
+ script_path = save_fallback_script_to_file(
237
+ result['fallback_script'], lambda_code_path, output_path
238
+ )
239
+
240
+ # Get the output filename for use in examples
241
+ output_filename = os.path.basename(output_path)
242
+ output_dir = os.path.dirname(output_path)
243
+
244
+ # Update the result dictionary to include the script path instead of script content
245
+ result['fallback_script_path'] = script_path
246
+
247
+ # Remove the full script content to avoid verbose responses
248
+ del result['fallback_script']
249
+
250
+ # Enhanced client instructions with CDK integration example
251
+ result['client_instructions'] = {
252
+ 'title': 'Schema Generation and Integration Guide',
253
+ 'steps': [
254
+ f"1. Run the script at '{script_path}'",
255
+ f"2. The script will generate the schema file at '{output_path}'",
256
+ '3. In your CDK code, reference this exact schema file as shown below:',
257
+ ],
258
+ 'command_suggestion': f'python {script_path}',
259
+ 'cdk_integration_example': f"// Assuming your Lambda function is named '{os.path.basename(lambda_code_path).replace('.py', 'Lambda')}'\n"
260
+ f'const {os.path.basename(lambda_code_path).replace(".py", "ActionGroup")} = new bedrock.AgentActionGroup({{\n'
261
+ f' name: "{os.path.basename(lambda_code_path).replace(".py", "ActionGroup")}",\n'
262
+ f' description: "This action group is used for {os.path.basename(lambda_code_path).replace(".py", "")}",\n'
263
+ f' executor: bedrock.ActionGroupExecutor.fromlambdaFunction({os.path.basename(lambda_code_path).replace(".py", "Lambda")}),\n'
264
+ f' apiSchema: bedrock.ApiSchema.fromLocalAsset(\n'
265
+ f' path.join(__dirname, "{os.path.relpath(output_dir, os.path.dirname(lambda_code_path))}", "{output_filename}")\n'
266
+ f' )\n'
267
+ f'}});\n'
268
+ f'agent.addActionGroup({os.path.basename(lambda_code_path).replace(".py", "ActionGroup")});',
269
+ 'important_notes': [
270
+ '✅ Use the exact openapi.json file generated by the script',
271
+ '✅ Adjust the path in fromLocalAsset() to point to where the schema was generated',
272
+ '❌ Do NOT regenerate or modify the schema manually',
273
+ ],
274
+ }
275
+
276
+ if 'instructions' in result:
277
+ result['instructions'] = result['instructions'].replace(
278
+ 'save the fallback script to a file',
279
+ f'run the fallback script located at {script_path}',
280
+ )
281
+
282
+ # Update the solution message
283
+ result['solution'] = f'Use the fallback script at {script_path} to generate the schema'
284
+
174
285
  return result
175
286
 
176
287
 
@@ -34,14 +34,16 @@ def get_lambda_powertools_section(topic: str = '') -> str:
34
34
  topic = 'index'
35
35
 
36
36
  if topic.lower() in topic_map:
37
- file_path = os.path.join(
38
- os.path.dirname(__file__), 'static', 'lambda_powertools', f'{topic.lower()}.md'
39
- )
37
+ # Fix the path to correctly point to the static directory (parent of 'data')
38
+ base_dir = os.path.dirname(
39
+ os.path.dirname(__file__)
40
+ ) # Go up from 'data' to get to the package root
41
+ file_path = os.path.join(base_dir, 'static', 'lambda_powertools', f'{topic.lower()}.md')
40
42
  try:
41
43
  with open(file_path, 'r') as f:
42
44
  return f.read()
43
45
  except FileNotFoundError:
44
- return f"Error: File for topic '{topic}' not found."
46
+ return f"Error: File for topic '{topic}' not found. (Looking in: {file_path})"
45
47
  else:
46
48
  # Topic not found
47
49
  topic_list = '\n'.join([f'- {t}: {desc}' for t, desc in topic_map.items() if t != 'index'])
@@ -15,6 +15,7 @@ cdk init app --language python
15
15
  ```
16
16
 
17
17
  Proper initialization ensures:
18
+
18
19
  - Consistent project structure
19
20
  - Correct dependency setup
20
21
  - Appropriate tsconfig/package.json configuration
@@ -61,6 +62,7 @@ When implementing AWS infrastructure with CDK, consider these complementary appr
61
62
  - Perfect for agents, knowledge bases, vector stores, and other GenAI components
62
63
 
63
64
  **Installation:**
65
+
64
66
  ```typescript
65
67
  // TypeScript
66
68
  // Create or use an existing CDK application
@@ -103,67 +105,20 @@ When implementing AWS infrastructure with CDK, consider these complementary appr
103
105
 
104
106
  ## Amazon Bedrock Cross-Region Inference Profiles
105
107
 
106
- 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. Failing to use inference profiles can result in errors like:
107
-
108
- ```
109
- Invocation of model ID anthropic.claude-3-7-sonnet-20250219-v1:0 with on-demand throughput isn't supported.
110
- Retry your request with the ID or ARN of an inference profile that contains this model.
111
- ```
112
-
113
- ### Using Cross-Region Inference Profiles
114
-
115
- To properly configure Bedrock models with cross-region inference profiles:
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.
116
109
 
117
- #### TypeScript
110
+ ### Key Considerations
118
111
 
119
- ```typescript
120
- import { bedrock } from '@cdklabs/generative-ai-cdk-constructs';
121
-
122
- // Create a cross-region inference profile for Claude
123
- const claudeInferenceProfile = bedrock.CrossRegionInferenceProfile.fromConfig({
124
- // Choose the appropriate region:
125
- // US (default) - bedrock.CrossRegionInferenceProfileRegion.US
126
- // EU - bedrock.CrossRegionInferenceProfileRegion.EU
127
- // APAC - bedrock.CrossRegionInferenceProfileRegion.APAC
128
- geoRegion: bedrock.CrossRegionInferenceProfileRegion.US,
129
- model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_7_SONNET_V1_0
130
- });
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
131
116
 
132
- // Use the inference profile with your agent or other Bedrock resources
133
- const agent = new bedrock.Agent(this, 'MyAgent', {
134
- // Use the inference profile instead of directly using the foundation model
135
- foundationModel: claudeInferenceProfile,
136
- // Other agent configuration...
137
- });
138
- ```
139
-
140
- #### Python
141
-
142
- ```python
143
- from cdklabs.generative_ai_cdk_constructs import bedrock
144
-
145
- # Create a cross-region inference profile for Claude
146
- claude_inference_profile = bedrock.CrossRegionInferenceProfile.from_config(
147
- # Choose the appropriate region:
148
- # US (default) - bedrock.CrossRegionInferenceProfileRegion.US
149
- # EU - bedrock.CrossRegionInferenceProfileRegion.EU
150
- # APAC - bedrock.CrossRegionInferenceProfileRegion.APAC
151
- geo_region=bedrock.CrossRegionInferenceProfileRegion.US,
152
- model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_7_SONNET_V1_0
153
- )
154
-
155
- # Use the inference profile with your agent or other Bedrock resources
156
- agent = bedrock.Agent(self, "MyAgent",
157
- # Use the inference profile instead of directly using the foundation model
158
- foundation_model=claude_inference_profile,
159
- # Other agent configuration...
160
- )
161
- ```
117
+ For detailed implementation examples, see the `genai-cdk-constructs://bedrock/profiles` resource.
162
118
 
163
119
  ### Regional Considerations
164
120
 
165
121
  - **Model Availability**: Not all foundation models are available in all regions
166
- - **Inference Profile Requirements**: Some models require inference profiles in specific regions
167
122
  - **Performance**: Choose the region closest to your users for optimal latency
168
123
  - **Compliance**: Consider data residency requirements when selecting regions
169
124
 
@@ -174,12 +129,14 @@ Always check the [Amazon Bedrock documentation](https://docs.aws.amazon.com/bedr
174
129
  AWS Solutions Constructs are vetted architecture patterns that combine multiple AWS services to solve common use cases following AWS Well-Architected best practices.
175
130
 
176
131
  **Key benefits:**
132
+
177
133
  - Accelerated Development: Implement common patterns without boilerplate code
178
134
  - Best Practices Built-in: Security, reliability, and performance best practices
179
135
  - Reduced Complexity: Simplified interfaces for multi-service architectures
180
136
  - Well-Architected: Patterns follow AWS Well-Architected Framework principles
181
137
 
182
138
  **When to use Solutions Constructs:**
139
+
183
140
  - Implementing common architecture patterns (e.g., API + Lambda + DynamoDB)
184
141
  - You want secure defaults and best practices applied automatically
185
142
  - You need to quickly prototype or build production-ready infrastructure
@@ -188,24 +145,115 @@ To discover available patterns, use the `GetAwsSolutionsConstructPattern` tool.
188
145
 
189
146
  ## Security with CDK Nag
190
147
 
191
- CDK Nag is a crucial tool for ensuring your CDK applications follow AWS security best practices. **Always apply CDK Nag to all your stacks by default.**
148
+ CDK Nag ensures your CDK applications follow AWS security best practices. **Always apply CDK Nag to all stacks.**
149
+
150
+ **When to use CDK Nag tools:**
151
+ - **ExplainCDKNagRule**: When encountering warnings that need remediation
152
+ - **CheckCDKNagSuppressions**: During code reviews to verify suppression justifications
192
153
 
193
- Key security practices to remember:
194
- - Follow the principle of least privilege for IAM
195
- - Secure S3 buckets with encryption, access controls, and policies
154
+ Key security practices:
155
+ - Follow least privilege for IAM
156
+ - Secure S3 buckets with encryption and access controls
196
157
  - Implement secure authentication with Cognito
197
158
  - Secure API Gateway endpoints with proper authorization
198
159
 
199
- For detailed guidance, use the `CDKNagGuidance` tool.
200
-
201
160
  ## Operational Excellence with Lambda Powertools
202
161
 
203
- Always implement Lambda Powertools for:
204
- - Structured Logging
205
- - Tracing
206
- - Metrics
162
+ **Always implement Lambda Powertools** for structured logging, tracing, and metrics. For detailed guidance, use the `lambda-powertools://cdk` resource.
163
+
164
+ ## Tool Selection Guide
165
+
166
+ Match CDK tasks to appropriate tools:
167
+
168
+ | Task | Tool | Common Mistakes |
169
+ |------|------|-----------------|
170
+ | Generate Bedrock Agent schema | GenerateBedrockAgentSchema | ❌ Missing schema generation or not running script to create openapi.json |
171
+ | Understand CDK Nag rules | ExplainCDKNagRule | ❌ Ignoring security warnings without understanding remediation steps |
172
+ | Find architecture patterns | GetAwsSolutionsConstructPattern | ❌ Building common patterns from scratch instead of using vetted constructs |
173
+ | Implement GenAI features | SearchGenAICDKConstructs | ❌ Building GenAI components without specialized constructs |
174
+ | Add Lambda observability | lambda-powertools://cdk | ❌ Missing Layer creation, structured logging and monitoring |
175
+ | Audit CDK Nag suppressions | CheckCDKNagSuppressions | ❌ Insufficient documentation for security suppressions |
176
+
177
+ ## Lambda Powertools Implementation
207
178
 
208
- For detailed guidance, use the `LambdaPowertoolsGuidance` tool.
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
+ ```
209
257
 
210
258
  ## Available MCP Tools
211
259
 
@@ -214,7 +262,7 @@ This MCP server provides several tools to help you implement AWS CDK best practi
214
262
  1. **CDKGeneralGuidance**: This document - general CDK best practices
215
263
  2. **ExplainCDKNagRule**: Explain a specific CDK Nag rule with AWS Well-Architected guidance
216
264
  3. **CheckCDKNagSuppressions**: Check if CDK code contains Nag suppressions that require human review
217
- 4. **GenerateBedrockAgentSchemaFromFile**: Generate OpenAPI schema for Bedrock Agent Action Groups from Lambda functions
265
+ 4. **GenerateBedrockAgentSchema**: Generate OpenAPI schema for Bedrock Agent Action Groups from Lambda functions
218
266
  5. **GetAwsSolutionsConstructPattern**: Search and discover AWS Solutions Constructs patterns
219
267
  6. **SearchGenAICDKConstructs**: Search for GenAI CDK constructs by name or type
220
268
 
@@ -32,7 +32,7 @@ For Action Groups, use the built-in OpenAPI schema generation tool provided by t
32
32
  // Using MCP client
33
33
  const result = await use_mcp_tool({
34
34
  server_name: "awslabs.cdk-mcp-server",
35
- tool_name: "GenerateBedrockAgentSchemaFromFile",
35
+ tool_name: "GenerateBedrockAgentSchema",
36
36
  arguments: {
37
37
  lambda_code_path: "path/to/your/lambda.py",
38
38
  output_path: "path/to/output/openapi.json"
@@ -53,7 +53,7 @@ To generate a Bedrock-compatible OpenAPI schema:
53
53
  # Generate schema from a file
54
54
  result = await use_mcp_tool(
55
55
  server_name="awslabs.cdk-mcp-server",
56
- tool_name="GenerateBedrockAgentSchemaFromFile",
56
+ tool_name="GenerateBedrockAgentSchema",
57
57
  arguments={
58
58
  "lambda_code_path": "/path/to/your/agent_actions.py",
59
59
  "output_path": "/path/to/output/schema.json"
@@ -0,0 +1,151 @@
1
+ Metadata-Version: 2.4
2
+ Name: awslabs.cdk-mcp-server
3
+ Version: 0.0.71717
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
+ Requires-Python: >=3.10
6
+ Requires-Dist: aws-lambda-powertools>=2.30.0
7
+ Requires-Dist: httpx>=0.27.0
8
+ Requires-Dist: mcp[cli]>=1.6.0
9
+ Requires-Dist: pydantic>=2.10.6
10
+ Description-Content-Type: text/markdown
11
+
12
+ # AWS CDK MCP Server
13
+
14
+ MCP server for AWS Cloud Development Kit (CDK) best practices, infrastructure as code patterns, and security compliance with CDK Nag.
15
+
16
+ ## Features
17
+
18
+ ### CDK General Guidance
19
+
20
+ - Prescriptive patterns with AWS Solutions Constructs and GenAI CDK libraries
21
+ - Structured decision flow for choosing appropriate implementation approaches
22
+ - Security automation through CDK Nag integration and Lambda Powertools
23
+
24
+ ### CDK Nag Integration
25
+
26
+ - Work with CDK Nag rules for security and compliance
27
+ - Explain specific CDK Nag rules with AWS Well-Architected guidance
28
+ - Check if CDK code contains Nag suppressions that require human review
29
+
30
+ ### AWS Solutions Constructs
31
+
32
+ - Search and discover AWS Solutions Constructs patterns
33
+ - Find recommended patterns for common architecture needs
34
+ - Get detailed documentation on Solutions Constructs
35
+
36
+ ### Generative AI CDK Constructs
37
+
38
+ - Search for GenAI CDK constructs by name or type
39
+ - Discover specialized constructs for AI/ML workloads
40
+ - Get implementation guidance for generative AI applications
41
+
42
+ ### Amazon Bedrock Agent Schema Generation
43
+
44
+ - Generate OpenAPI schema for Bedrock Agent Action Groups
45
+ - Streamline the creation of Bedrock Agent schemas
46
+ - Convert code files to compatible OpenAPI specifications
47
+
48
+ ## CDK Implementation Workflow
49
+
50
+ This diagram provides a comprehensive view of the recommended CDK implementation workflow:
51
+
52
+ ```mermaid
53
+ graph TD
54
+ Start([Start]) --> Init["cdk init app"]
55
+
56
+ Init --> B{Choose Approach}
57
+ B -->|"Common Patterns"| C1["GetAwsSolutionsConstructPattern"]
58
+ B -->|"GenAI Features"| C2["SearchGenAICDKConstructs"]
59
+ B -->|"Custom Needs"| C3["Custom CDK Code"]
60
+
61
+ C1 --> D1["Implement Solutions Construct"]
62
+ C2 --> D2["Implement GenAI Constructs"]
63
+ C3 --> D3["Implement Custom Resources"]
64
+
65
+ %% Bedrock Agent with Action Groups specific flow
66
+ D2 -->|"For Bedrock Agents<br/>with Action Groups"| BA["Create Lambda with<br/>BedrockAgentResolver"]
67
+
68
+ %% Schema generation flow
69
+ BA --> BS["GenerateBedrockAgentSchema"]
70
+ BS -->|"Success"| JSON["openapi.json created"]
71
+ BS -->|"Import Errors"| BSF["Tool generates<br/>generate_schema.py"]
72
+ BSF --> BSR["Run script manually:<br/>python generate_schema.py"]
73
+ BSR --> JSON["openapi.json created"]
74
+
75
+ %% Use schema in Agent CDK
76
+ JSON --> AgentCDK["Use schema in<br/>Agent CDK code"]
77
+ AgentCDK --> D2
78
+
79
+ %% Conditional Lambda Powertools implementation
80
+ D1 & D2 & D3 --> HasLambda{"Using Lambda<br/>Functions?"}
81
+ HasLambda -->|"Yes"| L["Add Lambda Powertools<br/>and create Layer"]
82
+ HasLambda -->|"No"| SkipL["Skip Lambda<br/>Powertools"]
83
+
84
+ %% Rest of workflow
85
+ L --> Synth["cdk synth"]
86
+ SkipL --> Synth
87
+
88
+ Synth --> Nag{"CDK Nag<br/>warnings?"}
89
+ Nag -->|Yes| E["ExplainCDKNagRule"]
90
+ Nag -->|No| Deploy["cdk deploy"]
91
+
92
+ E --> Fix["Fix or Add Suppressions"]
93
+ Fix --> CN["CheckCDKNagSuppressions"]
94
+ CN --> Synth
95
+
96
+ %% Styling with darker colors
97
+ classDef default fill:#424242,stroke:#ffffff,stroke-width:1px,color:#ffffff;
98
+ classDef cmd fill:#4a148c,stroke:#ffffff,stroke-width:1px,color:#ffffff;
99
+ classDef tool fill:#01579b,stroke:#ffffff,stroke-width:1px,color:#ffffff;
100
+ classDef note fill:#1b5e20,stroke:#ffffff,stroke-width:1px,color:#ffffff;
101
+ classDef output fill:#006064,stroke:#ffffff,stroke-width:1px,color:#ffffff;
102
+ classDef decision fill:#5d4037,stroke:#ffffff,stroke-width:1px,color:#ffffff;
103
+
104
+ class Init,Synth,Deploy,BSR cmd;
105
+ class C1,C2,BS,E,CN tool;
106
+ class JSON output;
107
+ class HasLambda,Nag decision;
108
+ ```
109
+
110
+ ## Tools and Resources
111
+
112
+ - **CDK Nag Rules**: Access rule packs via `cdk-nag://rules/{rule_pack}`
113
+ - **Lambda Powertools**: Get guidance on Lambda Powertools via `lambda-powertools://{topic}`
114
+ - **AWS Solutions Constructs**: Access patterns via `aws-solutions-constructs://{pattern_name}`
115
+ - **GenAI CDK Constructs**: Access documentation via `genai-cdk-constructs://{construct_type}/{construct_name}`
116
+
117
+ ## Prerequisites
118
+
119
+ 1. Install `uv` from [Astral](https://docs.astral.sh/uv/getting-started/installation/) or the [GitHub README](https://github.com/astral-sh/uv#installation)
120
+ 2. Install Python using `uv python install 3.10`
121
+
122
+ ## Installation
123
+
124
+ Here are some ways you can work with MCP across AWS, and we'll be adding support to more products including Amazon Q Developer CLI soon: (e.g. for Amazon Q Developer CLI MCP, `~/.aws/amazonq/mcp.json`):
125
+
126
+ ```json
127
+ {
128
+ "mcpServers": {
129
+ "awslabs.cdk-mcp-server": {
130
+ "command": "uvx",
131
+ "args": ["awslabs.cdk-mcp-server@latest"],
132
+ "env": {
133
+ "FASTMCP_LOG_LEVEL": "ERROR"
134
+ },
135
+ "disabled": false,
136
+ "autoApprove": []
137
+ }
138
+ }
139
+ }
140
+ ```
141
+
142
+ ## Security Considerations
143
+
144
+ When using this MCP server, you should consider:
145
+
146
+ - Reviewing all CDK Nag warnings and errors manually
147
+ - Fixing security issues rather than suppressing them whenever possible
148
+ - Documenting clear justifications for any necessary suppressions
149
+ - Using the CheckCDKNagSuppressions tool to verify no unauthorized suppressions exist
150
+
151
+ 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.
@@ -4,40 +4,21 @@ awslabs/cdk_mcp_server/server.py,sha256=KKNPh9zTvUy6uCAzeR2djtJqFCzDkkihUb-9dP_j
4
4
  awslabs/cdk_mcp_server/core/__init__.py,sha256=wMYtq0d53XTzMmilxj-crP-I445ijE_8A7MH6wL1Fm8,47
5
5
  awslabs/cdk_mcp_server/core/resources.py,sha256=nduzytgmiAb3C-RuqcexWgEl_APUYymTQDmZhkAl-NQ,9593
6
6
  awslabs/cdk_mcp_server/core/search_utils.py,sha256=Nz8ftv4w9O_1fvCwIJL36GoBMOtHP9XZnTnVhUxVUko,5585
7
- awslabs/cdk_mcp_server/core/server.py,sha256=1Zc_n4whZJq9q2_eVrmvqnmNaTKL4ftwbiVHmPJ3JAs,2594
8
- awslabs/cdk_mcp_server/core/tools.py,sha256=dw_RJ-IvfWsaicj6bp_UvyGjtd2hLicXL4RC5doaVk4,11644
7
+ awslabs/cdk_mcp_server/core/server.py,sha256=64pM6HcJvGOS3J9AmIx27smpdkHDaBUDjFY-XK3WPwQ,2586
8
+ awslabs/cdk_mcp_server/core/tools.py,sha256=jDkUB2mS9HEAV2C6e9nMikBTtIphPbqC3uzKyhlONPo,16991
9
9
  awslabs/cdk_mcp_server/data/__init__.py,sha256=ksA1se4fyvTIb4K7lND-C66ouriFtjyZU96Q88nl6w4,47
10
10
  awslabs/cdk_mcp_server/data/cdk_nag_parser.py,sha256=k3OzuVyoYUivowt_mEO0cp1YwTOgzTmVyg_0mcanDt8,10900
11
11
  awslabs/cdk_mcp_server/data/construct_descriptions.py,sha256=br5gOa5M8Nhv3HrHqrHGXCwQRTu4ZeMAo85bEhzCuMM,2605
12
12
  awslabs/cdk_mcp_server/data/genai_cdk_loader.py,sha256=Q_-tnYu9VNe9lbAxN6qfvBQWYJJjYXht63ko9x-IH-Y,15507
13
- awslabs/cdk_mcp_server/data/lambda_powertools_loader.py,sha256=sQfZrmA2hZdd1NSK0hCb5l4kl7jlQ3xhxs28KgEB4Dw,1630
13
+ awslabs/cdk_mcp_server/data/lambda_powertools_loader.py,sha256=XfhWST0-f050nBB4zPMVFahgE1m21PXdhD9WaYAz2yg,1834
14
14
  awslabs/cdk_mcp_server/data/schema_generator.py,sha256=vQaZiasOyVam0NNmtzo6D6hy7ynsndRR2I56OBwQlag,27879
15
15
  awslabs/cdk_mcp_server/data/solutions_constructs_parser.py,sha256=SL3ZjvCSALmiQlHEMsoDbnbtKxFAPl-mTurciCgj3G8,27656
16
- awslabs/cdk_mcp_server/static/CDK_GENERAL_GUIDANCE.md,sha256=bZJRzb-14lVOIceQnUTvzb4_QoPg2g3O4NgPavXYiz0,9919
16
+ awslabs/cdk_mcp_server/static/CDK_GENERAL_GUIDANCE.md,sha256=aFUZvhfELhS7UEffFIzJM-tRS8a7Aj13X9O7FnGN0UI,12245
17
17
  awslabs/cdk_mcp_server/static/CDK_NAG_GUIDANCE.md,sha256=zJtHJp9ruaaJ-xa68k9kDrPmEaXpiWCZZf7JIy8NK0w,5839
18
18
  awslabs/cdk_mcp_server/static/__init__.py,sha256=JJ9ptA-cG8muKCoJgjPKUoCc2q2ks8gBJNbjJTHZS3o,194
19
- awslabs/cdk_mcp_server/static/bedrock/bedrockguardrails.md,sha256=CX00B7XgDpLbVxvf6B-a13O4NERAJMiaPPeTuKK-8Sw,7386
20
- awslabs/cdk_mcp_server/static/bedrock/profiles.md,sha256=xxPnEkZ0tJAFKomMuAPLm3EtlQFku6MR2nPu4VoyppE,7195
21
- awslabs/cdk_mcp_server/static/bedrock/agent/actiongroups.md,sha256=qm6UCCfKurtvNO52g1a6H1N9iBZx-KTCf4SbCK2QQXw,4865
22
- awslabs/cdk_mcp_server/static/bedrock/agent/alias.md,sha256=eyTmjmHyQbuR5CbFpp2qrEcEqw2l9pMupWERRVksVNw,1293
23
- awslabs/cdk_mcp_server/static/bedrock/agent/collaboration.md,sha256=nNu30F5ydUbb7HtboUWNhp0hOnQMw8q8shCUjMDwT_A,3616
24
- awslabs/cdk_mcp_server/static/bedrock/agent/creation.md,sha256=BzpVJkRs_q1ZkW8LnIEh7--57OnNmHHdPCygfGJAks0,6216
25
- awslabs/cdk_mcp_server/static/bedrock/agent/custom_orchestration.md,sha256=ylMTq3PT3vHnrul_boLuQIGQFuk_Y0evdImp_pLY7rY,2983
26
- awslabs/cdk_mcp_server/static/bedrock/agent/overview.md,sha256=4FLhC3CC01W9Gpw4S0Z6yWPnM86p2nJ_dxQ1yU4Xsxw,2921
27
- awslabs/cdk_mcp_server/static/bedrock/agent/prompt_override.md,sha256=ypmKxlO5WIYqUh2gYDzo1Mwzso_HwSkzrMHeDU473C8,2520
28
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/chunking.md,sha256=TpLXPJso6c4MhWUepX0WsX3FE6FOIsFBPcE28B-3iKM,3203
29
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/datasources.md,sha256=iHQ086zHzkqHoKLi7pmyMxf0oH02UVHf_GAid6EMdeE,7147
30
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/kendra.md,sha256=sYbhIAaGjuJ2lifP0xvDXacDEVFC24Gl9giAI6RF9bo,2786
31
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/overview.md,sha256=AGLS6146UufRTC80EAyAviBhAtb7hFcbMz3tWFviPOc,5167
32
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/parsing.md,sha256=AQ6TTO5HxKqhtVdv1bM6GjHyDgOICaNi5NtDT9Dxp10,1155
33
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/transformation.md,sha256=I5Lkn0giUr5n0lTxqjtUsoHNkom6AJtxEnvlarH_54Y,813
34
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/aurora.md,sha256=CjiJDoaui2H4-nu99Sem4rK_8pQGB_ciI5So5pKWMSQ,5766
35
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/creation.md,sha256=jXxrwnor7_YUJc9sYCHjrQnCnHQrVItPI7YttcX-mX8,4491
36
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/opensearch.md,sha256=mM8nILHaFaLfHUaIl7c8Eh0NFx8Z5H4yu5LbC-DmnSU,1368
37
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/pinecone.md,sha256=OnKjSXB6CHBxnXJFGbsIRqpLyA6_S2AiHOJslxQVaOw,2053
38
19
  awslabs/cdk_mcp_server/static/genai_cdk/bedrock/bedrockguardrails.md,sha256=CX00B7XgDpLbVxvf6B-a13O4NERAJMiaPPeTuKK-8Sw,7386
39
20
  awslabs/cdk_mcp_server/static/genai_cdk/bedrock/profiles.md,sha256=xxPnEkZ0tJAFKomMuAPLm3EtlQFku6MR2nPu4VoyppE,7195
40
- awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/actiongroups.md,sha256=qm6UCCfKurtvNO52g1a6H1N9iBZx-KTCf4SbCK2QQXw,4865
21
+ awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/actiongroups.md,sha256=m40RkxPkX3BI4PHEBQHHPOAAK0rgdPkLVi37F3JcLZQ,4857
41
22
  awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/alias.md,sha256=eyTmjmHyQbuR5CbFpp2qrEcEqw2l9pMupWERRVksVNw,1293
42
23
  awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/collaboration.md,sha256=nNu30F5ydUbb7HtboUWNhp0hOnQMw8q8shCUjMDwT_A,3616
43
24
  awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/creation.md,sha256=BzpVJkRs_q1ZkW8LnIEh7--57OnNmHHdPCygfGJAks0,6216
@@ -56,7 +37,7 @@ awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/opensearch
56
37
  awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/pinecone.md,sha256=OnKjSXB6CHBxnXJFGbsIRqpLyA6_S2AiHOJslxQVaOw,2053
57
38
  awslabs/cdk_mcp_server/static/genai_cdk/opensearch-vectorindex/overview.md,sha256=0aSuBwX4ubI5WqwEfrnX1MH2UJlJOzdXZQ003fRIrGM,4121
58
39
  awslabs/cdk_mcp_server/static/genai_cdk/opensearchserverless/overview.md,sha256=aUO1BRana_xqUPENP3GQyOSCAvV9mI-ZWls7x0g8ruA,746
59
- awslabs/cdk_mcp_server/static/lambda_powertools/bedrock.md,sha256=Fu54j6sKHdNCUl8FnrIN02kXoTZzdS1g91lURG0ORA4,4292
40
+ awslabs/cdk_mcp_server/static/lambda_powertools/bedrock.md,sha256=iqmnsoOQlXHOwsvF9U5quIclIBQvv4mEf2TGFnZI_SA,4284
60
41
  awslabs/cdk_mcp_server/static/lambda_powertools/cdk.md,sha256=XBj-31YcphHb1BjCYz4nRpAfPuVJVRmDYI2K7e6Ti8E,3826
61
42
  awslabs/cdk_mcp_server/static/lambda_powertools/dependencies.md,sha256=nZ2Fv54rG1rUmD_YHkM9h5VNvB81-Hk8Qx3ZNQSFZLY,1520
62
43
  awslabs/cdk_mcp_server/static/lambda_powertools/index.md,sha256=yivjInZAZ3tENKGrrAv7geICzUvKUTskWuaNj9nuPbI,1819
@@ -64,9 +45,7 @@ awslabs/cdk_mcp_server/static/lambda_powertools/insights.md,sha256=t-lgyx2AstqXu
64
45
  awslabs/cdk_mcp_server/static/lambda_powertools/logging.md,sha256=6CSgD8QB3Bs4s_x4RnbKwZoWvG6aG4etCnmDH6HU9XY,1797
65
46
  awslabs/cdk_mcp_server/static/lambda_powertools/metrics.md,sha256=XpQHtNSQRKN3GUqQWkk1lTfQSRC0LmW6VoX1dlwEvnQ,3182
66
47
  awslabs/cdk_mcp_server/static/lambda_powertools/tracing.md,sha256=Q3dSCvgktb9sUsuuQ5ONU2Qdb1OTwbNOYpK--MDzBNw,2539
67
- awslabs/cdk_mcp_server/static/opensearch-vectorindex/overview.md,sha256=0aSuBwX4ubI5WqwEfrnX1MH2UJlJOzdXZQ003fRIrGM,4121
68
- awslabs/cdk_mcp_server/static/opensearchserverless/overview.md,sha256=aUO1BRana_xqUPENP3GQyOSCAvV9mI-ZWls7x0g8ruA,746
69
- awslabs_cdk_mcp_server-0.0.31004.dist-info/METADATA,sha256=HkaHCbgnYTWxRslpcr2GjyS5UIQnGaLQHGN5Z3TIHnE,3591
70
- awslabs_cdk_mcp_server-0.0.31004.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
71
- awslabs_cdk_mcp_server-0.0.31004.dist-info/entry_points.txt,sha256=LertzmID_mUU1YYZPySAF1IY1zE7ySTvzFxiGyo3VjY,78
72
- awslabs_cdk_mcp_server-0.0.31004.dist-info/RECORD,,
48
+ awslabs_cdk_mcp_server-0.0.71717.dist-info/METADATA,sha256=4CQDjLXNh-UYcjQUduSq8XetSx0rld1iwQPqyzq0Bw4,5979
49
+ awslabs_cdk_mcp_server-0.0.71717.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
50
+ awslabs_cdk_mcp_server-0.0.71717.dist-info/entry_points.txt,sha256=LertzmID_mUU1YYZPySAF1IY1zE7ySTvzFxiGyo3VjY,78
51
+ awslabs_cdk_mcp_server-0.0.71717.dist-info/RECORD,,