awslabs.cdk-mcp-server 0.0.62303__tar.gz → 0.0.81004__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.62303 → awslabs_cdk_mcp_server-0.0.81004}/PKG-INFO +71 -2
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/README.md +70 -1
- awslabs_cdk_mcp_server-0.0.81004/awslabs/__init__.py +10 -0
- awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/__init__.py +18 -0
- awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/core/__init__.py +11 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/core/resources.py +11 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/core/search_utils.py +11 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/core/server.py +12 -1
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/core/tools.py +154 -0
- awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/data/__init__.py +11 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/data/cdk_nag_parser.py +11 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/data/construct_descriptions.py +11 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/data/genai_cdk_loader.py +11 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/data/lambda_powertools_loader.py +17 -4
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/data/schema_generator.py +22 -3
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/data/solutions_constructs_parser.py +11 -0
- awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/server.py +18 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/static/CDK_GENERAL_GUIDANCE.md +108 -66
- awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/__init__.py +19 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/actiongroups.md +1 -1
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/static/lambda_powertools/bedrock.md +1 -1
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/pyproject.toml +1 -1
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/uv.lock +2 -1
- awslabs_cdk_mcp_server-0.0.62303/awslabs/__init__.py +0 -2
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/__init__.py +0 -8
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/core/__init__.py +0 -1
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/data/__init__.py +0 -1
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/server.py +0 -7
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/__init__.py +0 -9
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/bedrock/agent/actiongroups.md +0 -137
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/bedrock/knowledgebases/chunking.md +0 -137
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/alias.md +0 -39
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/collaboration.md +0 -91
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/creation.md +0 -149
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/custom_orchestration.md +0 -74
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/overview.md +0 -78
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/prompt_override.md +0 -70
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/bedrockguardrails.md +0 -188
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/datasources.md +0 -225
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/kendra.md +0 -81
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/overview.md +0 -116
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/parsing.md +0 -36
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/transformation.md +0 -30
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/aurora.md +0 -185
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/creation.md +0 -80
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/opensearch.md +0 -56
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/pinecone.md +0 -66
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/profiles.md +0 -153
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/opensearch-vectorindex/overview.md +0 -135
- awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static/opensearchserverless/overview.md +0 -17
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/.gitignore +0 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/.pre-commit-config.yaml +0 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/.python-version +0 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/CHANGELOG.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/static/CDK_NAG_GUIDANCE.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/agent/alias.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/agent/collaboration.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/agent/creation.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/agent/custom_orchestration.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/agent/overview.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/agent/prompt_override.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/bedrockguardrails.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/chunking.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/datasources.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/kendra.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/overview.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/parsing.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/transformation.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/vector/aurora.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/vector/creation.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/vector/opensearch.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/knowledgebases/vector/pinecone.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303/awslabs/cdk_mcp_server/static → awslabs_cdk_mcp_server-0.0.81004/awslabs/cdk_mcp_server/static/genai_cdk}/bedrock/profiles.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/static/genai_cdk/opensearch-vectorindex/overview.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/static/genai_cdk/opensearchserverless/overview.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/static/lambda_powertools/cdk.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/static/lambda_powertools/dependencies.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/static/lambda_powertools/index.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/static/lambda_powertools/insights.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/static/lambda_powertools/logging.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/static/lambda_powertools/metrics.md +0 -0
- {awslabs_cdk_mcp_server-0.0.62303 → awslabs_cdk_mcp_server-0.0.81004}/awslabs/cdk_mcp_server/static/lambda_powertools/tracing.md +0 -0
|
@@ -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.81004
|
|
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
|
|
@@ -41,10 +41,79 @@ MCP server for AWS Cloud Development Kit (CDK) best practices, infrastructure as
|
|
|
41
41
|
|
|
42
42
|
### Amazon Bedrock Agent Schema Generation
|
|
43
43
|
|
|
44
|
-
-
|
|
44
|
+
- Use this tool when creating Bedrock Agents with Action Groups that use Lambda functions
|
|
45
45
|
- Streamline the creation of Bedrock Agent schemas
|
|
46
46
|
- Convert code files to compatible OpenAPI specifications
|
|
47
47
|
|
|
48
|
+
#### Developer Notes
|
|
49
|
+
|
|
50
|
+
- **Requirements**: Your Lambda function must use `BedrockAgentResolver` from AWS Lambda Powertools
|
|
51
|
+
- **Lambda Dependencies**: If schema generation fails, a fallback script will be generated. If you see error messages about missing dependencies, install them and then run the script again.
|
|
52
|
+
- **Integration**: Use the generated schema with `bedrock.ApiSchema.fromLocalAsset()` in your CDK code
|
|
53
|
+
|
|
54
|
+
## CDK Implementation Workflow
|
|
55
|
+
|
|
56
|
+
This diagram provides a comprehensive view of the recommended CDK implementation workflow:
|
|
57
|
+
|
|
58
|
+
```mermaid
|
|
59
|
+
graph TD
|
|
60
|
+
Start([Start]) --> Init["cdk init app"]
|
|
61
|
+
|
|
62
|
+
Init --> B{Choose Approach}
|
|
63
|
+
B -->|"Common Patterns"| C1["GetAwsSolutionsConstructPattern"]
|
|
64
|
+
B -->|"GenAI Features"| C2["SearchGenAICDKConstructs"]
|
|
65
|
+
B -->|"Custom Needs"| C3["Custom CDK Code"]
|
|
66
|
+
|
|
67
|
+
C1 --> D1["Implement Solutions Construct"]
|
|
68
|
+
C2 --> D2["Implement GenAI Constructs"]
|
|
69
|
+
C3 --> D3["Implement Custom Resources"]
|
|
70
|
+
|
|
71
|
+
%% Bedrock Agent with Action Groups specific flow
|
|
72
|
+
D2 -->|"For Bedrock Agents<br/>with Action Groups"| BA["Create Lambda with<br/>BedrockAgentResolver"]
|
|
73
|
+
|
|
74
|
+
%% Schema generation flow
|
|
75
|
+
BA --> BS["GenerateBedrockAgentSchema"]
|
|
76
|
+
BS -->|"Success"| JSON["openapi.json created"]
|
|
77
|
+
BS -->|"Import Errors"| BSF["Tool generates<br/>generate_schema.py"]
|
|
78
|
+
BSF -->|"Missing dependencies?"| InstallDeps["Install dependencies"]
|
|
79
|
+
InstallDeps --> BSR["Run script manually:<br/>python generate_schema.py"]
|
|
80
|
+
BSR --> JSON["openapi.json created"]
|
|
81
|
+
|
|
82
|
+
%% Use schema in Agent CDK
|
|
83
|
+
JSON --> AgentCDK["Use schema in<br/>Agent CDK code"]
|
|
84
|
+
AgentCDK --> D2
|
|
85
|
+
|
|
86
|
+
%% Conditional Lambda Powertools implementation
|
|
87
|
+
D1 & D2 & D3 --> HasLambda{"Using Lambda<br/>Functions?"}
|
|
88
|
+
HasLambda -->|"Yes"| L["Add Lambda Powertools<br/>and create Layer"]
|
|
89
|
+
HasLambda -->|"No"| SkipL["Skip Lambda<br/>Powertools"]
|
|
90
|
+
|
|
91
|
+
%% Rest of workflow
|
|
92
|
+
L --> Synth["cdk synth"]
|
|
93
|
+
SkipL --> Synth
|
|
94
|
+
|
|
95
|
+
Synth --> Nag{"CDK Nag<br/>warnings?"}
|
|
96
|
+
Nag -->|Yes| E["ExplainCDKNagRule"]
|
|
97
|
+
Nag -->|No| Deploy["cdk deploy"]
|
|
98
|
+
|
|
99
|
+
E --> Fix["Fix or Add Suppressions"]
|
|
100
|
+
Fix --> CN["CheckCDKNagSuppressions"]
|
|
101
|
+
CN --> Synth
|
|
102
|
+
|
|
103
|
+
%% Styling with darker colors
|
|
104
|
+
classDef default fill:#424242,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
105
|
+
classDef cmd fill:#4a148c,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
106
|
+
classDef tool fill:#01579b,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
107
|
+
classDef note fill:#1b5e20,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
108
|
+
classDef output fill:#006064,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
109
|
+
classDef decision fill:#5d4037,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
110
|
+
|
|
111
|
+
class Init,Synth,Deploy,BSR cmd;
|
|
112
|
+
class C1,C2,BS,E,CN tool;
|
|
113
|
+
class JSON output;
|
|
114
|
+
class HasLambda,Nag decision;
|
|
115
|
+
```
|
|
116
|
+
|
|
48
117
|
## Tools and Resources
|
|
49
118
|
|
|
50
119
|
- **CDK Nag Rules**: Access rule packs via `cdk-nag://rules/{rule_pack}`
|
|
@@ -30,10 +30,79 @@ MCP server for AWS Cloud Development Kit (CDK) best practices, infrastructure as
|
|
|
30
30
|
|
|
31
31
|
### Amazon Bedrock Agent Schema Generation
|
|
32
32
|
|
|
33
|
-
-
|
|
33
|
+
- Use this tool when creating Bedrock Agents with Action Groups that use Lambda functions
|
|
34
34
|
- Streamline the creation of Bedrock Agent schemas
|
|
35
35
|
- Convert code files to compatible OpenAPI specifications
|
|
36
36
|
|
|
37
|
+
#### Developer Notes
|
|
38
|
+
|
|
39
|
+
- **Requirements**: Your Lambda function must use `BedrockAgentResolver` from AWS Lambda Powertools
|
|
40
|
+
- **Lambda Dependencies**: If schema generation fails, a fallback script will be generated. If you see error messages about missing dependencies, install them and then run the script again.
|
|
41
|
+
- **Integration**: Use the generated schema with `bedrock.ApiSchema.fromLocalAsset()` in your CDK code
|
|
42
|
+
|
|
43
|
+
## CDK Implementation Workflow
|
|
44
|
+
|
|
45
|
+
This diagram provides a comprehensive view of the recommended CDK implementation workflow:
|
|
46
|
+
|
|
47
|
+
```mermaid
|
|
48
|
+
graph TD
|
|
49
|
+
Start([Start]) --> Init["cdk init app"]
|
|
50
|
+
|
|
51
|
+
Init --> B{Choose Approach}
|
|
52
|
+
B -->|"Common Patterns"| C1["GetAwsSolutionsConstructPattern"]
|
|
53
|
+
B -->|"GenAI Features"| C2["SearchGenAICDKConstructs"]
|
|
54
|
+
B -->|"Custom Needs"| C3["Custom CDK Code"]
|
|
55
|
+
|
|
56
|
+
C1 --> D1["Implement Solutions Construct"]
|
|
57
|
+
C2 --> D2["Implement GenAI Constructs"]
|
|
58
|
+
C3 --> D3["Implement Custom Resources"]
|
|
59
|
+
|
|
60
|
+
%% Bedrock Agent with Action Groups specific flow
|
|
61
|
+
D2 -->|"For Bedrock Agents<br/>with Action Groups"| BA["Create Lambda with<br/>BedrockAgentResolver"]
|
|
62
|
+
|
|
63
|
+
%% Schema generation flow
|
|
64
|
+
BA --> BS["GenerateBedrockAgentSchema"]
|
|
65
|
+
BS -->|"Success"| JSON["openapi.json created"]
|
|
66
|
+
BS -->|"Import Errors"| BSF["Tool generates<br/>generate_schema.py"]
|
|
67
|
+
BSF -->|"Missing dependencies?"| InstallDeps["Install dependencies"]
|
|
68
|
+
InstallDeps --> BSR["Run script manually:<br/>python generate_schema.py"]
|
|
69
|
+
BSR --> JSON["openapi.json created"]
|
|
70
|
+
|
|
71
|
+
%% Use schema in Agent CDK
|
|
72
|
+
JSON --> AgentCDK["Use schema in<br/>Agent CDK code"]
|
|
73
|
+
AgentCDK --> D2
|
|
74
|
+
|
|
75
|
+
%% Conditional Lambda Powertools implementation
|
|
76
|
+
D1 & D2 & D3 --> HasLambda{"Using Lambda<br/>Functions?"}
|
|
77
|
+
HasLambda -->|"Yes"| L["Add Lambda Powertools<br/>and create Layer"]
|
|
78
|
+
HasLambda -->|"No"| SkipL["Skip Lambda<br/>Powertools"]
|
|
79
|
+
|
|
80
|
+
%% Rest of workflow
|
|
81
|
+
L --> Synth["cdk synth"]
|
|
82
|
+
SkipL --> Synth
|
|
83
|
+
|
|
84
|
+
Synth --> Nag{"CDK Nag<br/>warnings?"}
|
|
85
|
+
Nag -->|Yes| E["ExplainCDKNagRule"]
|
|
86
|
+
Nag -->|No| Deploy["cdk deploy"]
|
|
87
|
+
|
|
88
|
+
E --> Fix["Fix or Add Suppressions"]
|
|
89
|
+
Fix --> CN["CheckCDKNagSuppressions"]
|
|
90
|
+
CN --> Synth
|
|
91
|
+
|
|
92
|
+
%% Styling with darker colors
|
|
93
|
+
classDef default fill:#424242,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
94
|
+
classDef cmd fill:#4a148c,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
95
|
+
classDef tool fill:#01579b,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
96
|
+
classDef note fill:#1b5e20,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
97
|
+
classDef output fill:#006064,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
98
|
+
classDef decision fill:#5d4037,stroke:#ffffff,stroke-width:1px,color:#ffffff;
|
|
99
|
+
|
|
100
|
+
class Init,Synth,Deploy,BSR cmd;
|
|
101
|
+
class C1,C2,BS,E,CN tool;
|
|
102
|
+
class JSON output;
|
|
103
|
+
class HasLambda,Nag decision;
|
|
104
|
+
```
|
|
105
|
+
|
|
37
106
|
## Tools and Resources
|
|
38
107
|
|
|
39
108
|
- **CDK Nag Rules**: Access rule packs via `cdk-nag://rules/{rule_pack}`
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
"""AWS CDK MCP server package."""
|
|
12
|
+
|
|
13
|
+
# Import the minimal set of essential functions
|
|
14
|
+
from awslabs.cdk_mcp_server.core.server import main, mcp
|
|
15
|
+
|
|
16
|
+
__all__ = ['main', 'mcp']
|
|
17
|
+
|
|
18
|
+
__version__ = '0.0.0'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
"""Core modules for the AWS CDK MCP server."""
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
1
12
|
"""AWS CDK MCP resource handlers."""
|
|
2
13
|
|
|
3
14
|
import logging
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
1
12
|
"""Common search utilities for AWS CDK MCP Server."""
|
|
2
13
|
|
|
3
14
|
import re
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
1
12
|
"""AWS CDK MCP server implementation."""
|
|
2
13
|
|
|
3
14
|
import argparse
|
|
@@ -49,7 +60,7 @@ mcp.resource('genai-cdk-constructs://{construct_type}')(resources.get_genai_cdk_
|
|
|
49
60
|
mcp.tool(name='CDKGeneralGuidance')(tools.cdk_guidance)
|
|
50
61
|
mcp.tool(name='ExplainCDKNagRule')(tools.explain_cdk_nag_rule)
|
|
51
62
|
mcp.tool(name='CheckCDKNagSuppressions')(tools.check_cdk_nag_suppressions_tool)
|
|
52
|
-
mcp.tool(name='
|
|
63
|
+
mcp.tool(name='GenerateBedrockAgentSchema')(tools.bedrock_schema_generator_from_file)
|
|
53
64
|
mcp.tool(name='GetAwsSolutionsConstructPattern')(tools.get_aws_solutions_construct_pattern)
|
|
54
65
|
mcp.tool(name='SearchGenAICDKConstructs')(tools.search_genai_cdk_constructs)
|
|
55
66
|
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
1
12
|
"""AWS CDK MCP tool handlers."""
|
|
2
13
|
|
|
3
14
|
import logging
|
|
@@ -142,6 +153,65 @@ async def check_cdk_nag_suppressions_tool(
|
|
|
142
153
|
return check_cdk_nag_suppressions(code=code, file_path=file_path)
|
|
143
154
|
|
|
144
155
|
|
|
156
|
+
def save_fallback_script_to_file(
|
|
157
|
+
script_content: str, lambda_code_path: str, output_path: str
|
|
158
|
+
) -> str:
|
|
159
|
+
"""Save fallback script to a file instead of including it in the response.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
script_content: The script content to save
|
|
163
|
+
lambda_code_path: Original Lambda file path (used for naming)
|
|
164
|
+
output_path: Schema output path (used for directory)
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
Path to the saved script file
|
|
168
|
+
"""
|
|
169
|
+
# Sanitize paths to prevent path traversal attacks
|
|
170
|
+
output_dir = os.path.dirname(os.path.abspath(output_path))
|
|
171
|
+
|
|
172
|
+
# Create scripts directory in the same directory as the output file
|
|
173
|
+
scripts_dir = os.path.join(output_dir, 'scripts')
|
|
174
|
+
|
|
175
|
+
try:
|
|
176
|
+
os.makedirs(scripts_dir, exist_ok=True)
|
|
177
|
+
except (OSError, IOError) as e:
|
|
178
|
+
logger.error(f'Failed to create scripts directory: {e}')
|
|
179
|
+
# Fall back to output directory if scripts dir creation fails
|
|
180
|
+
scripts_dir = output_dir
|
|
181
|
+
|
|
182
|
+
# Sanitize file name - remove any path components and ensure it's just a base name
|
|
183
|
+
lambda_file_name = os.path.basename(lambda_code_path)
|
|
184
|
+
# Remove extension and any potentially problematic characters
|
|
185
|
+
sanitized_name = os.path.splitext(lambda_file_name)[0]
|
|
186
|
+
sanitized_name = re.sub(r'[^a-zA-Z0-9_-]', '', sanitized_name)
|
|
187
|
+
|
|
188
|
+
# Generate script name
|
|
189
|
+
script_file_name = f'generate_schema_{sanitized_name}.py'
|
|
190
|
+
script_path = os.path.join(scripts_dir, script_file_name)
|
|
191
|
+
|
|
192
|
+
# Validate the resulting path is still within the expected directory
|
|
193
|
+
if not os.path.abspath(script_path).startswith(os.path.abspath(scripts_dir)):
|
|
194
|
+
logger.error(f'Path traversal attempt detected: {script_path}')
|
|
195
|
+
# Fall back to a safe default
|
|
196
|
+
script_path = os.path.join(scripts_dir, 'generate_schema.py')
|
|
197
|
+
|
|
198
|
+
try:
|
|
199
|
+
# Write the script to file with restricted permissions
|
|
200
|
+
# Open with restricted permissions from the start (only owner can read/write)
|
|
201
|
+
with open(os.open(script_path, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f:
|
|
202
|
+
f.write(script_content)
|
|
203
|
+
|
|
204
|
+
# Update to executable permissions (only for the owner)
|
|
205
|
+
os.chmod(script_path, 0o700) # rwx------ permissions (owner only)
|
|
206
|
+
|
|
207
|
+
logger.info(f'Successfully created script at {script_path}')
|
|
208
|
+
return script_path
|
|
209
|
+
|
|
210
|
+
except (OSError, IOError) as e:
|
|
211
|
+
logger.error(f'Failed to save script: {e}')
|
|
212
|
+
return f'Error saving script: {str(e)}'
|
|
213
|
+
|
|
214
|
+
|
|
145
215
|
async def bedrock_schema_generator_from_file(
|
|
146
216
|
ctx: Context, lambda_code_path: str, output_path: str
|
|
147
217
|
) -> Dict[str, Any]:
|
|
@@ -171,6 +241,90 @@ async def bedrock_schema_generator_from_file(
|
|
|
171
241
|
output_path=output_path,
|
|
172
242
|
)
|
|
173
243
|
|
|
244
|
+
# Add comprehensive next steps for successful schema generation
|
|
245
|
+
if result.get('status') == 'success':
|
|
246
|
+
output_filename = os.path.basename(output_path)
|
|
247
|
+
output_dir = os.path.dirname(output_path)
|
|
248
|
+
lambda_dir = os.path.dirname(os.path.abspath(lambda_code_path))
|
|
249
|
+
lambda_name = os.path.basename(os.path.dirname(lambda_code_path))
|
|
250
|
+
|
|
251
|
+
# Create a more comprehensive integration example
|
|
252
|
+
result['next_steps'] = {
|
|
253
|
+
'success_message': f'Schema successfully generated and saved to {output_path}',
|
|
254
|
+
'integration_steps': [
|
|
255
|
+
'1. Ensure your Lambda function has the right permissions:',
|
|
256
|
+
' - Add bedrock.amazonaws.com as a principal in permissions',
|
|
257
|
+
' - Include Lambda Powertools and Pydantic as layers',
|
|
258
|
+
'2. Add the ActionGroup to your Bedrock Agent:',
|
|
259
|
+
' - Create an action group with your Lambda as the executor',
|
|
260
|
+
' - Use the generated schema with ApiSchema.fromLocalAsset()',
|
|
261
|
+
'3. Deploy your CDK stack',
|
|
262
|
+
],
|
|
263
|
+
'cdk_example': [
|
|
264
|
+
'// Add the Action Group to your agent',
|
|
265
|
+
'agent.addActionGroup(new bedrock.AgentActionGroup({',
|
|
266
|
+
f" name: '{lambda_name}-action-group',",
|
|
267
|
+
f" description: 'Action group for {lambda_name}',",
|
|
268
|
+
' executor: bedrock.ActionGroupExecutor.fromlambdaFunction(yourLambdaFunction),',
|
|
269
|
+
' apiSchema: bedrock.ApiSchema.fromLocalAsset(',
|
|
270
|
+
f" path.join(__dirname, '{os.path.relpath(output_dir, lambda_dir)}', '{output_filename}')",
|
|
271
|
+
' )',
|
|
272
|
+
'}));',
|
|
273
|
+
],
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
# If fallback script was generated, save it to a file instead of returning it in the response
|
|
277
|
+
if result.get('status') == 'error' and result.get('fallback_script'):
|
|
278
|
+
# Save the script to a file
|
|
279
|
+
script_path = save_fallback_script_to_file(
|
|
280
|
+
result['fallback_script'], lambda_code_path, output_path
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
# Get the output filename for use in examples
|
|
284
|
+
output_filename = os.path.basename(output_path)
|
|
285
|
+
output_dir = os.path.dirname(output_path)
|
|
286
|
+
|
|
287
|
+
# Update the result dictionary to include the script path instead of script content
|
|
288
|
+
result['fallback_script_path'] = script_path
|
|
289
|
+
|
|
290
|
+
# Remove the full script content to avoid verbose responses
|
|
291
|
+
del result['fallback_script']
|
|
292
|
+
|
|
293
|
+
# Enhanced client instructions with CDK integration example
|
|
294
|
+
result['client_instructions'] = {
|
|
295
|
+
'title': 'Schema Generation and Integration Guide',
|
|
296
|
+
'steps': [
|
|
297
|
+
f"1. Run the script at '{script_path}'",
|
|
298
|
+
f"2. The script will generate the schema file at '{output_path}'",
|
|
299
|
+
'3. In your CDK code, reference this exact schema file as shown below:',
|
|
300
|
+
],
|
|
301
|
+
'command_suggestion': f'python {script_path}',
|
|
302
|
+
'cdk_integration_example': f"// Assuming your Lambda function is named '{os.path.basename(lambda_code_path).replace('.py', 'Lambda')}'\n"
|
|
303
|
+
f'const {os.path.basename(lambda_code_path).replace(".py", "ActionGroup")} = new bedrock.AgentActionGroup({{\n'
|
|
304
|
+
f' name: "{os.path.basename(lambda_code_path).replace(".py", "ActionGroup")}",\n'
|
|
305
|
+
f' description: "This action group is used for {os.path.basename(lambda_code_path).replace(".py", "")}",\n'
|
|
306
|
+
f' executor: bedrock.ActionGroupExecutor.fromlambdaFunction({os.path.basename(lambda_code_path).replace(".py", "Lambda")}),\n'
|
|
307
|
+
f' apiSchema: bedrock.ApiSchema.fromLocalAsset(\n'
|
|
308
|
+
f' path.join(__dirname, "{os.path.relpath(output_dir, os.path.dirname(lambda_code_path))}", "{output_filename}")\n'
|
|
309
|
+
f' )\n'
|
|
310
|
+
f'}});\n'
|
|
311
|
+
f'agent.addActionGroup({os.path.basename(lambda_code_path).replace(".py", "ActionGroup")});',
|
|
312
|
+
'important_notes': [
|
|
313
|
+
'✅ Use the exact openapi.json file generated by the script',
|
|
314
|
+
'✅ Adjust the path in fromLocalAsset() to point to where the schema was generated',
|
|
315
|
+
'❌ Do NOT regenerate or modify the schema manually',
|
|
316
|
+
],
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if 'instructions' in result:
|
|
320
|
+
result['instructions'] = result['instructions'].replace(
|
|
321
|
+
'save the fallback script to a file',
|
|
322
|
+
f'run the fallback script located at {script_path}',
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
# Update the solution message
|
|
326
|
+
result['solution'] = f'Use the fallback script at {script_path} to generate the schema'
|
|
327
|
+
|
|
174
328
|
return result
|
|
175
329
|
|
|
176
330
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
"""Data modules for the AWS CDK MCP server."""
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
1
12
|
"""CDK Nag rules parsing utilities."""
|
|
2
13
|
|
|
3
14
|
import httpx
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
1
12
|
"""GenAI CDK construct descriptions."""
|
|
2
13
|
|
|
3
14
|
from typing import Dict
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
1
12
|
"""GenAI CDK constructs static content loader."""
|
|
2
13
|
|
|
3
14
|
import logging
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
1
12
|
"""Lambda Powertools guidance loader module."""
|
|
2
13
|
|
|
3
14
|
import os
|
|
@@ -34,14 +45,16 @@ def get_lambda_powertools_section(topic: str = '') -> str:
|
|
|
34
45
|
topic = 'index'
|
|
35
46
|
|
|
36
47
|
if topic.lower() in topic_map:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
# Fix the path to correctly point to the static directory (parent of 'data')
|
|
49
|
+
base_dir = os.path.dirname(
|
|
50
|
+
os.path.dirname(__file__)
|
|
51
|
+
) # Go up from 'data' to get to the package root
|
|
52
|
+
file_path = os.path.join(base_dir, 'static', 'lambda_powertools', f'{topic.lower()}.md')
|
|
40
53
|
try:
|
|
41
54
|
with open(file_path, 'r') as f:
|
|
42
55
|
return f.read()
|
|
43
56
|
except FileNotFoundError:
|
|
44
|
-
return f"Error: File for topic '{topic}' not found."
|
|
57
|
+
return f"Error: File for topic '{topic}' not found. (Looking in: {file_path})"
|
|
45
58
|
else:
|
|
46
59
|
# Topic not found
|
|
47
60
|
topic_list = '\n'.join([f'- {t}: {desc}' for t, desc in topic_map.items() if t != 'index'])
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
1
12
|
"""Schema generator for Bedrock Agent Action Groups."""
|
|
2
13
|
|
|
3
14
|
import importlib.util
|
|
@@ -121,12 +132,13 @@ def main():
|
|
|
121
132
|
|
|
122
133
|
# Generate the OpenAPI schema
|
|
123
134
|
print("Generating OpenAPI schema...")
|
|
135
|
+
# Note: This might show a UserWarning about Pydantic v2 and OpenAPI versions
|
|
124
136
|
openapi_schema = json.loads(app.get_openapi_json_schema(openapi_version="3.0.0"))
|
|
125
137
|
|
|
126
138
|
# Fix Pydantic v2 issue (forcing OpenAPI 3.0.0)
|
|
127
139
|
if openapi_schema.get("openapi") != "3.0.0":
|
|
128
140
|
openapi_schema["openapi"] = "3.0.0"
|
|
129
|
-
print("
|
|
141
|
+
print("Note: Adjusted OpenAPI version for compatibility with Bedrock Agents")
|
|
130
142
|
|
|
131
143
|
# Fix operationIds
|
|
132
144
|
for path in openapi_schema['paths']:
|
|
@@ -158,12 +170,19 @@ def main():
|
|
|
158
170
|
json.dump(openapi_schema, f, indent=2)
|
|
159
171
|
|
|
160
172
|
print(f"Schema successfully generated and saved to {{OUTPUT_PATH}}")
|
|
173
|
+
print("Next steps: Use this schema in your CDK code with bedrock.ApiSchema.fromLocalAsset()")
|
|
161
174
|
return True
|
|
162
175
|
|
|
163
176
|
except Exception as simplified_error:
|
|
164
177
|
print(f"Error with simplified version: {{str(simplified_error)}}")
|
|
165
|
-
|
|
166
|
-
|
|
178
|
+
if "No module named" in str(simplified_error):
|
|
179
|
+
missing_dep = str(simplified_error).split("'")[-2] if "'" in str(simplified_error) else str(simplified_error).split("No module named ")[-1].strip()
|
|
180
|
+
print("To resolve this error, install the missing dependency:")
|
|
181
|
+
print(" pip install " + missing_dep.replace('_', '-'))
|
|
182
|
+
print("Then run this script again.")
|
|
183
|
+
else:
|
|
184
|
+
print("You may need to manually modify the script to handle this error.")
|
|
185
|
+
print("Focus on preserving the BedrockAgentResolver app definition and routes.")
|
|
167
186
|
return False
|
|
168
187
|
|
|
169
188
|
except Exception as e:
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
1
12
|
"""AWS Solutions Constructs patterns parser module."""
|
|
2
13
|
|
|
3
14
|
import httpx
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
|
4
|
+
# with the License. A copy of the License is located at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
|
|
9
|
+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
|
|
10
|
+
# and limitations under the License.
|
|
11
|
+
|
|
12
|
+
"""AWS CDK MCP server implementation."""
|
|
13
|
+
|
|
14
|
+
from awslabs.cdk_mcp_server.core.server import main
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
if __name__ == '__main__':
|
|
18
|
+
main()
|