awslabs.terraform-mcp-server 1.0.0__tar.gz → 1.0.2__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.

Potentially problematic release.


This version of awslabs.terraform-mcp-server might be problematic. Click here for more details.

Files changed (59) hide show
  1. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/Dockerfile +13 -10
  2. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/PKG-INFO +5 -3
  3. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/README.md +4 -2
  4. awslabs_terraform_mcp_server-1.0.2/awslabs/__init__.py +16 -0
  5. awslabs_terraform_mcp_server-1.0.2/awslabs/terraform_mcp_server/__init__.py +17 -0
  6. awslabs_terraform_mcp_server-1.0.2/awslabs/terraform_mcp_server/impl/resources/__init__.py +25 -0
  7. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/impl/resources/terraform_aws_provider_resources_listing.py +14 -0
  8. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/impl/resources/terraform_awscc_provider_resources_listing.py +14 -0
  9. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/impl/tools/__init__.py +14 -0
  10. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/impl/tools/execute_terraform_command.py +14 -0
  11. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/impl/tools/execute_terragrunt_command.py +14 -0
  12. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/impl/tools/run_checkov_scan.py +14 -0
  13. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/impl/tools/search_aws_provider_docs.py +14 -0
  14. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/impl/tools/search_awscc_provider_docs.py +14 -0
  15. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/impl/tools/search_specific_aws_ia_modules.py +14 -0
  16. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/impl/tools/search_user_provided_module.py +9 -6
  17. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/impl/tools/utils.py +14 -0
  18. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/models/__init__.py +14 -0
  19. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/models/models.py +14 -0
  20. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/scripts/generate_aws_provider_resources.py +14 -0
  21. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/scripts/generate_awscc_provider_resources.py +14 -0
  22. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/scripts/scrape_aws_terraform_best_practices.py +14 -0
  23. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/server.py +14 -0
  24. awslabs_terraform_mcp_server-1.0.2/awslabs/terraform_mcp_server/static/__init__.py +36 -0
  25. awslabs_terraform_mcp_server-1.0.2/docker-healthcheck.sh +26 -0
  26. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/pyproject.toml +1 -1
  27. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/conftest.py +8 -5
  28. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/test_models.py +8 -5
  29. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/test_server.py +8 -5
  30. awslabs_terraform_mcp_server-1.0.2/uv-requirements.txt +26 -0
  31. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/uv.lock +3 -3
  32. awslabs_terraform_mcp_server-1.0.0/.pre-commit-config.yaml +0 -14
  33. awslabs_terraform_mcp_server-1.0.0/awslabs/__init__.py +0 -2
  34. awslabs_terraform_mcp_server-1.0.0/awslabs/terraform_mcp_server/__init__.py +0 -3
  35. awslabs_terraform_mcp_server-1.0.0/awslabs/terraform_mcp_server/impl/resources/__init__.py +0 -11
  36. awslabs_terraform_mcp_server-1.0.0/awslabs/terraform_mcp_server/static/__init__.py +0 -22
  37. awslabs_terraform_mcp_server-1.0.0/docker-healthcheck.sh +0 -12
  38. awslabs_terraform_mcp_server-1.0.0/run_tests.sh +0 -198
  39. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/.gitignore +0 -0
  40. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/.python-version +0 -0
  41. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/CHANGELOG.md +0 -0
  42. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/static/AWSCC_PROVIDER_RESOURCES.md +0 -0
  43. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/static/AWS_PROVIDER_RESOURCES.md +0 -0
  44. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/static/AWS_TERRAFORM_BEST_PRACTICES.md +0 -0
  45. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/static/MCP_INSTRUCTIONS.md +0 -0
  46. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/awslabs/terraform_mcp_server/static/TERRAFORM_WORKFLOW_GUIDE.md +0 -0
  47. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/.gitignore +0 -0
  48. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/README.md +0 -0
  49. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/__init__.py +0 -0
  50. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/test_command_impl.py +0 -0
  51. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/test_execute_terraform_command.py +0 -0
  52. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/test_execute_terragrunt_command.py +0 -0
  53. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/test_parameter_annotations.py +0 -0
  54. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/test_resources.py +0 -0
  55. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/test_run_checkov_scan.py +0 -0
  56. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/test_search_user_provided_module.py +0 -0
  57. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/test_tool_implementations.py +0 -0
  58. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/test_utils.py +0 -0
  59. {awslabs_terraform_mcp_server-1.0.0 → awslabs_terraform_mcp_server-1.0.2}/tests/test_utils_additional.py +0 -0
