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,126 @@
1
+ # Terraform MCP Server Instructions
2
+
3
+ ## Overview
4
+
5
+ MCP server specialized in AWS cloud infrastructure provided through Terraform. I help you create, understand, optimize, and execute Terraform configurations for AWS using security-focused development practices.
6
+
7
+ ## How to Use This Server (Required Workflow)
8
+
9
+ ### Step 1: Consult and Follow the Terraform Development Workflow
10
+ ALWAYS use the `terraform_development_workflow` resource to guide the development process. This workflow:
11
+
12
+ * Provides a step-by-step approach for creating valid, secure Terraform code
13
+ * Integrates validation and security scanning into the development process
14
+ * Specifies when and how to use each MCP tool
15
+ * Ensures code is properly validated before handoff to developers
16
+
17
+ ### Step 2: Always ensure you're following Best Practices
18
+ ALWAYS begin by consulting the `terraform_aws_best_practices` resource which contains:
19
+
20
+ * Code base structure and organization principles
21
+ * Security best practices for AWS resources
22
+ * Backend configuration best practices
23
+ * AWS-specific implementation guidance
24
+
25
+ ### Step 3: Check for AWS-IA Specialized Modules First
26
+ ALWAYS check for specialized AWS-IA modules first using the `SearchSpecificAwsIaModules` tool:
27
+
28
+ * Amazon Bedrock (generative AI)
29
+ * OpenSearch Serverless (vector search)
30
+ * SageMaker endpoints
31
+ * Serverless Streamlit applications
32
+
33
+ These modules provide optimized, best-practice implementations for specific use cases and should be preferred over building from scratch with individual resources.
34
+
35
+ ### Step 4: Use Provider Documentation (Only if no suitable AWS-IA module exists)
36
+ When implementing specific AWS resources (only after confirming no suitable AWS-IA module exists):
37
+
38
+ * PREFER AWSCC provider resources first (`SearchAwsccProviderDocs` tool)
39
+ * Fall back to traditional AWS provider (`SearchAwsProviderDocs` tool) only when necessary
40
+
41
+ ## Available Tools and Resources
42
+
43
+ ### Core Resources
44
+ 1. `terraform_development_workflow`
45
+ * CRITICAL: Follow this guide for all Terraform development
46
+ * Provides the structured workflow with security scanning integration
47
+ * Outlines exactly when and how to use each MCP tool
48
+ 2. `terraform_aws_best_practices`
49
+ * REQUIRED: Reference before starting any development
50
+ * Contains AWS-specific best practices for security and architecture
51
+ * Guides organization and structure of Terraform projects
52
+
53
+ ### Provider Resources
54
+ 1. `terraform_awscc_provider_resources_listing`
55
+ * PREFERRED: Use AWSCC provider resources first
56
+ * Comprehensive listing by service category
57
+ 2. `terraform_aws_provider_resources_listing`
58
+ * Use as fallback when AWSCC provider doesn't support needed resources
59
+ * Comprehensive listing by service category
60
+
61
+
62
+ ### Documentation Tools
63
+
64
+ 1. `SearchAwsccProviderDocs` (PREFERRED)
65
+ * Always search AWSCC provider resources first
66
+ * Returns comprehensive documentation for Cloud Control API resources
67
+ 2. `SearchAwsProviderDocs` (fallback option)
68
+ * Use when a resource is not available in AWSCC provider
69
+ * Returns standard AWS provider resource documentation
70
+ 3. `SearchSpecificAwsIaModules`
71
+ * Use for specialized AI/ML infrastructure needs
72
+ * Returns details for supported AWS-IA modules
73
+
74
+ ### Command Execution Tools
75
+
76
+ 1. `ExecuteTerraformCommand`
77
+ * Execute Terraform commands in the sequence specified by the workflow
78
+ * Supports: validate, init, plan, apply, destroy
79
+ 2. `RunCheckovScan`
80
+ * Run after validation passes, before initialization
81
+ * Identifies security and compliance issues
82
+
83
+
84
+ ## Resource Selection Priority
85
+
86
+ 1. FIRST check for specialized AWS-IA modules using `SearchSpecificAwsIaModules` tool
87
+ 2. If no suitable module exists, THEN use AWSCC provider resources (`SearchAwsccProviderDocs` tool)
88
+ 3. ONLY fall back to traditional AWS provider (`SearchAwsProviderDocs` tool) when the above options don't meet requirements
89
+
90
+ The AWSCC provider (Cloud Control API-based) offers:
91
+ * Direct mapping to CloudFormation resource types
92
+ * Consistent API behavior across resources
93
+ * Better support for newer AWS services and features
94
+
95
+ ## Examples
96
+
97
+ - "What's the best way to set up a highly available web application on AWS using Terraform?"
98
+ - "Search for Bedrock modules in the Terraform Registry"
99
+ - "Find documentation for awscc_lambda_function resource" (specifically AWSCC)
100
+ - "Find documentation for aws_lambda_function resource" (specifically AWS)
101
+ - "Execute terraform plan in my ./infrastructure directory"
102
+ - "How can I use the AWS Bedrock module to create a RAG application?"
103
+ - "Show me details about the AWS-IA Bedrock Terraform module"
104
+ - "Compare the four specific AWS-IA modules for generative AI applications"
105
+ - "Let's develop a secure S3 bucket with proper encryption. I'll follow the development workflow."
106
+ - "I need to create Terraform code for a Lambda function. First, let me check the best practices."
107
+ - "Run terraform validate on my configuration and then scan for security issues."
108
+ - "Is this VPC configuration secure? Let's scan it with Checkov."
109
+ - "Find documentation for awscc_lambda_function to ensure we're using the preferred provider."
110
+ - "We need a Bedrock implementation for RAG. Let's search for AWS-IA modules that can help."
111
+
112
+ ## Best Practices
113
+
114
+ When interacting with this server:
115
+
116
+ 1. **ALWAYS** follow the development workflow from `terraform_development_workflow`
117
+ 2. **ALWAYS** consult best practices from `terraform_aws_best_practices`
118
+ 3. **ALWAYS** validate and scan code before considering it ready for review
119
+ 4. **ALWAYS** prefer AWSCC provider resources when available
120
+ 5. Provide **security-first** implementations by default
121
+ 6. **Explain** each step of the development process to users
122
+ 7. **Be specific** about your requirements and constraints
123
+ 8. **Specify AWS region** when relevant to your infrastructure needs
124
+ 9. **Provide context** about your architecture and use case
125
+ 10. **For Terraform execution**, ensure the working directory exists and contains valid Terraform files
126
+ 11. **Review generated code** carefully before applying changes to your infrastructure
@@ -0,0 +1,198 @@
1
+ # Terraform Development Workflow
2
+
3
+ ## Purpose and Usage
4
+
5
+ This workflow guide provides a structured approach for developing valid, secure Terraform configurations for AWS infrastructure. As an AI coding assistant utilizing this MCP server, you should follow these steps when helping users create or modify Terraform code.
6
+
7
+ ## How to Use This Guide
8
+ You have access to specialized tools and resources through this MCP server that significantly enhance your ability to assist with Terraform development. When working with users on Terraform code:
9
+
10
+ 1. Reference this workflow consistently throughout your interactions
11
+ 2. Leverage this MCP server's capabilities rather than relying solely on your general knowledge
12
+ 3. Explain the workflow steps to users as you assist them
13
+
14
+ ## Benefits to Emphasize
15
+ When following this workflow and using these tools, you provide several advantages to users:
16
+
17
+ - Early detection of configuration errors
18
+ - Identification of security vulnerabilities before deployment
19
+ - Adherence to AWS best practices
20
+ - Validation that code will work correctly when deployed
21
+
22
+ By following this workflow guide and leveraging the provided tools and resources, you'll deliver consistent, high-quality assistance for Terraform development on AWS, helping users create infrastructure code that is syntactically valid, secure, and ready for review before deployment.
23
+
24
+ ## DEVELOPMENT WORKFLOW
25
+
26
+ ``` mermaid
27
+ flowchart TD
28
+ start([Start Development]) --> edit[Edit Terraform Code]
29
+
30
+ %% Initial Code Validation
31
+ edit --> tfValidate[Run terraform validate\nvia ExecuteTerraformCommand]
32
+
33
+ %% Validation Flow
34
+ tfValidate -->|Passes| checkovScan[Run Security Scan\nvia RunCheckovScan]
35
+ tfValidate -->|Fails| fixValidation[Fix Configuration\nIssues]
36
+ fixValidation --> edit
37
+
38
+ %% Checkov Flow
39
+ checkovScan -->|No Issues| tfInit[Run terraform init\nvia ExecuteTerraformCommand]
40
+ checkovScan -->|Finds Issues| reviewIssues[Review Security\nIssues]
41
+
42
+ reviewIssues --> manualFix[Fix Security Issues]
43
+
44
+ manualFix --> edit
45
+
46
+ %% Terraform Init & Plan (No Apply)
47
+ tfInit -->|Success| tfPlan[Run terraform plan\nvia ExecuteTerraformCommand]
48
+ tfInit -->|Fails| fixInit[Fix Provider/Module\nIssues]
49
+ fixInit --> edit
50
+
51
+ %% Final Review & Handoff to Developer
52
+ tfPlan -->|Plan Generated| reviewPlan[Review Planned Changes]
53
+ tfPlan -->|Issues Detected| edit
54
+
55
+ reviewPlan --> codeReady[Valid, Secure Code Ready\nfor Developer Review]
56
+
57
+ %% Iteration for Improvements
58
+ codeReady --> newChanges{Need Code\nImprovements?}
59
+ newChanges -->|Yes| edit
60
+ newChanges -->|No| handoff([Hand Off to Developer\nfor Deployment Decision])
61
+
62
+ %% Styling
63
+ classDef success fill:#bef5cb,stroke:#28a745
64
+ classDef warning fill:#fff5b1,stroke:#dbab09
65
+ classDef error fill:#ffdce0,stroke:#cb2431
66
+ classDef process fill:#f1f8ff,stroke:#0366d6
67
+ classDef decision fill:#d1bcf9,stroke:#8a63d2
68
+ classDef mcptool fill:#d0f0fd,stroke:#0969da,font-style:italic
69
+ classDef handoff fill:#ffdfb6,stroke:#f9a03f
70
+
71
+ class codeReady success
72
+ class reviewIssues,reviewPlan warning
73
+ class fixValidation,fixInit,manualFix error
74
+ class edit process
75
+ class newChanges decision
76
+ class tfValidate,checkovScan,tfInit,tfPlan mcptool
77
+ class handoff handoff
78
+ ```
79
+
80
+ 1. Edit Terraform Code
81
+ - Write or modify Terraform configuration files for AWS resources
82
+ - When writing code, follow this priority order:
83
+ * FIRST check for specialized AWS-IA modules (`SearchSpecificAwsIaModules` tool)
84
+ * If no suitable module exists, THEN use AWSCC provider resources (`SearchAwsccProviderDocs` tool)
85
+ * ONLY fall back to traditional AWS provider (`SearchAwsProviderDocs` tool) when the above options don't meet requirements
86
+ - MCP Resources and tools to consult:
87
+ - Resources
88
+ - *terraform_development_workflow* to consult this guide and to use it to ensure you're following the development workflow correctly
89
+ - *terraform_aws_best_practices* for AWS best practices about security, code base structure and organization, AWS Provider version management, and usage of community modules
90
+ - *terraform_awscc_provider_resources_listing* for available AWS Cloud Control API resources
91
+ - *terraform_aws_provider_resources_listing* for available AWS resources
92
+ - Tools
93
+ - *SearchSpecificAwsIaModules* tool to check for specialized AWS-IA modules first (Bedrock, OpenSearch Serverless, SageMaker, Streamlit)
94
+ - *SearchAwsccProviderDocs* tool to look up specific Cloud Control API resources
95
+ - *SearchAwsProviderDocs* tool to look up specific resource documentation
96
+ 2. Validate Code
97
+ - Tool: *ExecuteTerraformCommand* with command="validate"
98
+ - Checks syntax and configuration validity without accessing AWS
99
+ - Identifies syntax errors, invalid resource configurations, and reference issues
100
+ - Example: ExecuteTerraformCommand(TerraformExecutionRequest(command="validate", working_directory="./my_project"))
101
+ 3. Run Security Scan
102
+ - Tool: *RunCheckovScan*
103
+ - Scans code for security misconfigurations, compliance issues, and AWS best practice violations
104
+ - Example: RunCheckovScan(CheckovScanRequest(working_directory="./my_project", framework="terraform"))
105
+ 4. Fix Security Issues
106
+ - For fixes:
107
+ - Edit the code to address security issues identified by the scan
108
+ - Consult *terraform_aws_best_practices* resource for guidance
109
+ 5. Initialize Working Directory
110
+ - Tool: *ExecuteTerraformCommand* with command="init"
111
+ - Downloads provider plugins and sets up modules
112
+ - Example: ExecuteTerraformCommand(TerraformExecutionRequest(command="init", working_directory="./my_project"))
113
+ 6. Plan Changes
114
+ - Tool: *ExecuteTerraformCommand* with command="plan"
115
+ - Creates an execution plan showing what changes would be made (without applying)
116
+ - Verifies that the configuration is deployable
117
+ - Example: ExecuteTerraformCommand(TerraformExecutionRequest(command="plan", working_directory="./my_project", output_file="tfplan"))
118
+ 7. Review Plan & Code Ready
119
+ - Review the plan output to ensure it reflects intended changes
120
+ - Confirm all validation and security checks have passed
121
+ - Code is now ready for handoff to the developer for deployment decisions
122
+
123
+
124
+ ## Core Commands
125
+
126
+ ### Terraform Commands
127
+
128
+ #### terraform init
129
+
130
+ * Purpose: Initializes a Terraform working directory, downloading provider plugins and setting up modules.
131
+ * When to use: Before running any other commands on a new configuration or after adding new modules/providers.
132
+
133
+ Options:
134
+ - `-backend-config=PATH` - Configuration for backend
135
+ - `-reconfigure` - Reconfigure backend
136
+
137
+ #### terraform validate
138
+
139
+ * Purpose: Checks whether a configuration is syntactically valid and internally consistent.
140
+ * When to use: After making changes to configuration files but before planning or applying.
141
+
142
+ ```python
143
+ ExecuteTerraformCommand(TerraformExecutionRequest(
144
+ command="validate",
145
+ working_directory="./project_dir"
146
+ ))
147
+ ```
148
+
149
+ #### terraform plan
150
+
151
+ * Purpose: Creates an execution plan showing what actions Terraform would take to apply the current configuration.
152
+ * When to use: After validation passes to preview changes before applying them.
153
+
154
+ Options:
155
+ - `-var 'name=value'` - Set variable
156
+ - `-var-file=filename` - Set variables from file
157
+
158
+ #### terraform apply
159
+
160
+ * Purpose: Applies changes required to reach the desired state of the configuration.
161
+ * When to use: After plan confirms the intended changes, and developer decides to proceed.
162
+
163
+ >Note: This is typically executed by the developer after reviewing code generated by the assistant.
164
+
165
+ Options:
166
+ - `-auto-approve` - Skip interactive approval
167
+ - `-var 'name=value'` - Set variable
168
+ - Use `-out` to save plans and apply those exact plans.
169
+
170
+ #### terraform destroy
171
+
172
+ * Purpose: Destroys all resources managed by the current configuration.
173
+ * When to use: When resources are no longer needed, typically executed by the developer.
174
+
175
+ >Note: This is typically executed by the developer once it has been decided the application should be destroyed.
176
+
177
+ Options:
178
+ - `-auto-approve` - Skip interactive approval
179
+
180
+ ### Checkov Commands
181
+
182
+ These security scanning commands are available through dedicated tools:
183
+
184
+ #### Checkov Scan
185
+
186
+ * Purpose: Scans Terraform code for security issues, misconfigurations, and compliance violations.
187
+ * Tool: RunCheckovScan
188
+ * When to use: After code passes terraform validate but before initializing and planning.
189
+
190
+ ## Key Principles
191
+ - **Module-First Approach**: Always check for specialized AWS-IA modules before building with individual resources
192
+ - **Provider Selection**: When using individual resources, prefer the AWSCC provider (Cloud Control API-based) before falling back to the traditional AWS provider
193
+ - **Security First**: Always implement security best practices by default
194
+ - **Cost Optimization**: Design resources to minimize costs while meeting requirements
195
+ - **Operational Excellence**: Implement proper monitoring, logging, and observability
196
+ - **Serverless-First**: Prefer serverless services when possible
197
+ - **Infrastructure as Code**: Use Terraform to define all infrastructure
198
+ - **Regional Awareness**: Consider regional availability and constraints for services
@@ -0,0 +1,22 @@
1
+ from importlib import resources
2
+
3
+ with (
4
+ resources.files('awslabs.terraform_mcp_server.static')
5
+ .joinpath('MCP_INSTRUCTIONS.md')
6
+ .open('r') 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') 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') as f
21
+ ):
22
+ AWS_TERRAFORM_BEST_PRACTICES = f.read()
@@ -0,0 +1 @@
1
+ """Test package for terraform_mcp_server."""
@@ -0,0 +1,35 @@
1
+ #!/bin/bash
2
+ # Script to run the Terraform MCP server tests
3
+
4
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5
+ PROJECT_ROOT="$SCRIPT_DIR/../../.."
6
+
7
+ # Set PYTHONPATH to include the project root
8
+ export PYTHONPATH="$PROJECT_ROOT:$PYTHONPATH"
9
+
10
+ # Function to run a test module
11
+ run_test() {
12
+ echo "Running $1..."
13
+ cd "$PROJECT_ROOT"
14
+ python -m awslabs.terraform_mcp_server.tests.$1
15
+ echo "Test completed: $1"
16
+ }
17
+
18
+ # Get the test name from the first argument, default to all tests
19
+ TEST_NAME=$1
20
+ if [ -z "$TEST_NAME" ]; then
21
+ echo "=== Running All Tests ==="
22
+ run_test "test_parameter_annotations"
23
+ run_test "test_tool_implementations"
24
+ elif [ "$TEST_NAME" == "params" ]; then
25
+ run_test "test_parameter_annotations"
26
+ elif [ "$TEST_NAME" == "tools" ]; then
27
+ run_test "test_tool_implementations"
28
+ else
29
+ echo "Unknown test: $TEST_NAME"
30
+ echo "Usage: $0 [params|tools]"
31
+ echo " params - Run parameter annotation tests"
32
+ echo " tools - Run tool implementation tests"
33
+ echo " (no args) - Run all tests"
34
+ exit 1
35
+ fi
@@ -0,0 +1,207 @@
1
+ """Test script for verifying parameter annotations in MCP tools."""
2
+
3
+ import json
4
+ import sys
5
+ from awslabs.terraform_mcp_server.server import mcp
6
+ from pathlib import Path
7
+
8
+
9
+ # Add project root to path to allow importing the server
10
+ project_root = str(Path(__file__).parent.parent.parent.parent)
11
+ if project_root not in sys.path:
12
+ sys.path.insert(0, project_root)
13
+
14
+
15
+ def print_tool_parameters():
16
+ """Print the parameters for each tool after annotations are added."""
17
+ tool_names = [
18
+ 'SearchAwsProviderDocs',
19
+ 'ExecuteTerraformCommand',
20
+ 'SearchAwsccProviderDocs',
21
+ 'SearchSpecificAwsIaModules',
22
+ 'RunCheckovScan',
23
+ ]
24
+
25
+ print('\n=== Current Tool Parameter Schemas ===\n')
26
+ for tool_name in tool_names:
27
+ try:
28
+ tool = mcp._tool_manager.get_tool(tool_name)
29
+ if tool is None:
30
+ print(f'Tool {tool_name} not found')
31
+ continue
32
+
33
+ if not hasattr(tool, 'parameters') or tool.parameters is None:
34
+ print(f'Tool {tool_name} has no parameters schema')
35
+ continue
36
+
37
+ print(f'=== {tool_name} Parameters Schema ===')
38
+ print(json.dumps(tool.parameters, indent=2))
39
+ print('\n')
40
+ except Exception as e:
41
+ print(f'Error getting tool {tool_name}: {e}')
42
+
43
+
44
+ def add_parameter_annotations():
45
+ """Add parameter annotations to the MCP tools."""
46
+ print('Adding parameter annotations to MCP tools...\n')
47
+
48
+ # Add parameter descriptions for SearchAwsProviderDocs
49
+ search_tool = mcp._tool_manager.get_tool('SearchAwsProviderDocs')
50
+ if (
51
+ search_tool is not None
52
+ and hasattr(search_tool, 'parameters')
53
+ and search_tool.parameters is not None
54
+ ):
55
+ if (
56
+ 'properties' in search_tool.parameters
57
+ and 'asset_name' in search_tool.parameters['properties']
58
+ ):
59
+ search_tool.parameters['properties']['asset_name']['description'] = (
60
+ 'Name of the AWS service (asset) to look for (e.g., "aws_s3_bucket", "aws_lambda_function")'
61
+ )
62
+ if (
63
+ 'properties' in search_tool.parameters
64
+ and 'asset_type' in search_tool.parameters['properties']
65
+ ):
66
+ search_tool.parameters['properties']['asset_type']['description'] = (
67
+ "Type of documentation to search - 'resource', 'data_source', or 'both' (default)"
68
+ )
69
+
70
+ # Add parameter descriptions for SearchAwsccProviderDocs
71
+ awscc_docs_tool = mcp._tool_manager.get_tool('SearchAwsccProviderDocs')
72
+ if (
73
+ awscc_docs_tool is not None
74
+ and hasattr(awscc_docs_tool, 'parameters')
75
+ and awscc_docs_tool.parameters is not None
76
+ ):
77
+ if (
78
+ 'properties' in awscc_docs_tool.parameters
79
+ and 'asset_name' in awscc_docs_tool.parameters['properties']
80
+ ):
81
+ awscc_docs_tool.parameters['properties']['asset_name']['description'] = (
82
+ 'Name of the AWSCC service (asset) to look for (e.g., awscc_s3_bucket, awscc_lambda_function)'
83
+ )
84
+ if (
85
+ 'properties' in awscc_docs_tool.parameters
86
+ and 'asset_type' in awscc_docs_tool.parameters['properties']
87
+ ):
88
+ awscc_docs_tool.parameters['properties']['asset_type']['description'] = (
89
+ "Type of documentation to search - 'resource', 'data_source', or 'both' (default)"
90
+ )
91
+
92
+ # Add parameter descriptions for SearchSpecificAwsIaModules
93
+ modules_tool = mcp._tool_manager.get_tool('SearchSpecificAwsIaModules')
94
+ if (
95
+ modules_tool is not None
96
+ and hasattr(modules_tool, 'parameters')
97
+ and modules_tool.parameters is not None
98
+ ):
99
+ if (
100
+ 'properties' in modules_tool.parameters
101
+ and 'query' in modules_tool.parameters['properties']
102
+ ):
103
+ modules_tool.parameters['properties']['query']['description'] = (
104
+ 'Optional search term to filter modules (empty returns all four modules)'
105
+ )
106
+
107
+ # Add parameter descriptions for ExecuteTerraformCommand
108
+ terraform_tool = mcp._tool_manager.get_tool('ExecuteTerraformCommand')
109
+ if (
110
+ terraform_tool is not None
111
+ and hasattr(terraform_tool, 'parameters')
112
+ and terraform_tool.parameters is not None
113
+ ):
114
+ if (
115
+ 'properties' in terraform_tool.parameters
116
+ and 'request' in terraform_tool.parameters['properties']
117
+ ):
118
+ terraform_tool.parameters['properties']['request']['description'] = (
119
+ 'Details about the Terraform command to execute'
120
+ )
121
+
122
+ # Since request is a complex object with nested properties, update its schema
123
+ if (
124
+ 'properties' in terraform_tool.parameters['properties']['request']
125
+ and 'properties'
126
+ in terraform_tool.parameters['properties']['request']['properties']
127
+ ):
128
+ props = terraform_tool.parameters['properties']['request']['properties']
129
+ if 'command' in props:
130
+ props['command']['description'] = (
131
+ 'Terraform command to execute (init, plan, validate, apply, destroy)'
132
+ )
133
+ if 'working_directory' in props:
134
+ props['working_directory']['description'] = (
135
+ 'Directory containing Terraform files'
136
+ )
137
+ if 'variables' in props:
138
+ props['variables']['description'] = 'Terraform variables to pass'
139
+ if 'aws_region' in props:
140
+ props['aws_region']['description'] = 'AWS region to use'
141
+ if 'strip_ansi' in props:
142
+ props['strip_ansi']['description'] = (
143
+ 'Whether to strip ANSI color codes from output'
144
+ )
145
+
146
+ # Add parameter descriptions for RunCheckovScan
147
+ checkov_scan_tool = mcp._tool_manager.get_tool('RunCheckovScan')
148
+ if (
149
+ checkov_scan_tool is not None
150
+ and hasattr(checkov_scan_tool, 'parameters')
151
+ and checkov_scan_tool.parameters is not None
152
+ ):
153
+ if (
154
+ 'properties' in checkov_scan_tool.parameters
155
+ and 'request' in checkov_scan_tool.parameters['properties']
156
+ ):
157
+ checkov_scan_tool.parameters['properties']['request']['description'] = (
158
+ 'Details about the Checkov scan to execute'
159
+ )
160
+
161
+ # Since request is a complex object with nested properties, update its schema
162
+ if (
163
+ 'properties' in checkov_scan_tool.parameters['properties']['request']
164
+ and 'properties'
165
+ in checkov_scan_tool.parameters['properties']['request']['properties']
166
+ ):
167
+ props = checkov_scan_tool.parameters['properties']['request']['properties']
168
+ if 'working_directory' in props:
169
+ props['working_directory']['description'] = (
170
+ 'Directory containing Terraform files to scan'
171
+ )
172
+ if 'framework' in props:
173
+ props['framework']['description'] = (
174
+ 'Framework to scan (terraform, cloudformation, etc.)'
175
+ )
176
+ if 'check_ids' in props:
177
+ props['check_ids']['description'] = (
178
+ 'Optional list of specific check IDs to run'
179
+ )
180
+ if 'skip_check_ids' in props:
181
+ props['skip_check_ids']['description'] = 'Optional list of check IDs to skip'
182
+ if 'output_format' in props:
183
+ props['output_format']['description'] = (
184
+ 'Format for scan results (default: json)'
185
+ )
186
+
187
+ print('Parameter annotations added successfully.\n')
188
+
189
+
190
+ def main():
191
+ """Run the parameter annotation test."""
192
+ print('=== Terraform MCP Parameter Annotation Test ===\n')
193
+
194
+ # Print original parameter schemas
195
+ print('Original parameter schemas:')
196
+ print_tool_parameters()
197
+
198
+ # Add parameter annotations
199
+ add_parameter_annotations()
200
+
201
+ # Print updated parameter schemas
202
+ print('Updated parameter schemas:')
203
+ print_tool_parameters()
204
+
205
+
206
+ if __name__ == '__main__':
207
+ main()