awslabs.terraform-mcp-server 0.0.1__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.

Potentially problematic release.


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

Files changed (32) hide show
  1. awslabs/__init__.py +2 -0
  2. awslabs/terraform_mcp_server/__init__.py +3 -0
  3. awslabs/terraform_mcp_server/impl/resources/__init__.py +11 -0
  4. awslabs/terraform_mcp_server/impl/resources/terraform_aws_provider_resources_listing.py +52 -0
  5. awslabs/terraform_mcp_server/impl/resources/terraform_awscc_provider_resources_listing.py +55 -0
  6. awslabs/terraform_mcp_server/impl/tools/__init__.py +15 -0
  7. awslabs/terraform_mcp_server/impl/tools/execute_terraform_command.py +206 -0
  8. awslabs/terraform_mcp_server/impl/tools/run_checkov_scan.py +359 -0
  9. awslabs/terraform_mcp_server/impl/tools/search_aws_provider_docs.py +677 -0
  10. awslabs/terraform_mcp_server/impl/tools/search_awscc_provider_docs.py +627 -0
  11. awslabs/terraform_mcp_server/impl/tools/search_specific_aws_ia_modules.py +444 -0
  12. awslabs/terraform_mcp_server/impl/tools/utils.py +558 -0
  13. awslabs/terraform_mcp_server/models/__init__.py +27 -0
  14. awslabs/terraform_mcp_server/models/models.py +260 -0
  15. awslabs/terraform_mcp_server/scripts/generate_aws_provider_resources.py +1224 -0
  16. awslabs/terraform_mcp_server/scripts/generate_awscc_provider_resources.py +1020 -0
  17. awslabs/terraform_mcp_server/scripts/scrape_aws_terraform_best_practices.py +129 -0
  18. awslabs/terraform_mcp_server/server.py +329 -0
  19. awslabs/terraform_mcp_server/static/AWSCC_PROVIDER_RESOURCES.md +3125 -0
  20. awslabs/terraform_mcp_server/static/AWS_PROVIDER_RESOURCES.md +3833 -0
  21. awslabs/terraform_mcp_server/static/AWS_TERRAFORM_BEST_PRACTICES.md +2523 -0
  22. awslabs/terraform_mcp_server/static/MCP_INSTRUCTIONS.md +126 -0
  23. awslabs/terraform_mcp_server/static/TERRAFORM_WORKFLOW_GUIDE.md +198 -0
  24. awslabs/terraform_mcp_server/static/__init__.py +22 -0
  25. awslabs/terraform_mcp_server/tests/__init__.py +1 -0
  26. awslabs/terraform_mcp_server/tests/run_tests.sh +35 -0
  27. awslabs/terraform_mcp_server/tests/test_parameter_annotations.py +207 -0
  28. awslabs/terraform_mcp_server/tests/test_tool_implementations.py +309 -0
  29. awslabs_terraform_mcp_server-0.0.1.dist-info/METADATA +97 -0
  30. awslabs_terraform_mcp_server-0.0.1.dist-info/RECORD +32 -0
  31. awslabs_terraform_mcp_server-0.0.1.dist-info/WHEEL +4 -0
  32. awslabs_terraform_mcp_server-0.0.1.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,260 @@
