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.
Files changed (45) hide show
  1. awslabs/__init__.py +10 -2
  2. awslabs/cdk_mcp_server/__init__.py +10 -0
  3. awslabs/cdk_mcp_server/core/__init__.py +10 -0
  4. awslabs/cdk_mcp_server/core/resources.py +11 -0
  5. awslabs/cdk_mcp_server/core/search_utils.py +11 -0
  6. awslabs/cdk_mcp_server/core/server.py +12 -1
  7. awslabs/cdk_mcp_server/core/tools.py +154 -0
  8. awslabs/cdk_mcp_server/data/__init__.py +10 -0
  9. awslabs/cdk_mcp_server/data/cdk_nag_parser.py +11 -0
  10. awslabs/cdk_mcp_server/data/construct_descriptions.py +11 -0
  11. awslabs/cdk_mcp_server/data/genai_cdk_loader.py +11 -0
  12. awslabs/cdk_mcp_server/data/lambda_powertools_loader.py +17 -4
  13. awslabs/cdk_mcp_server/data/schema_generator.py +22 -3
  14. awslabs/cdk_mcp_server/data/solutions_constructs_parser.py +11 -0
  15. awslabs/cdk_mcp_server/server.py +11 -0
  16. awslabs/cdk_mcp_server/static/CDK_GENERAL_GUIDANCE.md +108 -66
  17. awslabs/cdk_mcp_server/static/__init__.py +10 -0
  18. awslabs/cdk_mcp_server/static/genai_cdk/bedrock/agent/actiongroups.md +1 -1
  19. awslabs/cdk_mcp_server/static/lambda_powertools/bedrock.md +1 -1
  20. {awslabs_cdk_mcp_server-0.0.62303.dist-info → awslabs_cdk_mcp_server-0.0.81004.dist-info}/METADATA +71 -2
  21. awslabs_cdk_mcp_server-0.0.81004.dist-info/RECORD +51 -0
  22. awslabs/cdk_mcp_server/static/bedrock/agent/actiongroups.md +0 -137
  23. awslabs/cdk_mcp_server/static/bedrock/agent/alias.md +0 -39
  24. awslabs/cdk_mcp_server/static/bedrock/agent/collaboration.md +0 -91
  25. awslabs/cdk_mcp_server/static/bedrock/agent/creation.md +0 -149
  26. awslabs/cdk_mcp_server/static/bedrock/agent/custom_orchestration.md +0 -74
  27. awslabs/cdk_mcp_server/static/bedrock/agent/overview.md +0 -78
  28. awslabs/cdk_mcp_server/static/bedrock/agent/prompt_override.md +0 -70
  29. awslabs/cdk_mcp_server/static/bedrock/bedrockguardrails.md +0 -188
  30. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/chunking.md +0 -137
  31. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/datasources.md +0 -225
  32. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/kendra.md +0 -81
  33. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/overview.md +0 -116
  34. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/parsing.md +0 -36
  35. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/transformation.md +0 -30
  36. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/aurora.md +0 -185
  37. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/creation.md +0 -80
  38. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/opensearch.md +0 -56
  39. awslabs/cdk_mcp_server/static/bedrock/knowledgebases/vector/pinecone.md +0 -66
  40. awslabs/cdk_mcp_server/static/bedrock/profiles.md +0 -153
  41. awslabs/cdk_mcp_server/static/opensearch-vectorindex/overview.md +0 -135
  42. awslabs/cdk_mcp_server/static/opensearchserverless/overview.md +0 -17
  43. awslabs_cdk_mcp_server-0.0.62303.dist-info/RECORD +0 -72
  44. {awslabs_cdk_mcp_server-0.0.62303.dist-info → awslabs_cdk_mcp_server-0.0.81004.dist-info}/WHEEL +0 -0
  45. {awslabs_cdk_mcp_server-0.0.62303.dist-info → awslabs_cdk_mcp_server-0.0.81004.dist-info}/entry_points.txt +0 -0
awslabs/__init__.py CHANGED
@@ -1,2 +1,10 @@
1
- # This file is part of the awslabs namespace.
2
- # It is intentionally minimal to support PEP 420 namespace packages.
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,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
  """AWS CDK MCP server package."""
2
12
 
3
13
  # Import the minimal set of essential functions
@@ -1 +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.
1
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='GenerateBedrockAgentSchemaFromFile')(tools.bedrock_schema_generator_from_file)
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
 
@@ -1 +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.
1
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
- file_path = os.path.join(
38
- os.path.dirname(__file__), 'static', 'lambda_powertools', f'{topic.lower()}.md'
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("Fixed OpenAPI version to 3.0.0 (Pydantic v2 issue)")
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
- print("You may need to manually modify the script to handle this error.")
166
- print("Focus on preserving the BedrockAgentResolver app definition and routes.")
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
@@ -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
  from awslabs.cdk_mcp_server.core.server import main