awslabs.cfn-mcp-server 1.0.3__tar.gz → 1.0.5__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.
Files changed (36) hide show
  1. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/Dockerfile +9 -6
  2. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/PKG-INFO +1 -1
  3. awslabs_cfn_mcp_server-1.0.5/awslabs/__init__.py +16 -0
  4. awslabs_cfn_mcp_server-1.0.5/awslabs/cfn_mcp_server/__init__.py +17 -0
  5. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/awslabs/cfn_mcp_server/aws_client.py +9 -6
  6. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/awslabs/cfn_mcp_server/cloud_control_utils.py +29 -10
  7. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/awslabs/cfn_mcp_server/context.py +14 -0
  8. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/awslabs/cfn_mcp_server/errors.py +9 -6
  9. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/awslabs/cfn_mcp_server/iac_generator.py +9 -6
  10. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/awslabs/cfn_mcp_server/schema_manager.py +9 -6
  11. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/awslabs/cfn_mcp_server/server.py +13 -10
  12. awslabs_cfn_mcp_server-1.0.5/docker-healthcheck.sh +26 -0
  13. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/pyproject.toml +1 -1
  14. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/run_tests.sh +14 -0
  15. awslabs_cfn_mcp_server-1.0.5/tests/__init__.py +14 -0
  16. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/tests/test_aws_client.py +9 -6
  17. awslabs_cfn_mcp_server-1.0.5/tests/test_cloud_control_utils.py +201 -0
  18. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/tests/test_errors.py +9 -6
  19. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/tests/test_iac_generator.py +9 -6
  20. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/tests/test_init.py +9 -6
  21. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/tests/test_main.py +9 -6
  22. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/tests/test_schema_manager.py +9 -6
  23. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/tests/test_server.py +9 -6
  24. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/uv.lock +1 -1
  25. awslabs_cfn_mcp_server-1.0.3/awslabs/__init__.py +0 -13
  26. awslabs_cfn_mcp_server-1.0.3/awslabs/cfn_mcp_server/__init__.py +0 -14
  27. awslabs_cfn_mcp_server-1.0.3/docker-healthcheck.sh +0 -12
  28. awslabs_cfn_mcp_server-1.0.3/tests/__init__.py +0 -11
  29. awslabs_cfn_mcp_server-1.0.3/tests/test_cloud_control_utils.py +0 -108
  30. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/.gitignore +0 -0
  31. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/.pre-commit-config.yaml +0 -0
  32. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/.python-version +0 -0
  33. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/CHANGELOG.md +0 -0
  34. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/LICENSE +0 -0
  35. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/NOTICE +0 -0
  36. {awslabs_cfn_mcp_server-1.0.3 → awslabs_cfn_mcp_server-1.0.5}/README.md +0 -0
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
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
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
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.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
 
12
15
  #FROM public.ecr.aws/sam/build-python3.10:1.137.1-20250411084548
13
16
  FROM public.ecr.aws/sam/build-python3.10@sha256:e78695db10ca8cb129e59e30f7dc9789b0dbd0181dba195d68419c72bac51ac1 AS uv
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: awslabs.cfn-mcp-server
3
- Version: 1.0.3
3
+ Version: 1.0.5
4
4
  Summary: An AWS Labs Model Context Protocol (MCP) server for doing common cloudformation tasks and for managing your resources in your AWS account
5
5
  Project-URL: homepage, https://awslabs.github.io/mcp/
6
6
  Project-URL: docs, https://awslabs.github.io/mcp/servers/cfn-mcp-server/
@@ -0,0 +1,16 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # This file is part of the awslabs namespace.
16
+ # It is intentionally minimal to support PEP 420 namespace packages.
@@ -0,0 +1,17 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """awslabs.cfn-mcp-server"""
16
+
17
+ __version__ = '1.0.3'
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
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
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
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.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
 
12
15
  import botocore.config
13
16
  import sys
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
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
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
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.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
 
12
15
  from awslabs.cfn_mcp_server.errors import ClientError
13
16
 
@@ -33,19 +36,18 @@ def validate_patch(patch_document: list):
33
36
  raise ClientError(f"The '{patch_op['op']}' operation requires a 'from' field")
34
37
 
35
38
 
36
- def progress_event(response_event) -> dict[str, str]:
39
+ def progress_event(response_event, hooks_events) -> dict[str, str]:
37
40
  """Map a CloudControl API response to a standard output format for the MCP."""