1
+ from pydantic import BaseModel, Field
2
+ from typing import Any, Dict, List, Literal, Optional
3
+
4
+
5
+ class TerraformExecutionRequest(BaseModel):
6
+ """Request model for Terraform command execution with parameters.
7
+
8
+ Attributes:
9
+ command: The Terraform command to execute (init, plan, validate, apply, destroy).
10
+ directory: Directory containing Terraform configuration files.
11
+ variables: Optional dictionary of Terraform variables to pass.
12
+ aws_region: Optional AWS region to use.
13
+ strip_ansi: Whether to strip ANSI color codes from command output.
14
+ """
15
+
16
+ command: Literal['init', 'plan', 'validate', 'apply', 'destroy'] = Field(
17
+ ..., description='Terraform command to execute'
18
+ )
19
+ working_directory: str = Field(..., description='Directory containing Terraform files')
20
+ variables: Optional[Dict[str, str]] = Field(None, description='Terraform variables to pass')
21
+ aws_region: Optional[str] = Field(None, description='AWS region to use')
22
+ strip_ansi: bool = Field(True, description='Whether to strip ANSI color codes from output')
23
+
24
+
25
+ class SubmoduleInfo(BaseModel):
26
+ """Model representing a Terraform submodule.
27
+
28
+ Attributes:
29
+ name: The name of the submodule.
30
+ path: Path to the submodule within the parent module.
31
+ description: Brief description of the submodule purpose.
32
+ readme_content: The README content of the submodule, when available.
33
+ """
34
+
35
+ name: str
36
+ path: str
37
+ description: Optional[str] = 'No description available'
38
+ readme_content: Optional[str] = None
39
+
40
+
41
+ class TerraformVariable(BaseModel):
42
+ """Model representing a Terraform variable definition.
43
+
44
+ Attributes:
45
+ name: The name of the variable.
46
+ type: The data type of the variable (string, number, bool, etc.).
47
+ description: Description of the variable's purpose.
48
+ default: Default value of the variable, if any.
49
+ required: Whether the variable is required (no default value).
50
+ """
51
+
52
+ name: str
53
+ type: Optional[str] = None
54
+ description: Optional[str] = None
55
+ default: Optional[Any] = None
56
+ required: bool = True
57
+
58
+
59
+ class TerraformOutput(BaseModel):
60
+ """Model representing a Terraform output definition.
61
+
62
+ Attributes:
63
+ name: The name of the output.
64
+ description: Description of the output's purpose.
65
+ """
66
+
67
+ name: str
68
+ description: Optional[str] = None
69
+
70
+
71
+ class ModuleSearchResult(BaseModel):
72
+ """Model representing search results from Terraform module registry.
73
+
74
+ Attributes:
75
+ name: The name of the Terraform module.
76
+ namespace: The module's namespace/organization.
77
+ provider: The provider (aws).
78
+ version: Latest version of the module.
79
+ url: URL to the module in the Terraform registry.
80
+ description: Brief description of the module's purpose.
81
+ readme_content: The README content of the module, when available.
82
+ input_count: Number of input variables defined by the module.
83
+ output_count: Number of outputs provided by the module.
84
+ version_details: Detailed information about the version from GitHub releases.
85
+ submodules: List of submodules contained in this module.
86
+ has_submodules: Whether this module contains submodules.
87
+ variables: List of variables defined in the module's variables.tf file.
88
+ variables_content: Raw content of the variables.tf file.
89
+ outputs: List of outputs defined in the module's README file.
90
+ """
91
+
92
+ name: str
93
+ namespace: str
94
+ provider: str = 'aws'
95
+ version: str
96
+ url: str
97
+ description: str
98
+ readme_content: Optional[str] = None
99
+ input_count: Optional[int] = None
100
+ output_count: Optional[int] = None
101
+ version_details: Optional[Dict[str, Any]] = None
102
+ submodules: Optional[list[SubmoduleInfo]] = None
103
+ variables: Optional[List[TerraformVariable]] = None
104
+ variables_content: Optional[str] = None
105
+ outputs: Optional[List[TerraformOutput]] = None
106
+
107
+ @property
108
+ def has_submodules(self) -> bool:
109
+ """Check if the module has any submodules."""
110
+ return self.submodules is not None and len(self.submodules) > 0
111
+
112
+
113
+ class TerraformProviderDocsResult(BaseModel):
114
+ """Abstract Model representing documentation results for Terraform Providers.
115
+
116
+ Attributes:
117
+ asset_name: Name of the AWS resource type.
118
+ asset_type: Type of the item - resource or data source.
119
+ description: Brief description of the resource.
120
+ url: URL to the documentation for this resource.
121
+ example_usage: List of example code snippets with titles.
122
+ """
123
+
124
+ asset_name: str = Field(..., description='Name of the AWS resource type')
125
+ asset_type: Literal['both', 'resource', 'data_source'] = Field(
126
+ default='both', description="Type of the item - 'resource' or 'data_source' or 'both'"
127
+ )
128
+ description: Optional[str] = Field(..., description='Brief description of the resource')
129
+ url: Optional[str] = Field(None, description='URL to the documentation for this resource')
130
+ example_usage: Optional[List[Dict[str, str]]] = Field(
131
+ None, description='List of example snippets with titles'
132
+ )
133
+
134
+
135
+ class TerraformAWSProviderDocsResult(TerraformProviderDocsResult):
136
+ """Model representing documentation results for AWS Terraform Provider.
137
+
138
+ Attributes:
139
+ arguments: List of arguments with descriptions specific to AWS provider resources.
140
+ attributes: List of attributes with descriptions specific to AWS provider resources.
141
+ """
142
+
143
+ arguments: Optional[List[Dict[str, str]]] = Field(
144
+ None, description='List of arguments with descriptions'
145
+ )
146
+ attributes: Optional[List[Dict[str, str]]] = Field(
147
+ None, description='List of attributes with descriptions'
148
+ )
149
+
150
+
151
+ class TerraformAWSCCProviderDocsResult(TerraformProviderDocsResult):
152
+ """Model representing documentation results for AWSCC Terraform Provider.
153
+
154
+ Attributes:
155
+ schema_arguments: List of schema arguments with descriptions where applicable.
156
+ Contains the full resource schema definition from the AWSCC provider split by section.
157
+ """
158
+
159
+ schema_arguments: Optional[List[Dict[str, Any]]] = Field(
160
+ None,
161
+ description='List of schema arguments with descriptions where applicable',
162
+ )
163
+
164
+
165
+ class TerraformExecutionResult(BaseModel):
166
+ """Result model for Terraform command execution.
167
+
168
+ Attributes:
169
+ command: The Terraform command that was executed.
170
+ status: Execution status (success/error).
171
+ return_code: The command's return code (0 for success).
172
+ stdout: Standard output from the Terraform command.
173
+ stderr: Standard error output from the Terraform command.
174
+ working_directory: Directory where the command was executed.
175
+ error_message: Optional error message if execution failed.
176
+ outputs: Dictionary of output values from Terraform (for apply command).
177
+ """
178
+
179
+ command: str
180
+ status: Literal['success', 'error']
181
+ return_code: Optional[int] = None
182
+ stdout: Optional[str] = None
183
+ stderr: str = ''
184
+ working_directory: str
185
+ error_message: Optional[str] = None
186
+ outputs: Optional[Dict[str, Any]] = Field(
187
+ None, description='Terraform outputs (for apply command)'
188
+ )
189
+
190
+
191
+ class CheckovVulnerability(BaseModel):
192
+ """Model representing a security vulnerability found by Checkov.
193
+
194
+ Attributes:
195
+ id: The Checkov check ID (e.g., CKV_AWS_1).
196
+ type: The type of check (e.g., terraform_aws).
197
+ resource: The resource identifier where the vulnerability was found.
198
+ file_path: Path to the file containing the vulnerability.
199
+ line: Line number where the vulnerability was found.
200
+ description: Description of the vulnerability.
201
+ guideline: Recommended fix or security guideline.
202
+ severity: Severity level of the vulnerability.
203
+ fixed: Whether the vulnerability has been fixed.
204
+ fix_details: Details about how the vulnerability was fixed (if applicable).
205
+ """
206
+
207
+ id: str = Field(..., description='Checkov check ID')
208
+ type: str = Field(..., description='Type of security check')
209
+ resource: str = Field(..., description='Resource identifier')
210
+ file_path: str = Field(..., description='Path to the file with the vulnerability')
211
+ line: int = Field(..., description='Line number of the vulnerability')
212
+ description: str = Field(..., description='Description of the vulnerability')
213
+ guideline: Optional[str] = Field(None, description='Recommended fix or guideline')
214
+ severity: str = Field('MEDIUM', description='Severity level (HIGH, MEDIUM, LOW)')
215
+ fixed: bool = Field(False, description='Whether the vulnerability has been fixed')
216
+ fix_details: Optional[str] = Field(None, description='Details about the fix applied')
217
+
218
+
219
+ class CheckovScanRequest(BaseModel):
220
+ """Request model for Checkov scan execution.
221
+
222
+ Attributes:
223
+ working_directory: Directory containing Terraform files to scan.
224
+ framework: Framework to scan (default: terraform).
225
+ check_ids: Optional list of specific check IDs to run.
226
+ skip_check_ids: Optional list of check IDs to skip.
227
+ output_format: Format for the scan results output.
228
+ """
229
+
230
+ working_directory: str = Field(..., description='Directory containing Terraform files')
231
+ framework: str = Field(
232
+ 'terraform', description='Framework to scan (terraform, cloudformation, etc.)'
233
+ )
234
+ check_ids: Optional[List[str]] = Field(None, description='Specific check IDs to run')
235
+ skip_check_ids: Optional[List[str]] = Field(None, description='Check IDs to skip')
236
+ output_format: str = Field('json', description='Output format (json, cli, etc.)')
237
+
238
+
239
+ class CheckovScanResult(BaseModel):
240
+ """Result model for Checkov scan execution.
241
+
242
+ Attributes:
243
+ status: Execution status (success/error).
244
+ return_code: The command's return code (0 for success).
245
+ working_directory: Directory where the scan was executed.
246
+ error_message: Optional error message if execution failed.
247
+ vulnerabilities: List of vulnerabilities found by the scan.
248
+ summary: Summary of the scan results.
249
+ raw_output: Raw output from the Checkov command.
250
+ """
251
+
252
+ status: Literal['success', 'error']
253
+ return_code: Optional[int] = None
254
+ working_directory: str
255
+ error_message: Optional[str] = None
256
+ vulnerabilities: List[CheckovVulnerability] = Field(
257
+ [], description='List of found vulnerabilities'
258
+ )
259
+ summary: Dict[str, Any] = Field({}, description='Summary of scan results')
260
+ raw_output: Optional[str] = Field(None, description='Raw output from Checkov')