awslabs.cdk-mcp-server 0.0.62303__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.
- awslabs/cdk_mcp_server/core/server.py +1 -1
- awslabs/cdk_mcp_server/core/tools.py +111 -0
- awslabs/cdk_mcp_server/data/lambda_powertools_loader.py +6 -4
- awslabs/cdk_mcp_server/static/CDK_GENERAL_GUIDANCE.md +108 -66
- awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/actiongroups.md +1 -1
- awslabs/cdk_mcp_server/static/lambda_powertools/bedrock.md +1 -1
- {awslabs_cdk_mcp_server-0.0.62303.dist-info → awslabs_cdk_mcp_server-0.0.71717.dist-info}/METADATA +63 -1
- {awslabs_cdk_mcp_server-0.0.62303.dist-info → awslabs_cdk_mcp_server-0.0.71717.dist-info}/RECORD +10 -31
- awslabs/cdk_mcp_server/static/bedrock/agent/actiongroups.md +0 -137
- awslabs/cdk_mcp_server/static/bedrock/agent/alias.md +0 -39
- awslabs/cdk_mcp_server/static/bedrock/agent/collaboration.md +0 -91
- awslabs/cdk_mcp_server/static/bedrock/agent/creation.md +0 -149
- awslabs/cdk_mcp_server/static/bedrock/agent/custom_orchestration.md +0 -74
- awslabs/cdk_mcp_server/static/bedrock/agent/overview.md +0 -78
- awslabs/cdk_mcp_server/static/bedrock/agent/prompt_override.md +0 -70
- awslabs/cdk_mcp_server/static/bedrock/bedrockguardrails.md +0 -188
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/chunking.md +0 -137
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/datasources.md +0 -225
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/kendra.md +0 -81
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/overview.md +0 -116
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/parsing.md +0 -36
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/transformation.md +0 -30
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/aurora.md +0 -185
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/creation.md +0 -80
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/opensearch.md +0 -56
- awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/pinecone.md +0 -66
- awslabs/cdk_mcp_server/static/bedrock/profiles.md +0 -153
- awslabs/cdk_mcp_server/static/opensearch-vectorindex/overview.md +0 -135
- awslabs/cdk_mcp_server/static/opensearchserverless/overview.md +0 -17
- {awslabs_cdk_mcp_server-0.0.62303.dist-info → awslabs_cdk_mcp_server-0.0.71717.dist-info}/WHEEL +0 -0
- {awslabs_cdk_mcp_server-0.0.62303.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='
|
|
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
|
-
|
|
38
|
-
|
|
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'])
|
|
@@ -105,67 +105,20 @@ When implementing AWS infrastructure with CDK, consider these complementary appr
|
|
|
105
105
|
|
|
106
106
|
## Amazon Bedrock Cross-Region Inference Profiles
|
|
107
107
|
|
|
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.
|
|
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.
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
Invocation of model ID anthropic.claude-3-7-sonnet-20250219-v1:0 with on-demand throughput isn't supported.
|
|
112
|
-
Retry your request with the ID or ARN of an inference profile that contains this model.
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Using Cross-Region Inference Profiles
|
|
110
|
+
### Key Considerations
|
|
116
111
|
|
|
117
|
-
|
|
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
|
|
118
116
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
```typescript
|
|
122
|
-
import { bedrock } from '@cdklabs/generative-ai-cdk-constructs';
|
|
123
|
-
|
|
124
|
-
// Create a cross-region inference profile for Claude
|
|
125
|
-
const claudeInferenceProfile = bedrock.CrossRegionInferenceProfile.fromConfig({
|
|
126
|
-
// Choose the appropriate region:
|
|
127
|
-
// US (default) - bedrock.CrossRegionInferenceProfileRegion.US
|
|
128
|
-
// EU - bedrock.CrossRegionInferenceProfileRegion.EU
|
|
129
|
-
// APAC - bedrock.CrossRegionInferenceProfileRegion.APAC
|
|
130
|
-
geoRegion: bedrock.CrossRegionInferenceProfileRegion.US,
|
|
131
|
-
model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_7_SONNET_V1_0
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
// Use the inference profile with your agent or other Bedrock resources
|
|
135
|
-
const agent = new bedrock.Agent(this, 'MyAgent', {
|
|
136
|
-
// Use the inference profile instead of directly using the foundation model
|
|
137
|
-
foundationModel: claudeInferenceProfile,
|
|
138
|
-
// Other agent configuration...
|
|
139
|
-
});
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
#### Python
|
|
143
|
-
|
|
144
|
-
```python
|
|
145
|
-
from cdklabs.generative_ai_cdk_constructs import bedrock
|
|
146
|
-
|
|
147
|
-
# Create a cross-region inference profile for Claude
|
|
148
|
-
claude_inference_profile = bedrock.CrossRegionInferenceProfile.from_config(
|
|
149
|
-
# Choose the appropriate region:
|
|
150
|
-
# US (default) - bedrock.CrossRegionInferenceProfileRegion.US
|
|
151
|
-
# EU - bedrock.CrossRegionInferenceProfileRegion.EU
|
|
152
|
-
# APAC - bedrock.CrossRegionInferenceProfileRegion.APAC
|
|
153
|
-
geo_region=bedrock.CrossRegionInferenceProfileRegion.US,
|
|
154
|
-
model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_7_SONNET_V1_0
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
# Use the inference profile with your agent or other Bedrock resources
|
|
158
|
-
agent = bedrock.Agent(self, "MyAgent",
|
|
159
|
-
# Use the inference profile instead of directly using the foundation model
|
|
160
|
-
foundation_model=claude_inference_profile,
|
|
161
|
-
# Other agent configuration...
|
|
162
|
-
)
|
|
163
|
-
```
|
|
117
|
+
For detailed implementation examples, see the `genai-cdk-constructs://bedrock/profiles` resource.
|
|
164
118
|
|
|
165
119
|
### Regional Considerations
|
|
166
120
|
|
|
167
121
|
- **Model Availability**: Not all foundation models are available in all regions
|
|
168
|
-
- **Inference Profile Requirements**: Some models require inference profiles in specific regions
|
|
169
122
|
- **Performance**: Choose the region closest to your users for optimal latency
|
|
170
123
|
- **Compliance**: Consider data residency requirements when selecting regions
|
|
171
124
|
|
|
@@ -192,26 +145,115 @@ To discover available patterns, use the `GetAwsSolutionsConstructPattern` tool.
|
|
|
192
145
|
|
|
193
146
|
## Security with CDK Nag
|
|
194
147
|
|
|
195
|
-
CDK Nag
|
|
148
|
+
CDK Nag ensures your CDK applications follow AWS security best practices. **Always apply CDK Nag to all stacks.**
|
|
196
149
|
|
|
197
|
-
|
|
150
|
+
**When to use CDK Nag tools:**
|
|
151
|
+
- **ExplainCDKNagRule**: When encountering warnings that need remediation
|
|
152
|
+
- **CheckCDKNagSuppressions**: During code reviews to verify suppression justifications
|
|
198
153
|
|
|
199
|
-
|
|
200
|
-
-
|
|
154
|
+
Key security practices:
|
|
155
|
+
- Follow least privilege for IAM
|
|
156
|
+
- Secure S3 buckets with encryption and access controls
|
|
201
157
|
- Implement secure authentication with Cognito
|
|
202
158
|
- Secure API Gateway endpoints with proper authorization
|
|
203
159
|
|
|
204
|
-
For detailed guidance, use the `CDKNagGuidance` tool.
|
|
205
|
-
|
|
206
160
|
## Operational Excellence with Lambda Powertools
|
|
207
161
|
|
|
208
|
-
Always implement Lambda Powertools for
|
|
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
|
|
178
|
+
|
|
179
|
+
> **CRITICAL:** All Lambda functions should implement Lambda Powertools for proper observability.
|
|
209
180
|
|
|
210
|
-
|
|
211
|
-
-
|
|
212
|
-
-
|
|
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
|
|
213
186
|
|
|
214
|
-
|
|
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
|
+
```
|
|
215
257
|
|
|
216
258
|
## Available MCP Tools
|
|
217
259
|
|
|
@@ -220,7 +262,7 @@ This MCP server provides several tools to help you implement AWS CDK best practi
|
|
|
220
262
|
1. **CDKGeneralGuidance**: This document - general CDK best practices
|
|
221
263
|
2. **ExplainCDKNagRule**: Explain a specific CDK Nag rule with AWS Well-Architected guidance
|
|
222
264
|
3. **CheckCDKNagSuppressions**: Check if CDK code contains Nag suppressions that require human review
|
|
223
|
-
4. **
|
|
265
|
+
4. **GenerateBedrockAgentSchema**: Generate OpenAPI schema for Bedrock Agent Action Groups from Lambda functions
|
|
224
266
|
5. **GetAwsSolutionsConstructPattern**: Search and discover AWS Solutions Constructs patterns
|
|
225
267
|
6. **SearchGenAICDKConstructs**: Search for GenAI CDK constructs by name or type
|
|
226
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: "
|
|
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="
|
|
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"
|
{awslabs_cdk_mcp_server-0.0.62303.dist-info → awslabs_cdk_mcp_server-0.0.71717.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: awslabs.cdk-mcp-server
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.71717
|
|
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
|
|
@@ -45,6 +45,68 @@ MCP server for AWS Cloud Development Kit (CDK) best practices, infrastructure as
|
|
|
45
45
|
- Streamline the creation of Bedrock Agent schemas
|
|
46
46
|
- Convert code files to compatible OpenAPI specifications
|
|
47
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
|
+
|
|
48
110
|
## Tools and Resources
|
|
49
111
|
|
|
50
112
|
- **CDK Nag Rules**: Access rule packs via `cdk-nag://rules/{rule_pack}`
|
{awslabs_cdk_mcp_server-0.0.62303.dist-info → awslabs_cdk_mcp_server-0.0.71717.dist-info}/RECORD
RENAMED
|
@@ -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=
|
|
8
|
-
awslabs/cdk_mcp_server/core/tools.py,sha256=
|
|
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=
|
|
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=
|
|
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=xlO23xjesPFGgv_FZm2AkRzQVH3nSFD2GpbddXJX2gM,3201
|
|
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=
|
|
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=
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
awslabs_cdk_mcp_server-0.0.
|
|
70
|
-
awslabs_cdk_mcp_server-0.0.
|
|
71
|
-
awslabs_cdk_mcp_server-0.0.62303.dist-info/entry_points.txt,sha256=LertzmID_mUU1YYZPySAF1IY1zE7ySTvzFxiGyo3VjY,78
|
|
72
|
-
awslabs_cdk_mcp_server-0.0.62303.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,,
|