38
41
  response = {
39
42
  'status': response_event['OperationStatus'],
40
43
  'resource_type': response_event['TypeName'],
41
- 'is_complete': response_event['OperationStatus'] == 'SUCCESS',
44
+ 'is_complete': response_event['OperationStatus'] == 'SUCCESS'
45
+ or response_event['OperationStatus'] == 'FAILED',
42
46
  'request_token': response_event['RequestToken'],
43
47
  }
44
48
 
45
49
  if response_event.get('Identifier', None):
46
50
  response['identifier'] = response_event['Identifier']
47
- if response_event.get('StatusMessage', None):
48
- response['status_message'] = response_event['StatusMessage']
49
51
  if response_event.get('ResourceModel', None):
50
52
  response['resource_info'] = response_event['ResourceModel']
51
53
  if response_event.get('ErrorCode', None):
@@ -55,4 +57,21 @@ def progress_event(response_event) -> dict[str, str]:
55
57
  if response_event.get('RetryAfter', None):
56
58
  response['retry_after'] = response_event['RetryAfter']
57
59
 
60
+ # CloudControl returns a list of hooks events which may also contain a message which should
61
+ # take precedent over the status message returned from CloudControl directly
62
+ hooks_status_message = None
63
+ if hooks_events:
64
+ failed_hook_event_messages = (
65
+ hook_event['HookStatusMessage']
66
+ for hook_event in hooks_events
67
+ if hook_event.get('HookStatus', None) == 'HOOK_COMPLETE_FAILED'
68
+ or hook_event.get('HookStatus', None) == 'HOOK_FAILED'
69
+ )
70
+ hooks_status_message = next(failed_hook_event_messages, None)
71
+
72
+ if hooks_status_message:
73
+ response['status_message'] = hooks_status_message
74
+ elif response_event.get('StatusMessage', None):
75
+ response['status_message'] = response_event['StatusMessage']
76
+
58
77
  return response
@@ -1,3 +1,17 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from awslabs.cfn_mcp_server.errors import ServerError
2
16
 
3
17
 
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
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
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
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.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
 
12
15
 
13
16
  def handle_aws_api_error(e: Exception) -> Exception:
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
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
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
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.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
 
12
15
  """CloudFormation IaC Generator tool implementation."""
13
16
 
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
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
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
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.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
 
12
15
  import json
13
16
  import os
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
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
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
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.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
 
12
15
  """awslabs CFN MCP Server implementation."""
13
16
 
