awslabs.cdk-mcp-server 0.0.62303__py3-none-any.whl → 0.0.81004__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/__init__.py +10 -2
- awslabs/cdk_mcp_server/__init__.py +10 -0
- awslabs/cdk_mcp_server/core/__init__.py +10 -0
- awslabs/cdk_mcp_server/core/resources.py +11 -0
- awslabs/cdk_mcp_server/core/search_utils.py +11 -0
- awslabs/cdk_mcp_server/core/server.py +12 -1
- awslabs/cdk_mcp_server/core/tools.py +154 -0
- awslabs/cdk_mcp_server/data/__init__.py +10 -0
- awslabs/cdk_mcp_server/data/cdk_nag_parser.py +11 -0
- awslabs/cdk_mcp_server/data/construct_descriptions.py +11 -0
- awslabs/cdk_mcp_server/data/genai_cdk_loader.py +11 -0
- awslabs/cdk_mcp_server/data/lambda_powertools_loader.py +17 -4
- awslabs/cdk_mcp_server/data/schema_generator.py +22 -3
- awslabs/cdk_mcp_server/data/solutions_constructs_parser.py +11 -0
- awslabs/cdk_mcp_server/server.py +11 -0
- awslabs/cdk_mcp_server/static/CDK_GENERAL_GUIDANCE.md +108 -66
- awslabs/cdk_mcp_server/static/__init__.py +10 -0
- 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.81004.dist-info}/METADATA +71 -2
- awslabs_cdk_mcp_server-0.0.81004.dist-info/RECORD +51 -0
- 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/RECORD +0 -72
- {awslabs_cdk_mcp_server-0.0.62303.dist-info → awslabs_cdk_mcp_server-0.0.81004.dist-info}/WHEEL +0 -0
- {awslabs_cdk_mcp_server-0.0.62303.dist-info → awslabs_cdk_mcp_server-0.0.81004.dist-info}/entry_points.txt +0 -0
|
@@ -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
|
|
|
@@ -1,3 +1,13 @@
|
|
|
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.
|
|
1
11
|
from importlib import resources
|
|
2
12
|
|
|
3
13
|
|
|
@@ -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.81004.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.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}`
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
awslabs/__init__.py,sha256=CyFUCiG6C9srM7h_p6i9w72Y_G53m4QN-jK0duBu948,558
|
|
2
|
+
awslabs/cdk_mcp_server/__init__.py,sha256=tE_wgU3b_iQUzMy9HlAJUehazMBzM9hGM94kDKPEDq4,748
|
|
3
|
+
awslabs/cdk_mcp_server/server.py,sha256=Mom-3sv93jLG-KdESEfbrIEo3isXdAMhHcyTxANFtBw,693
|
|
4
|
+
awslabs/cdk_mcp_server/core/__init__.py,sha256=P5jMlOb_nAqCEM22QnIe9RZMUCLVHwmAnwqJInvcQfc,605
|
|
5
|
+
awslabs/cdk_mcp_server/core/resources.py,sha256=DBIgjzhBorbjtDp-qRxq16oGnK39KHtZlKlUXXhKKC4,10152
|
|
6
|
+
awslabs/cdk_mcp_server/core/search_utils.py,sha256=GLaNJBFzmDgwM8OY98R4VHfgj2Cw7GEBk-Y2lLZcPjM,6144
|
|
7
|
+
awslabs/cdk_mcp_server/core/server.py,sha256=FmEb02_yu8kjr7PL-8fZ51Tu7ywl8kbMsxWMjrhvRlY,3145
|
|
8
|
+
awslabs/cdk_mcp_server/core/tools.py,sha256=m_GkmypslKBbhOA8VcDQmXRhwaLUi9BvSi0OO0zqINs,19279
|
|
9
|
+
awslabs/cdk_mcp_server/data/__init__.py,sha256=8o7-TnXbiVvfwc_xc6LGnDfERnD9GMPRFfnWcgf--0Y,605
|
|
10
|
+
awslabs/cdk_mcp_server/data/cdk_nag_parser.py,sha256=c_gIWGvn9zQzyfr-U-uBWR5b4n68PjSDNSj8c8AH370,11459
|
|
11
|
+
awslabs/cdk_mcp_server/data/construct_descriptions.py,sha256=CBfKFM_pJo6Sn_NA7hr-0oVB8piXdncQ_A5ewnTCx30,3164
|
|
12
|
+
awslabs/cdk_mcp_server/data/genai_cdk_loader.py,sha256=wARJk0pH8_3_ic2t9sa7zV8djQVOp_iNRUJw1hJxCIg,16066
|
|
13
|
+
awslabs/cdk_mcp_server/data/lambda_powertools_loader.py,sha256=5Wk0mLyakthzazGteGTCmk4uGOdmZfzHrNCfKGhrzVQ,2393
|
|
14
|
+
awslabs/cdk_mcp_server/data/schema_generator.py,sha256=p2RGeitGt82blWsO3LEQdleYGxfkTZIOjlUaV5CsqPM,29107
|
|
15
|
+
awslabs/cdk_mcp_server/data/solutions_constructs_parser.py,sha256=ceIZwKlj_zdxC1Z17NZ2FKCeVFwNZCoj7GwTjDlC_Q4,28215
|
|
16
|
+
awslabs/cdk_mcp_server/static/CDK_GENERAL_GUIDANCE.md,sha256=aFUZvhfELhS7UEffFIzJM-tRS8a7Aj13X9O7FnGN0UI,12245
|
|
17
|
+
awslabs/cdk_mcp_server/static/CDK_NAG_GUIDANCE.md,sha256=zJtHJp9ruaaJ-xa68k9kDrPmEaXpiWCZZf7JIy8NK0w,5839
|
|
18
|
+
awslabs/cdk_mcp_server/static/__init__.py,sha256=6MiRoh0eFS7TU_pj09tFRjWROSG2nYkMXLcWMdm5WAs,752
|
|
19
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/bedrockguardrails.md,sha256=CX00B7XgDpLbVxvf6B-a13O4NERAJMiaPPeTuKK-8Sw,7386
|
|
20
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/profiles.md,sha256=xxPnEkZ0tJAFKomMuAPLm3EtlQFku6MR2nPu4VoyppE,7195
|
|
21
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/actiongroups.md,sha256=m40RkxPkX3BI4PHEBQHHPOAAK0rgdPkLVi37F3JcLZQ,4857
|
|
22
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/alias.md,sha256=eyTmjmHyQbuR5CbFpp2qrEcEqw2l9pMupWERRVksVNw,1293
|
|
23
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/collaboration.md,sha256=nNu30F5ydUbb7HtboUWNhp0hOnQMw8q8shCUjMDwT_A,3616
|
|
24
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/creation.md,sha256=BzpVJkRs_q1ZkW8LnIEh7--57OnNmHHdPCygfGJAks0,6216
|
|
25
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/custom_orchestration.md,sha256=ylMTq3PT3vHnrul_boLuQIGQFuk_Y0evdImp_pLY7rY,2983
|
|
26
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/overview.md,sha256=4FLhC3CC01W9Gpw4S0Z6yWPnM86p2nJ_dxQ1yU4Xsxw,2921
|
|
27
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/prompt_override.md,sha256=ypmKxlO5WIYqUh2gYDzo1Mwzso_HwSkzrMHeDU473C8,2520
|
|
28
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/chunking.md,sha256=TpLXPJso6c4MhWUepX0WsX3FE6FOIsFBPcE28B-3iKM,3203
|
|
29
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/datasources.md,sha256=iHQ086zHzkqHoKLi7pmyMxf0oH02UVHf_GAid6EMdeE,7147
|
|
30
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/kendra.md,sha256=sYbhIAaGjuJ2lifP0xvDXacDEVFC24Gl9giAI6RF9bo,2786
|
|
31
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/overview.md,sha256=AGLS6146UufRTC80EAyAviBhAtb7hFcbMz3tWFviPOc,5167
|
|
32
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/parsing.md,sha256=AQ6TTO5HxKqhtVdv1bM6GjHyDgOICaNi5NtDT9Dxp10,1155
|
|
33
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/transformation.md,sha256=I5Lkn0giUr5n0lTxqjtUsoHNkom6AJtxEnvlarH_54Y,813
|
|
34
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/aurora.md,sha256=CjiJDoaui2H4-nu99Sem4rK_8pQGB_ciI5So5pKWMSQ,5766
|
|
35
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/creation.md,sha256=jXxrwnor7_YUJc9sYCHjrQnCnHQrVItPI7YttcX-mX8,4491
|
|
36
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/opensearch.md,sha256=mM8nILHaFaLfHUaIl7c8Eh0NFx8Z5H4yu5LbC-DmnSU,1368
|
|
37
|
+
awslabs/cdk_mcp_server/static/genai_cdk/bedrock/knowledgebases/vector/pinecone.md,sha256=OnKjSXB6CHBxnXJFGbsIRqpLyA6_S2AiHOJslxQVaOw,2053
|
|
38
|
+
awslabs/cdk_mcp_server/static/genai_cdk/opensearch-vectorindex/overview.md,sha256=0aSuBwX4ubI5WqwEfrnX1MH2UJlJOzdXZQ003fRIrGM,4121
|
|
39
|
+
awslabs/cdk_mcp_server/static/genai_cdk/opensearchserverless/overview.md,sha256=aUO1BRana_xqUPENP3GQyOSCAvV9mI-ZWls7x0g8ruA,746
|
|
40
|
+
awslabs/cdk_mcp_server/static/lambda_powertools/bedrock.md,sha256=iqmnsoOQlXHOwsvF9U5quIclIBQvv4mEf2TGFnZI_SA,4284
|
|
41
|
+
awslabs/cdk_mcp_server/static/lambda_powertools/cdk.md,sha256=XBj-31YcphHb1BjCYz4nRpAfPuVJVRmDYI2K7e6Ti8E,3826
|
|
42
|
+
awslabs/cdk_mcp_server/static/lambda_powertools/dependencies.md,sha256=nZ2Fv54rG1rUmD_YHkM9h5VNvB81-Hk8Qx3ZNQSFZLY,1520
|
|
43
|
+
awslabs/cdk_mcp_server/static/lambda_powertools/index.md,sha256=yivjInZAZ3tENKGrrAv7geICzUvKUTskWuaNj9nuPbI,1819
|
|
44
|
+
awslabs/cdk_mcp_server/static/lambda_powertools/insights.md,sha256=t-lgyx2AstqXuY7LeWyhQxknrPN27-nAcwW-GTjI058,3445
|
|
45
|
+
awslabs/cdk_mcp_server/static/lambda_powertools/logging.md,sha256=6CSgD8QB3Bs4s_x4RnbKwZoWvG6aG4etCnmDH6HU9XY,1797
|
|
46
|
+
awslabs/cdk_mcp_server/static/lambda_powertools/metrics.md,sha256=XpQHtNSQRKN3GUqQWkk1lTfQSRC0LmW6VoX1dlwEvnQ,3182
|
|
47
|
+
awslabs/cdk_mcp_server/static/lambda_powertools/tracing.md,sha256=Q3dSCvgktb9sUsuuQ5ONU2Qdb1OTwbNOYpK--MDzBNw,2539
|
|
48
|
+
awslabs_cdk_mcp_server-0.0.81004.dist-info/METADATA,sha256=mBHvzTFHyb40gc_0tpKlU9TuypMrG_CVtAiHY_cKneo,6508
|
|
49
|
+
awslabs_cdk_mcp_server-0.0.81004.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
50
|
+
awslabs_cdk_mcp_server-0.0.81004.dist-info/entry_points.txt,sha256=LertzmID_mUU1YYZPySAF1IY1zE7ySTvzFxiGyo3VjY,78
|
|
51
|
+
awslabs_cdk_mcp_server-0.0.81004.dist-info/RECORD,,
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
# Action Groups
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Action groups define functions your agent can call, connecting Bedrock Agents to your business logic via Lambda functions. The agent uses an OpenAPI schema to understand what your functions do and how to call them.
|
|
6
|
-
|
|
7
|
-
```mermaid
|
|
8
|
-
graph LR
|
|
9
|
-
A[Agent] --> B[Action Group]
|
|
10
|
-
B --> C[Lambda Function]
|
|
11
|
-
B --> D[OpenAPI Schema]
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Action Group Properties
|
|
15
|
-
|
|
16
|
-
| Name | Type | Required | Description |
|
|
17
|
-
|---|---|---|---|
|
|
18
|
-
| name | string | Yes | The name of the action group |
|
|
19
|
-
| description | string | No | A description of the action group |
|
|
20
|
-
| apiSchema | ApiSchema | No | The API Schema |
|
|
21
|
-
| executor | ActionGroupExecutor | No | The action group executor |
|
|
22
|
-
| enabled | boolean | No | Specifies whether the action group is available for the agent to invoke or not when sending an InvokeAgent request. Defaults to true |
|
|
23
|
-
| forceDelete | boolean | No | Specifies whether to delete the resource even if it's in use. Defaults to false |
|
|
24
|
-
| functionSchema | CfnAgent.FunctionSchemaProperty | No | Defines functions that each define parameters that the agent needs to invoke from the user |
|
|
25
|
-
| parentActionGroupSignature | ParentActionGroupSignature | No | The AWS Defined signature for enabling certain capabilities in your agent. When specified, description, apiSchema, and actionGroupExecutor must be blank |
|
|
26
|
-
|
|
27
|
-
## OpenAPI Schema Generation & Best Practices
|
|
28
|
-
|
|
29
|
-
For Action Groups, use the built-in OpenAPI schema generation tool provided by the AWS CDK MCP server:
|
|
30
|
-
|
|
31
|
-
```typescript
|
|
32
|
-
// Using MCP client
|
|
33
|
-
const result = await use_mcp_tool({
|
|
34
|
-
server_name: "awslabs.cdk-mcp-server",
|
|
35
|
-
tool_name: "GenerateBedrockAgentSchemaFromFile",
|
|
36
|
-
arguments: {
|
|
37
|
-
lambda_code_path: "path/to/your/lambda.py",
|
|
38
|
-
output_path: "path/to/output/openapi.json"
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
The tool will:
|
|
44
|
-
|
|
45
|
-
1. Parse your Lambda function code
|
|
46
|
-
2. Extract function signatures and docstrings
|
|
47
|
-
3. Generate a Bedrock-compatible OpenAPI schema
|
|
48
|
-
4. Save it to the specified output path
|
|
49
|
-
|
|
50
|
-
### Key Requirements
|
|
51
|
-
- Ensure each operation has a unique operationId
|
|
52
|
-
- Define complete response schemas
|
|
53
|
-
- Use `fromLocalAsset` (not `fromAsset`) for API schemas
|
|
54
|
-
- Include detailed descriptions for all endpoints, parameters, and return values
|
|
55
|
-
- Use proper type annotations with Python type hints
|
|
56
|
-
|
|
57
|
-
### Lambda Function Example
|
|
58
|
-
|
|
59
|
-
```python
|
|
60
|
-
from aws_lambda_powertools.event_handler import BedrockAgentResolver
|
|
61
|
-
from typing import Annotated, List
|
|
62
|
-
from aws_lambda_powertools.event_handler.openapi.params import Query, Path
|
|
63
|
-
from pydantic import BaseModel, Field
|
|
64
|
-
|
|
65
|
-
app = BedrockAgentResolver()
|
|
66
|
-
|
|
67
|
-
class Product(BaseModel):
|
|
68
|
-
product_id: str = Field(description="Unique product identifier")
|
|
69
|
-
name: str = Field(description="Product name")
|
|
70
|
-
price: float = Field(description="Product price in USD")
|
|
71
|
-
|
|
72
|
-
@app.get("/products", description="List available products")
|
|
73
|
-
def list_products(
|
|
74
|
-
category: Annotated[str, Query(description="Product category")] = None
|
|
75
|
-
) -> List[Product]:
|
|
76
|
-
# Your business logic here
|
|
77
|
-
return [Product(product_id="1", name="Product A", price=19.99)]
|
|
78
|
-
|
|
79
|
-
def lambda_handler(event, context):
|
|
80
|
-
return app.resolve(event, context)
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Examples
|
|
84
|
-
|
|
85
|
-
### TypeScript
|
|
86
|
-
|
|
87
|
-
```ts
|
|
88
|
-
const actionGroupFunction = new lambda_python.PythonFunction(this, 'ActionGroupFunction', {
|
|
89
|
-
runtime: lambda.Runtime.PYTHON_3_12,
|
|
90
|
-
entry: path.join(__dirname, '../lambda/action-group'),
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// Example of proper Action Group setup with fromLocalAsset
|
|
94
|
-
const actionGroup = new AgentActionGroup({
|
|
95
|
-
name: 'query-library',
|
|
96
|
-
description: 'Use these functions to get information about the books in the library.',
|
|
97
|
-
executor: bedrock.ActionGroupExecutor.fromlambdaFunction(actionGroupFunction),
|
|
98
|
-
enabled: true,
|
|
99
|
-
apiSchema: bedrock.ApiSchema.fromLocalAsset(path.join(__dirname, 'action-group.yaml')),
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
agent.addActionGroup(actionGroup);
|
|
103
|
-
|
|
104
|
-
// Real-world example with account actions
|
|
105
|
-
const agentAccountActions = new AgentActionGroup({
|
|
106
|
-
name: "agent-account-actions",
|
|
107
|
-
description: "Use these functions to take actions on authenticated user's accounts",
|
|
108
|
-
executor: bedrock.ActionGroupExecutor.fromlambdaFunction(accountActionsLambda),
|
|
109
|
-
apiSchema: bedrock.ApiSchema.fromLocalAsset(
|
|
110
|
-
path.join(agentsLambdaDir, "account_actions", "openapi.json"),
|
|
111
|
-
),
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
agent.addActionGroup(agentAccountActions);
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### Python
|
|
118
|
-
|
|
119
|
-
```python
|
|
120
|
-
action_group_function = PythonFunction(
|
|
121
|
-
self,
|
|
122
|
-
"LambdaFunction",
|
|
123
|
-
runtime=Runtime.PYTHON_3_12,
|
|
124
|
-
entry="./lambda",
|
|
125
|
-
index="app.py",
|
|
126
|
-
handler="lambda_handler",
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
actionGroup = bedrock.AgentActionGroup(
|
|
130
|
-
name="query-library",
|
|
131
|
-
description="Use these functions to get information about the books in the library.",
|
|
132
|
-
executor= bedrock.ActionGroupExecutor.fromlambda_function(action_group_function),
|
|
133
|
-
enabled=True,
|
|
134
|
-
api_schema=bedrock.ApiSchema.from_local_asset("action-group.yaml"))
|
|
135
|
-
|
|
136
|
-
agent.add_action_group(actionGroup)
|
|
137
|
-
```
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# Agent Alias
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
After you have sufficiently iterated on your working draft and are satisfied with the behavior of your agent, you can set it up for deployment and integration into your application by creating aliases of your agent.
|
|
6
|
-
|
|
7
|
-
To deploy your agent, you need to create an alias. During alias creation, Amazon Bedrock automatically creates a version of your agent. The alias points to this newly created version. You can point the alias to a previously created version if necessary. You then configure your application to make API calls to that alias.
|
|
8
|
-
|
|
9
|
-
By default, the `Agent` resource does not create any aliases, and you can use the 'DRAFT' version.
|
|
10
|
-
|
|
11
|
-
## Specific Version
|
|
12
|
-
|
|
13
|
-
You can use the `AgentAlias` resource if you want to create an Alias for an existing Agent.
|
|
14
|
-
|
|
15
|
-
## Example
|
|
16
|
-
|
|
17
|
-
### TypeScript
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
const agentAlias2 = new bedrock.AgentAlias(this, 'myalias2', {
|
|
21
|
-
aliasName: 'myalias',
|
|
22
|
-
agent: agent,
|
|
23
|
-
agentVersion: '1', // optional
|
|
24
|
-
description: 'mytest'
|
|
25
|
-
});
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Python
|
|
29
|
-
|
|
30
|
-
```python
|
|
31
|
-
agent_alias_2 = bedrock.AgentAlias(self, 'myalias2',
|
|
32
|
-
alias_name='myalias',
|
|
33
|
-
agent=agent,
|
|
34
|
-
agent_version='1', # optional
|
|
35
|
-
description='mytest'
|
|
36
|
-
)
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
[View full documentation](https://github.com/awslabs/generative-ai-cdk-constructs/blob/main/src/cdk-lib/bedrock/README.md)
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# Agent Collaboration
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Agent Collaboration enables multiple Bedrock Agents to work together on complex tasks. This feature allows agents to specialize in different areas and collaborate to provide more comprehensive responses to user queries.
|
|
6
|
-
|
|
7
|
-
## Collaboration Types
|
|
8
|
-
|
|
9
|
-
You can configure collaboration for an agent using the `agentCollaboration` and `agentCollaborators` properties in the `AgentProps` interface.
|
|
10
|
-
|
|
11
|
-
- **SUPERVISOR**: The agent acts as a supervisor that can delegate tasks to other agents.
|
|
12
|
-
- **SUPERVISOR_ROUTER**: The agent acts as a supervisor that can route requests to specialized agents.
|
|
13
|
-
- **DISABLED**: Collaboration is disabled (default).
|
|
14
|
-
|
|
15
|
-
## Example
|
|
16
|
-
|
|
17
|
-
### TypeScript
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
import { Agent, AgentCollaboratorType, RelayConversationHistoryType } from '@cdklabs/generative-ai-cdk-constructs';
|
|
21
|
-
|
|
22
|
-
// Create a specialized agent for customer support
|
|
23
|
-
const customerSupportAgent = new Agent(this, 'CustomerSupportAgent', {
|
|
24
|
-
name: 'CustomerSupportAgent',
|
|
25
|
-
instruction: 'You specialize in answering customer support questions about our products.',
|
|
26
|
-
foundationModel: bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// Create an agent alias for the specialized agent
|
|
30
|
-
const customerSupportAlias = new AgentAlias(this, 'CustomerSupportAlias', {
|
|
31
|
-
agent: customerSupportAgent,
|
|
32
|
-
aliasName: 'production',
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// Create a main agent that can collaborate with the specialized agent
|
|
36
|
-
const mainAgent = new Agent(this, 'MainAgent', {
|
|
37
|
-
name: 'MainAgent',
|
|
38
|
-
instruction: 'You are a helpful assistant that can answer general questions and route specialized customer support questions to the customer support agent.',
|
|
39
|
-
foundationModel: bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
|
|
40
|
-
agentCollaboration: AgentCollaboratorType.SUPERVISOR,
|
|
41
|
-
agentCollaborators: [
|
|
42
|
-
new bedrock.AgentCollaborator({
|
|
43
|
-
agentAlias: customerSupportAlias,
|
|
44
|
-
collaborationInstruction: 'Route customer support questions to this agent.',
|
|
45
|
-
collaboratorName: 'CustomerSupport',
|
|
46
|
-
relayConversationHistory: true,
|
|
47
|
-
}),
|
|
48
|
-
],
|
|
49
|
-
});
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Python
|
|
53
|
-
|
|
54
|
-
```python
|
|
55
|
-
from cdklabs.generative_ai_cdk_constructs import (
|
|
56
|
-
bedrock,
|
|
57
|
-
AgentCollaboratorType,
|
|
58
|
-
RelayConversationHistoryType
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
# Create a specialized agent for customer support
|
|
62
|
-
customer_support_agent = bedrock.Agent(self, 'CustomerSupportAgent',
|
|
63
|
-
name='CustomerSupportAgent',
|
|
64
|
-
instruction='You specialize in answering customer support questions about our products.',
|
|
65
|
-
foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
# Create an agent alias for the specialized agent
|
|
69
|
-
customer_support_alias = bedrock.AgentAlias(self, 'CustomerSupportAlias',
|
|
70
|
-
agent=customer_support_agent,
|
|
71
|
-
alias_name='production',
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
# Create a main agent that can collaborate with the specialized agent
|
|
75
|
-
main_agent = bedrock.Agent(self, 'MainAgent',
|
|
76
|
-
name='MainAgent',
|
|
77
|
-
instruction='You are a helpful assistant that can answer general questions and route specialized customer support questions to the customer support agent.',
|
|
78
|
-
foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
|
|
79
|
-
agent_collaboration=AgentCollaboratorType.SUPERVISOR,
|
|
80
|
-
agent_collaborators=[
|
|
81
|
-
bedrock.AgentCollaborator(
|
|
82
|
-
agent_alias= customer_support_alias,
|
|
83
|
-
collaboration_instruction= 'Route customer support questions to this agent.',
|
|
84
|
-
collaborator_name= 'CustomerSupport',
|
|
85
|
-
relay_conversation_history= true,
|
|
86
|
-
)
|
|
87
|
-
],
|
|
88
|
-
)
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
For more information on agent collaboration, refer to the [AWS Bedrock documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-collaboration.html).
|