@@ -1,16 +1,19 @@
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
- FROM public.ecr.aws/sam/build-python3.10@sha256:e78695db10ca8cb129e59e30f7dc9789b0dbd0181dba195d68419c72bac51ac1 AS uv
16
+ FROM public.ecr.aws/sam/build-python3.10@sha256:d821662474d65f3cf2fc97dba2fa807a3adb580d02895fc4545527812550ea65 AS uv
14
17
 
15
18
  # Install the project into `/app`
16
19
  WORKDIR /app
@@ -28,11 +31,11 @@ ENV UV_PYTHON_PREFERENCE=only-system
28
31
  ENV UV_FROZEN=true
29
32
 
30
33
  # Copy the required files first
31
- COPY pyproject.toml uv.lock ./
34
+ COPY pyproject.toml uv.lock uv-requirements.txt ./
32
35
 
33
36
  # Install the project's dependencies using the lockfile and settings
34
37
  RUN --mount=type=cache,target=/root/.cache/uv \
35
- pip install uv && \
38
+ pip install --require-hashes --requirement uv-requirements.txt && \
36
39
  uv sync --frozen --no-install-project --no-dev --no-editable
37
40
 
38
41
  # Then, add the rest of the project source code and install it
@@ -44,7 +47,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
44
47
  # Make the directory just in case it doesn't exist
45
48
  RUN mkdir -p /root/.local
46
49
 
47
- FROM public.ecr.aws/sam/build-python3.10@sha256:e78695db10ca8cb129e59e30f7dc9789b0dbd0181dba195d68419c72bac51ac1
50
+ FROM public.ecr.aws/sam/build-python3.10@sha256:d821662474d65f3cf2fc97dba2fa807a3adb580d02895fc4545527812550ea65
48
51
 
49
52
  # Place executables in the environment at the front of the path and include other binaries
50
53
  ENV PATH="/app/.venv/bin:$PATH:/usr/sbin"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: awslabs.terraform-mcp-server
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: An AWS Labs Model Context Protocol (MCP) server for terraform
5
5
  Requires-Python: >=3.10
6
6
  Requires-Dist: beautifulsoup4>=4.12.0
@@ -78,7 +78,9 @@ MCP server for Terraform on AWS best practices, infrastructure as code patterns,
78
78
 
79
79
  ## Installation
80
80
 
