awslabs.cdk-mcp-server 0.0.31004__tar.gz → 0.0.71717__tar.gz
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-0.0.71717/PKG-INFO +151 -0
- awslabs_cdk_mcp_server-0.0.71717/README.md +140 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/core/server.py +1 -1
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/core/tools.py +111 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/data/lambda_powertools_loader.py +6 -4
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/static/CDK_GENERAL_GUIDANCE.md +114 -66
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/actiongroups.md +1 -1
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/static/lambda_powertools/bedrock.md +1 -1
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/pyproject.toml +4 -1
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/uv.lock +2 -1
- awslabs_cdk_mcp_server-0.0.31004/PKG-INFO +0 -79
- awslabs_cdk_mcp_server-0.0.31004/README.md +0 -68
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/bedrock/agent/actiongroups.md +0 -137
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/alias.md +0 -39
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/collaboration.md +0 -91
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/creation.md +0 -149
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/custom_orchestration.md +0 -74
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/overview.md +0 -78
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/prompt_override.md +0 -70
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/bedrockguardrails.md +0 -188
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/chunking.md +0 -137
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/datasources.md +0 -225
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/kendra.md +0 -81
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/overview.md +0 -116
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/parsing.md +0 -36
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/transformation.md +0 -30
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/aurora.md +0 -185
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/creation.md +0 -80
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/opensearch.md +0 -56
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/pinecone.md +0 -66
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/profiles.md +0 -153
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/opensearch-vectorindex/overview.md +0 -135
- awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static/opensearchserverless/overview.md +0 -17
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/.gitignore +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/.pre-commit-config.yaml +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/.python-version +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/CHANGELOG.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/__init__.py +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/__init__.py +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/core/__init__.py +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/core/resources.py +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/core/search_utils.py +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/data/__init__.py +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/data/cdk_nag_parser.py +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/data/construct_descriptions.py +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/data/genai_cdk_loader.py +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/data/schema_generator.py +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/data/solutions_constructs_parser.py +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/server.py +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/static/CDK_NAG_GUIDANCE.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/static/__init__.py +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/agent/alias.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/agent/collaboration.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/agent/creation.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/agent/custom_orchestration.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/agent/overview.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/agent/prompt_override.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/bedrockguardrails.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/chunking.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/datasources.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/kendra.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/overview.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/parsing.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/transformation.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/vector/aurora.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/vector/creation.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/vector/opensearch.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/vector/pinecone.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.71717/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/profiles.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/static/genai_cdk/opensearch-vectorindex/overview.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/static/genai_cdk/opensearchserverless/overview.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/static/lambda_powertools/cdk.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/static/lambda_powertools/dependencies.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/static/lambda_powertools/index.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/static/lambda_powertools/insights.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/static/lambda_powertools/logging.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/static/lambda_powertools/metrics.md +0 -0
- {awslabs_cdk_mcp_server-0.0.31004 → awslabs_cdk_mcp_server-0.0.71717}/awslabs/cdk_mcp_server/static/lambda_powertools/tracing.md +0 -0
|
@@ -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.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# AWS CDK MCP Server
|
|
2
|
+
|
|
3
|
+
MCP server for AWS Cloud Development Kit (CDK) best practices, infrastructure as code patterns, and security compliance with CDK Nag.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
### CDK General Guidance
|
|
8
|
+
|
|
9
|
+
- Prescriptive patterns with AWS Solutions Constructs and GenAI CDK libraries
|
|
10
|
+
- Structured decision flow for choosing appropriate implementation approaches
|
|
11
|
+
- Security automation through CDK Nag integration and Lambda Powertools
|
|
12
|
+
|
|
13
|
+
### CDK Nag Integration
|
|
14
|
+
|
|
15
|
+
- Work with CDK Nag rules for security and compliance
|
|
16
|
+
- Explain specific CDK Nag rules with AWS Well-Architected guidance
|
|
17
|
+
- Check if CDK code contains Nag suppressions that require human review
|
|
18
|
+
|
|
19
|
+
### AWS Solutions Constructs
|
|
20
|
+
|
|
21
|
+
- Search and discover AWS Solutions Constructs patterns
|
|
22
|
+
- Find recommended patterns for common architecture needs
|
|
23
|
+
- Get detailed documentation on Solutions Constructs
|
|
24
|
+
|
|
25
|
+
### Generative AI CDK Constructs
|
|
26
|
+
|
|
27
|
+
- Search for GenAI CDK constructs by name or type
|
|
28
|
+
- Discover specialized constructs for AI/ML workloads
|
|
29
|
+
- Get implementation guidance for generative AI applications
|
|
30
|
+
|
|
31
|
+
### Amazon Bedrock Agent Schema Generation
|
|
32
|
+
|
|
33
|
+
- Generate OpenAPI schema for Bedrock Agent Action Groups
|
|
34
|
+
- Streamline the creation of Bedrock Agent schemas
|
|
35
|
+
- Convert code files to compatible OpenAPI specifications
|
|
36
|
+
|
|
37
|
+
## CDK Implementation Workflow
|
|
38
|
+
|
|
39
|
+
This diagram provides a comprehensive view of the recommended CDK implementation workflow:
|
|
40
|
+
|
|
41
|
+
```mermaid
|
|
42
|
+
graph TD
|
|
43
|
+
Start([Start]) --> Init["cdk init app"]
|
|
44
|
+
|
|
45
|
+
Init --> B{Choose Approach}
|
|
46
|
+
B -->|"Common Patterns"| C1["GetAwsSolutionsConstructPattern"]
|
|
47
|
+
B -->|"GenAI Features"| C2["SearchGenAICDKConstructs"]
|
|
48
|
+
B -->|"Custom Needs"| C3["Custom CDK Code"]
|
|
49
|
+
|
|
50
|
+
C1 --> D1["Implement Solutions Construct"]
|
|
51
|
+
C2 --> D2["Implement GenAI Constructs"]
|
|
52
|
+
C3 --> D3["Implement Custom Resources"]
|
|
53
|
+
|
|
54
|
+
%% Bedrock Agent with Action Groups specific flow
|
|
55
|
+
D2 -->|"For Bedrock Agents<br/>with Action Groups"| BA["Create Lambda with<br/>BedrockAgentResolver"]
|
|
56
|
+
|
|
57
|
+
%% Schema generation flow
|
|
58
|
+
BA --> BS["GenerateBedrockAgentSchema"]
|
|
59
|
+
BS -->|"Success"| JSON["openapi.json created"]
|
|
60
|
+
BS -->|"Import Errors"| BSF["Tool generates<br/>generate_schema.py"]
|
|
61
|
+
BSF --> BSR["Run script manually:<br/>python generate_schema.py"]
|
|
62
|
+
BSR --> JSON["openapi.json created"]
|
|
63
|
+
|
|
64
|
+
%% Use schema in Agent CDK
|
|
65
|
+
JSON --> AgentCDK["Use schema in<br/>Agent CDK code"]
|
|
66
|
+
AgentCDK --> D2
|
|
67
|
+
|
|
68
|
+
%% Conditional Lambda Powertools implementation
|
|
69
|
+
D1 & D2 & D3 --> HasLambda{"Using Lambda<br/>Functions?"}
|
|
70
|
+
HasLambda -->|"Yes"| L["Add Lambda Powertools<br/>and create Layer"]
|
|
71
|
+
HasLambda -->|"No"| SkipL["Skip Lambda<br/>Powertools"]
|
|
72
|
+
|
|
73
|
+
%% Rest of workflow
|
|
74
|
+
L --> Synth["cdk synth"]
|
|
75
|
+
SkipL --> Synth
|
|
76
|
+
|
|
77
|
+
Synth --> Nag{"CDK Nag<br/>warnings?"}
|
|
78
|
+
Nag -->|Yes| E["ExplainCDKNagRule"]
|
|
79
|
+
Nag -->|No| Deploy["cdk deploy"]
|
|
80
|
+
|
|
81
|
+
E --> Fix["Fix or Add Suppressions"]
|
|
82
|
+
Fix --> CN["CheckCDKNagSuppressions"]
|
|
83
|
+
CN --> Synth
|
|
84
|
+
|
|
85
|
+
%% Styling with darker colors
|
|
86
|
+
classDef default fill:#424242,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
87
|
+
classDef cmd fill:#4a148c,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
88
|
+
classDef tool fill:#01579b,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
89
|
+
classDef note fill:#1b5e20,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
90
|
+
classDef output fill:#006064,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
91
|
+
classDef decision fill:#5d4037,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
92
|
+
|
|
93
|
+
class Init,Synth,Deploy,BSR cmd;
|
|
94
|
+
class C1,C2,BS,E,CN tool;
|
|
95
|
+
class JSON output;
|
|
96
|
+
class HasLambda,Nag decision;
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Tools and Resources
|
|
100
|
+
|
|
101
|
+
- **CDK Nag Rules**: Access rule packs via `cdk-nag://rules/{rule_pack}`
|
|
102
|
+
- **Lambda Powertools**: Get guidance on Lambda Powertools via `lambda-powertools://{topic}`
|
|
103
|
+
- **AWS Solutions Constructs**: Access patterns via `aws-solutions-constructs://{pattern_name}`
|
|
104
|
+
- **GenAI CDK Constructs**: Access documentation via `genai-cdk-constructs://{construct_type}/{construct_name}`
|
|
105
|
+
|
|
106
|
+
## Prerequisites
|
|
107
|
+
|
|
108
|
+
1. Install `uv` from [Astral](https://docs.astral.sh/uv/getting-started/installation/) or the [GitHub README](https://github.com/astral-sh/uv#installation)
|
|
109
|
+
2. Install Python using `uv python install 3.10`
|
|
110
|
+
|
|
111
|
+
## Installation
|
|
112
|
+
|
|
113
|
+
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`):
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"mcpServers": {
|
|
118
|
+
"awslabs.cdk-mcp-server": {
|
|
119
|
+
"command": "uvx",
|
|
120
|
+
"args": ["awslabs.cdk-mcp-server@latest"],
|
|
121
|
+
"env": {
|
|
122
|
+
"FASTMCP_LOG_LEVEL": "ERROR"
|
|
123
|
+
},
|
|
124
|
+
"disabled": false,
|
|
125
|
+
"autoApprove": []
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Security Considerations
|
|
132
|
+
|
|
133
|
+
When using this MCP server, you should consider:
|
|
134
|
+
|
|
135
|
+
- Reviewing all CDK Nag warnings and errors manually
|
|
136
|
+
- Fixing security issues rather than suppressing them whenever possible
|
|
137
|
+
- Documenting clear justifications for any necessary suppressions
|
|
138
|
+
- Using the CheckCDKNagSuppressions tool to verify no unauthorized suppressions exist
|
|
139
|
+
|
|
140
|
+
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.
|
|
@@ -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'])
|