@@ -202,7 +205,7 @@ async def update_resource(
202
205
  except Exception as e:
203
206
  raise handle_aws_api_error(e)
204
207
 
205
- return progress_event(response['ProgressEvent'])
208
+ return progress_event(response['ProgressEvent'], None)
206
209
 
207
210
 
208
211
  @mcp.tool()
@@ -253,7 +256,7 @@ async def create_resource(
253
256
  except Exception as e:
254
257
  raise handle_aws_api_error(e)
255
258
 
256
- return progress_event(response['ProgressEvent'])
259
+ return progress_event(response['ProgressEvent'], None)
257
260
 
258
261
 
259
262
  @mcp.tool()
@@ -305,7 +308,7 @@ async def delete_resource(
305
308
  except Exception as e:
306
309
  raise handle_aws_api_error(e)
307
310
 
308
- return progress_event(response['ProgressEvent'])
311
+ return progress_event(response['ProgressEvent'], None)
309
312
 
310
313
 
311
314
  @mcp.tool()
@@ -347,7 +350,7 @@ async def get_resource_request_status(
347
350
  except Exception as e:
348
351
  raise handle_aws_api_error(e)
349
352
 
350
- return progress_event(response['ProgressEvent'])
353
+ return progress_event(response['ProgressEvent'], response.get('HooksProgressEvent', None))
351
354
 
352
355
 
353
356
  @mcp.tool()
@@ -0,0 +1,26 @@
1
+ #!/bin/sh
2
+
3
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ if [ "$(lsof +c 0 -p 1 | grep -e "^awslabs\..*\s1\s.*\sunix\s.*socket$" | wc -l)" -ne "0" ]; then
18
+ echo -n "$(lsof +c 0 -p 1 | grep -e "^awslabs\..*\s1\s.*\sunix\s.*socket$" | wc -l) awslabs.* streams found";
19
+ exit 0;
20
+ else
21
+ echo -n "Zero awslabs.* streams found";
22
+ exit 1;
23
+ fi;
24
+
25
+ echo -n "Never should reach here";
26
+ exit 99;
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "awslabs.cfn-mcp-server"
3
- version = "1.0.3"
3
+ version = "1.0.5"
4
4
  description = "An AWS Labs Model Context Protocol (MCP) server for doing common cloudformation tasks and for managing your resources in your AWS account"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -1,5 +1,19 @@
1
1
  #!/bin/bash
2
2
 
3
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
3
17
  # Exit on error
4
18
  set -e
5
19
 
@@ -0,0 +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");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """Tests for the CloudFormation MCP Server."""
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
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
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
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.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
  """Tests for the cfn MCP Server."""
12
15
 
13
16
  import pytest
@@ -0,0 +1,201 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """Tests for the cfn MCP Server."""
15
+
16
+ import pytest
17
+ from awslabs.cfn_mcp_server.cloud_control_utils import progress_event, validate_patch
18
+ from awslabs.cfn_mcp_server.errors import ClientError
19
+
20
+
21
+ @pytest.mark.asyncio
22
+ class TestUtils:
23
+ """Tests on the cloud_control_utils module."""
24
+
25
+ async def test_empty_patch(self):
26
+ """Testing no information in patch."""
27
+ validate_patch([])
28
+
29
+ async def test_patch_with_invalid_shape_1(self):
30
+ """Testing bad shape."""
31
+ with pytest.raises(ClientError):
32
+ validate_patch(['not_a_dict'])
33
+
34
+ async def test_patch_with_invalid_shape_2(self):
35
+ """Testing no operation."""
36
+ with pytest.raises(ClientError):
37
+ validate_patch([{'not-op': 'is bad'}])
38
+
39
+ async def test_patch_with_invalid_shape_3(self):
40
+ """Testing invalid operation."""
41
+ with pytest.raises(ClientError):
42
+ validate_patch([{'op': 'invalid'}])
43
+
44
+ async def test_patch_with_invalid_shape_4(self):
45
+ """Testing no path."""
46
+ with pytest.raises(ClientError):
47
+ validate_patch([{'op': 'add', 'not-path': 'is bad'}])
48
+
49
+ async def test_happy_remove(self):
50
+ """Testing simple remove."""
51
+ validate_patch([{'op': 'remove', 'path': '/property'}])
52
+
53
+ async def test_patch_with_invalid_shape_5(self):
54
+ """Testing no value."""
55
+ with pytest.raises(ClientError):
56
+ validate_patch([{'op': 'add', 'path': '/property', 'not-value': 'is bad'}])
57
+
58
+ async def test_happy_add(self):
59
+ """Testing simple add."""
60
+ validate_patch([{'op': 'add', 'path': '/property', 'value': '25'}])
61
+
62
+ async def test_patch_with_invalid_shape_6(self):
63
+ """Testing no from."""
64
+ with pytest.raises(ClientError):
65
+ validate_patch([{'op': 'move', 'path': '/property', 'not-from': 'is bad'}])
66
+
67
+ async def test_progress_event(self):
68
+ """Testing mapping progress event."""
69
+ request = {
70
+ 'OperationStatus': 'SUCCESS',
71
+ 'TypeName': 'AWS::CodeStarConnections::Connection',
72
+ 'RequestToken': '25',
73
+ }
74
+
75
+ response = {
76
+ 'status': 'SUCCESS',
77
+ 'resource_type': 'AWS::CodeStarConnections::Connection',
78
+ 'is_complete': True,
79
+ 'request_token': '25',
80
+ }
81
+
82
+ assert progress_event(request, None) == response
83
+
84
+ async def test_progress_event_full(self):
85
+ """Testing mapping progress event with all props."""
86
+ request = {
87
+ 'OperationStatus': 'SUCCESS',
88
+ 'TypeName': 'AWS::CodeStarConnections::Connection',
89
+ 'RequestToken': '25',
90
+ 'Identifier': 'id',
91
+ 'StatusMessage': 'good job',
92
+ 'ResourceModel': 'model',
93
+ 'ErrorCode': 'NONE',
94
+ 'EventTime': '25',
95
+ 'RetryAfter': '10',
96
+ }
97
+
98
+ response = {
99
+ 'status': 'SUCCESS',
100
+ 'resource_type': 'AWS::CodeStarConnections::Connection',
101
+ 'is_complete': True,
102
+ 'request_token': '25',
103
+ 'identifier': 'id',
104
+ 'status_message': 'good job',
105
+ 'resource_info': 'model',
106
+ 'error_code': 'NONE',
107
+ 'event_time': '25',
108
+ 'retry_after': '10',
109
+ }
110
+
111
+ assert progress_event(request, None) == response
112
+
113
+ async def test_progress_event_failed(self):
114
+ """Testing mapping progress event with all props."""
115
+ request = {
116
+ 'OperationStatus': 'FAILED',
117
+ 'TypeName': 'AWS::CodeStarConnections::Connection',
118
+ 'RequestToken': '25',
119
+ 'Identifier': 'id',
120
+ 'StatusMessage': 'good job',
121
+ 'ResourceModel': 'model',
122
+ 'ErrorCode': 'NONE',
123
+ 'EventTime': '25',
124
+ 'RetryAfter': '10',
125
+ }
126
+
127
+ response = {
128
+ 'status': 'FAILED',
129
+ 'resource_type': 'AWS::CodeStarConnections::Connection',
130
+ 'is_complete': True,
131
+ 'request_token': '25',
132
+ 'identifier': 'id',
133
+ 'status_message': 'good job',
134
+ 'resource_info': 'model',
135
+ 'error_code': 'NONE',
136
+ 'event_time': '25',
137
+ 'retry_after': '10',
138
+ }
139
+
140
+ assert progress_event(request, None) == response
141
+
142
+ async def test_progress_event_empty_list_chooses_status_message(self):
143
+ """Testing mapping progress event."""
144
+ request = {
145
+ 'OperationStatus': 'SUCCESS',
146
+ 'TypeName': 'AWS::CodeStarConnections::Connection',
147
+ 'RequestToken': '25',
148
+ 'StatusMessage': 'good job',
149
+ }
150
+
151
+ response = {
152
+ 'status': 'SUCCESS',
153
+ 'resource_type': 'AWS::CodeStarConnections::Connection',
154
+ 'is_complete': True,
155
+ 'request_token': '25',
156
+ 'status_message': 'good job',
157
+ }
158
+
159
+ assert progress_event(request, []) == response
160
+
161
+ async def test_progress_event_successful_hook_chooses_status_message(self):
162
+ """Testing mapping progress event."""
163
+ request = {
164
+ 'OperationStatus': 'SUCCESS',
165
+ 'TypeName': 'AWS::CodeStarConnections::Connection',
166
+ 'RequestToken': '25',
167
+ 'StatusMessage': 'good job',
168
+ }
169
+
170
+ hook = {'HookStatus': 'HOOK_COMPLETE_SUCCEEDED', 'HookStatusMessage': 'DONT SEE THIS'}
171
+
172
+ response = {
173
+ 'status': 'SUCCESS',
174
+ 'resource_type': 'AWS::CodeStarConnections::Connection',
175
+ 'is_complete': True,
176
+ 'request_token': '25',
177
+ 'status_message': 'good job',
178
+ }
179
+
180
+ assert progress_event(request, [hook]) == response
181
+
182
+ async def test_progress_event_failed_hook_chooses_hook_message(self):
183
+ """Testing mapping progress event."""
184
+ request = {
185
+ 'OperationStatus': 'SUCCESS',
186
+ 'TypeName': 'AWS::CodeStarConnections::Connection',
187
+ 'RequestToken': '25',
188
+ 'StatusMessage': 'good job',
189
+ }
190
+
191
+ hook = {'HookStatus': 'HOOK_FAILED', 'HookStatusMessage': 'HOOK FAILED!!'}
192
+
193
+ response = {
194
+ 'status': 'SUCCESS',
195
+ 'resource_type': 'AWS::CodeStarConnections::Connection',
196
+ 'is_complete': True,
197
+ 'request_token': '25',
198
+ 'status_message': 'HOOK FAILED!!',
199
+ }
200
+
201
+ assert progress_event(request, [hook]) == response
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
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
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
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.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
  """Tests for the cfn MCP Server."""
12
15
 
13
16
  import pytest
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
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
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
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.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
 
12
15
  """Tests for the CloudFormation IaC Generator tool."""
13
16
 
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
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
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
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.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
  """Tests for the awslabs.cfn-mcp-server package."""
12
15
 
13
16
  import importlib
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
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
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
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.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
  """Tests for the main function in server.py."""
12
15
 
13
16
  from awslabs.cfn_mcp_server.server import main
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
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
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
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.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
  """Tests for the cfn MCP Server."""
12
15
 
13
16
  import pytest
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
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
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
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.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
  """Tests for the cfn MCP Server."""
12
15
 
13
16
  import pytest
@@ -37,7 +37,7 @@ wheels = [
37
37
 
38
38
  [[package]]
39
39
  name = "awslabs-cfn-mcp-server"
40
- version = "1.0.0"
40
+ version = "1.0.1"
41
41
  source = { editable = "." }
42
42
  dependencies = [
43
43
  { name = "boto3" },
@@ -1,13 +0,0 @@
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
- # This file is part of the awslabs namespace.
13
- # It is intentionally minimal to support PEP 420 namespace packages.
@@ -1,14 +0,0 @@
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
- """awslabs.cfn-mcp-server"""
13
-
14
- __version__ = '1.0.3'
@@ -1,12 +0,0 @@
1
- #!/bin/sh
2
-
3
- if [ "$(lsof +c 0 -p 1 | grep -e "^awslabs\..*\s1\s.*\sunix\s.*socket$" | wc -l)" -ne "0" ]; then
4
- echo -n "$(lsof +c 0 -p 1 | grep -e "^awslabs\..*\s1\s.*\sunix\s.*socket$" | wc -l) awslabs.* streams found";
5
- exit 0;
6
- else
7
- echo -n "Zero awslabs.* streams found";
8
- exit 1;
9
- fi;
10
-
11
- echo -n "Never should reach here";
12
- exit 99;
@@ -1,11 +0,0 @@
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
- """Tests for the CloudFormation MCP Server."""
@@ -1,108 +0,0 @@
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
- """Tests for the cfn MCP Server."""
12
-
13
- import pytest
14
- from awslabs.cfn_mcp_server.cloud_control_utils import progress_event, validate_patch
15
- from awslabs.cfn_mcp_server.errors import ClientError
16
-
17
-
18
- @pytest.mark.asyncio
19
- class TestUtils:
20
- """Tests on the cloud_control_utils module."""
21
-
22
- async def test_empty_patch(self):
23
- """Testing no information in patch."""
24
- validate_patch([])
25
-
26
- async def test_patch_with_invalid_shape_1(self):
27
- """Testing bad shape."""
28
- with pytest.raises(ClientError):
29
- validate_patch(['not_a_dict'])
30
-
31
- async def test_patch_with_invalid_shape_2(self):
32
- """Testing no operation."""
33
- with pytest.raises(ClientError):
34
- validate_patch([{'not-op': 'is bad'}])
35
-
36
- async def test_patch_with_invalid_shape_3(self):
37
- """Testing invalid operation."""
38
- with pytest.raises(ClientError):
39
- validate_patch([{'op': 'invalid'}])
40
-
41
- async def test_patch_with_invalid_shape_4(self):
42
- """Testing no path."""
43
- with pytest.raises(ClientError):
44
- validate_patch([{'op': 'add', 'not-path': 'is bad'}])
45
-
46
- async def test_happy_remove(self):
47
- """Testing simple remove."""
48
- validate_patch([{'op': 'remove', 'path': '/property'}])
49
-
50
- async def test_patch_with_invalid_shape_5(self):
51
- """Testing no value."""
52
- with pytest.raises(ClientError):
53
- validate_patch([{'op': 'add', 'path': '/property', 'not-value': 'is bad'}])
54
-
55
- async def test_happy_add(self):
56
- """Testing simple add."""
57
- validate_patch([{'op': 'add', 'path': '/property', 'value': '25'}])
58
-
59
- async def test_patch_with_invalid_shape_6(self):
60
- """Testing no from."""
61
- with pytest.raises(ClientError):
62
- validate_patch([{'op': 'move', 'path': '/property', 'not-from': 'is bad'}])
63
-
64
- async def test_progress_event(self):
65
- """Testing mapping progress event."""
66
- request = {
67
- 'OperationStatus': 'SUCCESS',
68
- 'TypeName': 'AWS::CodeStarConnections::Connection',
69
- 'RequestToken': '25',
70
- }
71
-
72
- response = {
73
- 'status': 'SUCCESS',
74
- 'resource_type': 'AWS::CodeStarConnections::Connection',
75
- 'is_complete': True,
76
- 'request_token': '25',
77
- }
78
-
79
- assert progress_event(request) == response
80
-
81
- async def test_progress_event_full(self):
82
- """Testing mapping progress event with all props."""
83
- request = {
84
- 'OperationStatus': 'SUCCESS',
85
- 'TypeName': 'AWS::CodeStarConnections::Connection',
86
- 'RequestToken': '25',
87
- 'Identifier': 'id',
88
- 'StatusMessage': 'good job',
89
- 'ResourceModel': 'model',
90
- 'ErrorCode': 'NONE',
91
- 'EventTime': '25',
92
- 'RetryAfter': '10',
93
- }
94
-
95
- response = {
96
- 'status': 'SUCCESS',
97
- 'resource_type': 'AWS::CodeStarConnections::Connection',
98
- 'is_complete': True,
99
- 'request_token': '25',
100
- 'identifier': 'id',
101
- 'status_message': 'good job',
102
- 'resource_info': 'model',
103
- 'error_code': 'NONE',
104
- 'event_time': '25',
105
- 'retry_after': '10',
106
- }
107
-
108
- assert progress_event(request) == response