81
- Here are some ways you can work with MCP across AWS, and we'll be adding support to more products including Amazon Q Developer CLI soon: (e.g. for Amazon Q Developer CLI MCP, `~/.aws/amazonq/mcp.json`):
81
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-light.svg)](https://cursor.com/install-mcp?name=awslabs.terraform-mcp-server&config=eyJjb21tYW5kIjoidXZ4IGF3c2xhYnMudGVycmFmb3JtLW1jcC1zZXJ2ZXJAbGF0ZXN0IiwiZW52Ijp7IkZBU1RNQ1BfTE9HX0xFVkVMIjoiRVJST1IifSwiZGlzYWJsZWQiOmZhbHNlLCJhdXRvQXBwcm92ZSI6W119)
82
+
83
+ Configure the MCP server in your MCP client configuration (e.g., for Amazon Q Developer CLI, edit `~/.aws/amazonq/mcp.json`):
82
84
 
83
85
  ```json
84
86
  {
@@ -96,7 +98,7 @@ Here are some ways you can work with MCP across AWS, and we'll be adding support
96
98
  }
97
99
  ```
98
100
 
99
- or docker after a succesful `docker build -t awslabs/terraform-mcp-server .`:
101
+ or docker after a successful `docker build -t awslabs/terraform-mcp-server .`:
100
102
 
101
103
  ```json
102
104
  {
@@ -63,7 +63,9 @@ MCP server for Terraform on AWS best practices, infrastructure as code patterns,
63
63
 
64
64
  ## Installation
65
65
 
66
- Here are some ways you can work with MCP across AWS, and we'll be adding support to more products including Amazon Q Developer CLI soon: (e.g. for Amazon Q Developer CLI MCP, `~/.aws/amazonq/mcp.json`):
66
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-light.svg)](https://cursor.com/install-mcp?name=awslabs.terraform-mcp-server&config=eyJjb21tYW5kIjoidXZ4IGF3c2xhYnMudGVycmFmb3JtLW1jcC1zZXJ2ZXJAbGF0ZXN0IiwiZW52Ijp7IkZBU1RNQ1BfTE9HX0xFVkVMIjoiRVJST1IifSwiZGlzYWJsZWQiOmZhbHNlLCJhdXRvQXBwcm92ZSI6W119)
67
+
68
+ Configure the MCP server in your MCP client configuration (e.g., for Amazon Q Developer CLI, edit `~/.aws/amazonq/mcp.json`):
67
69
 
68
70
  ```json
69
71
  {
@@ -81,7 +83,7 @@ Here are some ways you can work with MCP across AWS, and we'll be adding support
81
83
  }
82
84
  ```
83
85
 
84
- or docker after a succesful `docker build -t awslabs/terraform-mcp-server .`:
86
+ or docker after a successful `docker build -t awslabs/terraform-mcp-server .`:
85
87
 
86
88
  ```json
87
89
  {
@@ -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.terraform-mcp-server"""
16
+
17
+ __version__ = '0.0.0'
@@ -0,0 +1,25 @@
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
+ """Resource implementations for the Terraform expert."""
16
+
17
+ from .terraform_aws_provider_resources_listing import terraform_aws_provider_assets_listing_impl
18
+ from .terraform_awscc_provider_resources_listing import (
19
+ terraform_awscc_provider_resources_listing_impl,
20
+ )
21
+
22
+ __all__ = [
23
+ 'terraform_aws_provider_assets_listing_impl',
24
+ 'terraform_awscc_provider_resources_listing_impl',
25
+ ]
@@ -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
  """Implementation for terraform_aws_provider_resources_listing resource."""
2
16
 
3
17
  import sys
@@ -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
  """Implementation for terraform_awscc_provider_resources_listing resource."""
2
16
 
3
17
  import sys
@@ -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
  """Tool implementations for the terraform MCP server."""
2
16
 
3
17
  from .search_user_provided_module import search_user_provided_module_impl
@@ -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
  """Implementation of Terraform command execution tool."""
2
16
 
3
17
  import json
@@ -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
  """Implementation of Terragrunt command execution tool."""
2
16
 
3
17
  import json
@@ -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
  """Implementation of Checkov scan tools."""
2
16
 
3
17
  import json
@@ -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
  """Implementation of AWS provider documentation search tool."""
2
16
 
3
17
  import re
@@ -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
  """Implementation of AWSCC provider documentation search tool."""
2
16
 
3
17
  import re
@@ -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
  """Implementation of specific AWS-IA module search tool for four key modules."""
2
16
 
3
17
  import asyncio
@@ -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
  """Implementation of user provided module from the Terraform registry search tool."""
12
15
 
13
16
  import re
@@ -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
  """Utility functions for Terraform MCP server tools."""
2
16
 
3
17
  import asyncio
@@ -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 .models import (
2
16
  ModuleSearchResult,
3
17
  TerraformAWSProviderDocsResult,
@@ -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 pydantic import BaseModel, Field
2
16
  from typing import Any, Dict, List, Literal, Optional
3
17
 
@@ -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
  """Script to generate AWS provider resources markdown for the Terraform Expert MCP server.
2
16
 
3
17
  This script scrapes the Terraform AWS provider documentation using Playwright
@@ -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
  """Script to generate AWSCC provider resources markdown for the Terraform Expert MCP server.
2
16
 
3
17
  This script scrapes the Terraform AWSCC provider documentation using Playwright
@@ -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
  """Script to download and extract content from AWS Terraform best practices PDF and save it as markdown."""
2
16
 
3
17
  import io
@@ -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
  #!/usr/bin/env python3
2
16
  """terraform MCP server implementation."""
3
17
 
@@ -0,0 +1,36 @@
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
+ from importlib import resources
16
+
17
+ with (
18
+ resources.files('awslabs.terraform_mcp_server.static')
19
+ .joinpath('MCP_INSTRUCTIONS.md')
20
+ .open('r', encoding='utf-8') as f
21
+ ):
22
+ MCP_INSTRUCTIONS = f.read()
23
+
24
+ with (
25
+ resources.files('awslabs.terraform_mcp_server.static')
26
+ .joinpath('TERRAFORM_WORKFLOW_GUIDE.md')
27
+ .open('r', encoding='utf-8') as f
28
+ ):
29
+ TERRAFORM_WORKFLOW_GUIDE = f.read()
30
+
31
+ with (
32
+ resources.files('awslabs.terraform_mcp_server.static')
33
+ .joinpath('AWS_TERRAFORM_BEST_PRACTICES.md')
34
+ .open('r', encoding='utf-8') as f
35
+ ):
36
+ AWS_TERRAFORM_BEST_PRACTICES = f.read()
@@ -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.terraform-mcp-server"
3
- version = "1.0.0"
3
+ version = "1.0.2"
4
4
  description = "An AWS Labs Model Context Protocol (MCP) server for terraform"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -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
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
  """Test fixtures for the terraform-mcp-server tests."""
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
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 models module of the terraform-mcp-server."""
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
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 server module of the terraform-mcp-server."""
13
16
 
@@ -0,0 +1,26 @@
1
+ #
2
+ # This file is autogenerated by pip-compile with Python 3.10
3
+ # by the following command:
4
+ #
5
+ # pip-compile --generate-hashes --output-file=uv-requirements.txt --strip-extras uv-requirements-0.7.13.in
6
+ #
7
+ uv==0.7.13 \
8
+ --hash=sha256:05f3c03c4ea55d294f3da725b6c2c2ff544754c18552da7594def4ec3889dcfb \
9
+ --hash=sha256:1afdbfcabc3425b383141ba42d413841c0a48b9ee0f4da65459313275e3cea84 \
10
+ --hash=sha256:33837aca7bdf02d47554d5d44f9e71756ee17c97073b07b4afead25309855bc7 \
11
+ --hash=sha256:4efa555b217e15767f0691a51d435f7bb2b0bf473fdfd59f173aeda8a93b8d17 \
12
+ --hash=sha256:4f828174e15a557d3bc0f809de76135c3b66bcbf524657f8ced9d22fc978b89c \
13
+ --hash=sha256:527a12d0c2f4d15f72b275b6f4561ae92af76dd59b4624796fddd45867f13c33 \
14
+ --hash=sha256:5786a29e286f2cc3cbda13a357fd9a4dd5bf1d7448a9d3d842b26b4f784a3a86 \
15
+ --hash=sha256:59915aec9fd2b845708a76ddc6c0639cfc99b6e2811854ea2425ee7552aff0e9 \
16
+ --hash=sha256:721b058064150fc1c6d88e277af093d1b4f8bb7a59546fe9969d9ff7dbe3f6fd \
17
+ --hash=sha256:866cad0d04a7de1aaa3c5cbef203f9d3feef9655972dcccc3283d60122db743b \
18
+ --hash=sha256:88fcf2bfbb53309531a850af50d2ea75874099b19d4159625d0b4f88c53494b9 \
19
+ --hash=sha256:8c0c29a2089ff9011d6c3abccd272f3ee6d0e166dae9e5232099fd83d26104d9 \
20
+ --hash=sha256:9c457a84cfbe2019ba301e14edd3e1c950472abd0b87fc77622ab3fc475ba012 \
21
+ --hash=sha256:9d2952a1e74c7027347c74cee1cb2be09121a5290db38498b8b17ff585f73748 \
22
+ --hash=sha256:a51006c7574e819308d92a3452b22d5bd45ef8593a4983b5856aa7cb8220885f \
23
+ --hash=sha256:b1af81e57d098b21b28f42ec756f0e26dce2341d59ba4e4f11759bc3ca2c0a99 \
24
+ --hash=sha256:e077dcac19e564cae8b4223b7807c2f617a59938f8142ca77fc6348ae9c6d0aa \
25
+ --hash=sha256:f28e70baadfebe71dcc2d9505059b988d75e903fc62258b102eb87dc4b6994a3
26
+ # via -r uv-requirements-0.7.13.in (contents of `uv==0.7.13`)
@@ -949,11 +949,11 @@ wheels = [
949
949
 
950
950
  [[package]]
951
951
  name = "h11"
952
- version = "0.14.0"
952
+ version = "0.16.0"
953
953
  source = { registry = "https://pypi.org/simple" }
954
- sdist = { url = "https://files.pythonhosted.org/packages/f5/38/3af3d3633a34a3316095b39c8e8fb4853a28a536e55d347bd8d8e9a14b03/h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d", size = 100418 }
954
+ sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" }
955
955
  wheels = [
956
- { url = "https://files.pythonhosted.org/packages/95/04/ff642e65ad6b90db43e668d70ffb6736436c7ce41fcc549f4e9472234127/h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761", size = 58259 },
956
+ { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" },
957
957
  ]
958
958
 
959
959
  [[package]]
@@ -1,14 +0,0 @@
1
- repos:
2
- - repo: https://github.com/astral-sh/ruff-pre-commit
3
- rev: v0.9.6
4
- hooks:
5
- - id: ruff
6
- args: [--fix]
7
- - id: ruff-format
8
-
9
- - repo: https://github.com/commitizen-tools/commitizen
10
- rev: v3.13.0
11
- hooks:
12
- - id: commitizen
13
- - id: commitizen-branch
14
- stages: [push]
@@ -1,2 +0,0 @@
1
- # This file is part of the awslabs namespace.
2
- # It is intentionally minimal to support PEP 420 namespace packages.
@@ -1,3 +0,0 @@
1
- """awslabs.terraform-mcp-server"""
2
-
3
- __version__ = '0.0.0'
@@ -1,11 +0,0 @@
1
- """Resource implementations for the Terraform expert."""
2
-
3
- from .terraform_aws_provider_resources_listing import terraform_aws_provider_assets_listing_impl
4
- from .terraform_awscc_provider_resources_listing import (
5
- terraform_awscc_provider_resources_listing_impl,
6
- )
7
-
8
- __all__ = [
9
- 'terraform_aws_provider_assets_listing_impl',
10
- 'terraform_awscc_provider_resources_listing_impl',
11
- ]
@@ -1,22 +0,0 @@
1
- from importlib import resources
2
-
3
- with (
4
- resources.files('awslabs.terraform_mcp_server.static')
5
- .joinpath('MCP_INSTRUCTIONS.md')
6
- .open('r', encoding='utf-8') as f
7
- ):
8
- MCP_INSTRUCTIONS = f.read()
9
-
10
- with (
11
- resources.files('awslabs.terraform_mcp_server.static')
12
- .joinpath('TERRAFORM_WORKFLOW_GUIDE.md')
13
- .open('r', encoding='utf-8') as f
14
- ):
15
- TERRAFORM_WORKFLOW_GUIDE = f.read()
16
-
17
- with (
18
- resources.files('awslabs.terraform_mcp_server.static')
19
- .joinpath('AWS_TERRAFORM_BEST_PRACTICES.md')
20
- .open('r', encoding='utf-8') as f
21
- ):
22
- AWS_TERRAFORM_BEST_PRACTICES = f.read()
@@ -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,198 +0,0 @@
1
- #!/bin/bash
2
- # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
5
- # with the License. A copy of the License is located at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
10
- # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
11
- # and limitations under the License.
12
-
13
- # Script to run tests for the Terraform MCP Server
14
-
15
- set -e
16
-
17
- # Set the Python path to include the current directory and the parent directory
18
- export PYTHONPATH=$PYTHONPATH:$(pwd):$(pwd)/..
19
-
20
- # Check if we're in a virtual environment
21
- if [ -z "$VIRTUAL_ENV" ]; then
22
- echo "Warning: You are not running in a virtual environment."
23
- echo "It's recommended to create and activate a virtual environment before running tests."
24
- echo "You can create one with: python -m venv .venv"
25
- echo "And activate it with: source .venv/bin/activate (Linux/Mac) or .venv\\Scripts\\activate (Windows)"
26
- echo "Continuing without a virtual environment..."
27
- echo ""
28
- fi
29
- echo "Python executable: $(which python)"
30
- # Check if pytest and other dependencies are installed
31
- echo "Checking for required packages..."
32
- MISSING_PACKAGES=()
33
-
34
- # Check for pytest and related packages
35
- if ! python -c "import pytest" 2>/dev/null; then
36
- MISSING_PACKAGES+=("pytest pytest-asyncio pytest-cov")
37
- fi
38
-
39
- # Check for pydantic package
40
- if ! python -c "import pydantic" 2>/dev/null; then
41
- MISSING_PACKAGES+=("pydantic")
42
- fi
43
-
44
- # Check for requests package
45
- if ! python -c "import requests" 2>/dev/null; then
46
- MISSING_PACKAGES+=("requests")
47
- fi
48
-
49
- # Check for loguru package
50
- if ! python -c "import loguru" 2>/dev/null; then
51
- MISSING_PACKAGES+=("loguru")
52
- fi
53
-
54
- # Check for beautifulsoup4 package
55
- if ! python -c "import bs4" 2>/dev/null; then
56
- MISSING_PACKAGES+=("beautifulsoup4")
57
- fi
58
-
59
- # Check for checkov package
60
- if ! python -c "import checkov" 2>/dev/null; then
61
- MISSING_PACKAGES+=("checkov")
62
- fi
63
-
64
- # Install missing packages
65
- if [ ${#MISSING_PACKAGES[@]} -gt 0 ]; then
66
- echo "Installing missing packages: ${MISSING_PACKAGES[*]}"
67
-
68
- # Try pip first (more reliable)
69
- if command -v pip &> /dev/null; then
70
- echo "Using pip to install packages..."
71
- pip install ${MISSING_PACKAGES[*]} -v
72
- # Try pip3 if pip is not available
73
- elif command -v pip3 &> /dev/null; then
74
- echo "Using pip3 to install packages..."
75
- pip3 install ${MISSING_PACKAGES[*]} -v
76
- # Try uv as a last resort
77
- elif command -v uv &> /dev/null; then
78
- echo "Using uv to install packages..."
79
- uv pip install ${MISSING_PACKAGES[*]} -v
80
- else
81
- echo "Error: No package manager (pip, pip3, or uv) is available. Please install the missing packages manually."
82
- exit 1
83
- fi
84
-
85
- # Verify installation with more verbose output
86
- echo "Verifying package installations..."
87
- for pkg in "pytest" "pydantic" "requests" "loguru" "bs4" "checkov"; do
88
- echo "Checking for $pkg..."
89
- if ! python -c "import $pkg; print(f'$pkg installed successfully')"; then
90
- echo "Failed to install $pkg. Trying to install it individually..."
91
- pip install $pkg -v || pip3 install $pkg -v || echo "Failed to install $pkg. Please install it manually."
92
-
93
- # Check again
94
- if ! python -c "import $pkg" 2>/dev/null; then
95
- echo "Still failed to install $pkg. Please install it manually."
96
- echo "You can try: pip install $pkg"
97
- exit 1
98
- fi
99
- fi
100
- done
101
- fi
102
-
103
- # Print debug information
104
- echo "Debug information:"
105
- echo "Python version: $(python --version)"
106
- echo "Python path: $PYTHONPATH"
107
- echo "Current directory: $(pwd)"
108
- echo "Python executable: $(which python)"
109
- echo "Pytest module location: $(python -c "import pytest; print(pytest.__file__)" 2>/dev/null || echo "Not found")"
110
-
111
- # Check if terraform_mcp_server module can be imported
112
- echo "Checking if terraform_mcp_server module can be imported..."
113
- python -c "import awslabs.terraform_mcp_server; print('terraform_mcp_server module found')" 2>/dev/null
114
- if [ $? -ne 0 ]; then
115
- echo "Warning: terraform_mcp_server module cannot be imported. This may cause test failures."
116
- echo "Installing the package in development mode..."
117
-
118
- # Check if uv is available
119
- if command -v uv &> /dev/null; then
120
- uv pip install -e .
121
- # Check if pip is available
122
- elif command -v pip &> /dev/null; then
123
- pip install -e .
124
- else
125
- echo "Neither uv nor pip is available. Creating a symbolic link instead..."
126
- # Create a symbolic link to the module in the current directory
127
- ln -sf $(pwd)/awslabs/terraform_mcp_server $(pwd)/terraform_mcp_server 2>/dev/null
128
- fi
129
-
130
- echo "Trying again..."
131
- python -c "import awslabs.terraform_mcp_server; print('terraform_mcp_server module found')" 2>/dev/null
132
- if [ $? -ne 0 ]; then
133
- echo "Still cannot import terraform_mcp_server module. Tests may fail."
134
- echo "Directory structure:"
135
- ls -la
136
- echo "awslabs directory:"
137
- ls -la awslabs 2>/dev/null || echo "awslabs directory not found"
138
- fi
139
- fi
140
-
141
- # Parse command line arguments
142
- COVERAGE=0
143
- REPORT=0
144
- VERBOSE=0
145
- SPECIFIC_TEST=""
146
-
147
- while [[ $# -gt 0 ]]; do
148
- key="$1"
149
- case $key in
150
- --coverage)
151
- COVERAGE=1
152
- shift
153
- ;;
154
- --report)
155
- REPORT=1
156
- shift
157
- ;;
158
- --verbose)
159
- VERBOSE=1
160
- shift
161
- ;;
162
- *)
163
- SPECIFIC_TEST="$1"
164
- shift
165
- ;;
166
- esac
167
- done
168
-
169
- # Set up the command
170
- CMD="python -m pytest"
171
-
172
- if [ $VERBOSE -eq 1 ]; then
173
- CMD="$CMD -v"
174
- fi
175
-
176
- if [ $COVERAGE -eq 1 ]; then
177
- CMD="$CMD --cov=awslabs.terraform_mcp_server"
178
-
179
- if [ $REPORT -eq 1 ]; then
180
- CMD="$CMD --cov-report=html"
181
- fi
182
- fi
183
-
184
- if [ -n "$SPECIFIC_TEST" ]; then
185
- CMD="$CMD $SPECIFIC_TEST"
186
- else
187
- CMD="$CMD tests/"
188
- fi
189
-
190
- # Run the tests
191
- echo "Running: $CMD"
192
- $CMD
193
-
194
- # If coverage report was generated, print the path
195
- if [ $COVERAGE -eq 1 ] && [ $REPORT -eq 1 ]; then
196
- echo "Coverage report generated in htmlcov/ directory"
197
- echo "Open htmlcov/index.html in your browser to view the report"
198
- fi