The Terraform MCP Server is a Model Context Protocol (MCP)
server that provides seamless integration with Terraform Registry APIs, enabling advanced
automation and interaction capabilities for Infrastructure as Code (IaC) development.
This fork extends the base server with Partner-Managed Resources - enabling AI-assisted security remediation through AWS Security Hub integration and HCP Terraform.
Terraform MCP Server with partner managed resources for AI-assisted remediation
Security Finding Discovery: Pull findings from AWS Security Hub automatically
Automatic ARN → Terraform Mapping: Discovers workspaces, parses state, and auto-links ARNs to Terraform addresses
Automated Remediation: Generate and apply Terraform fixes through HCP Terraform
CLI-Driven Workflow: Works with CLI-driven workspaces (configuration uploaded via API)
How Automatic Resource Mapping Works
When you provide your HCP Terraform org, the system automatically discovers and links resources:
sync_recommendations(terraform_org: "my-org")
│
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ 1. DISCOVER WORKSPACES │
│ Lists all workspaces in your org (via HCP Terraform API) │
└─────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ 2. INDEX TERRAFORM STATE │
│ For each workspace, parses state and extracts cloud resource IDs: │
│ - ARNs from aws_security_group, aws_instance, aws_s3_bucket, etc. │
│ - Builds index: ARN → Terraform address │
│ Example: "arn:aws:ec2:...:sg-xxx" → "aws_security_group.web" │
└─────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ 3. SYNC & AUTO-LINK │
│ Fetches findings from Security Hub, matches ARNs to Terraform │
│ Result: Each finding knows its Terraform resource automatically! │
└─────────────────────────────────────────────────────────────────────────┘
No manual linking required! Just provide terraform_org and the system handles the mapping.
Supported Resource Mappings
The auto-discovery system supports the following AWS-to-Terraform resource mappings:
AWS Security Hub Type
Terraform Resource Type
AwsEc2Instance
aws_instance
AwsEc2SecurityGroup
aws_security_group
AwsEc2Volume
aws_ebs_volume
AwsEc2Vpc
aws_vpc
AwsEc2Subnet
aws_subnet
AwsEc2NetworkInterface
aws_network_interface
AwsS3Bucket
aws_s3_bucket
AwsIamUser
aws_iam_user
AwsIamRole
aws_iam_role
AwsIamPolicy
aws_iam_policy
AwsIamAccessKey
aws_iam_access_key
AwsLambdaFunction
aws_lambda_function
AwsRdsDbInstance
aws_db_instance
AwsRdsDbCluster
aws_rds_cluster
AwsKmsKey
aws_kms_key
AwsSecretsManagerSecret
aws_secretsmanager_secret
AwsSqsQueue
aws_sqs_queue
AwsSnsTopic
aws_sns_topic
AwsSnsSubscription
aws_sns_topic_subscription
AwsCloudFrontDistribution
aws_cloudfront_distribution
AwsElbLoadBalancer
aws_elb
AwsElbv2LoadBalancer
aws_lb
AwsApiGatewayRestApi
aws_api_gateway_rest_api
AwsDynamoDbTable
aws_dynamodb_table
AwsElasticsearchDomain
aws_elasticsearch_domain
AwsEksCluster
aws_eks_cluster
AwsEcsCluster
aws_ecs_cluster
AwsEcsService
aws_ecs_service
How Resources Are Matched: The system extracts cloud resource IDs from Terraform state and matches them to Security Hub findings using ARNs. For each resource type, these attributes are checked (in order):
Terraform Resource
ID Attributes (priority order)
aws_instance
arn, id
aws_s3_bucket
arn, bucket, id
aws_security_group
arn, id
aws_lambda_function
arn, function_name
aws_db_instance
arn, id, identifier
aws_iam_role
arn, id, name
aws_iam_user
arn, id, name
aws_kms_key
arn, key_id, id
aws_lb / aws_alb
arn, id
aws_autoscaling_group
arn, id, name
(others)
arn, id
CLI-Driven vs VCS-Driven Workspaces
This extension is designed for CLI-driven workspaces where:
Terraform configuration is uploaded directly via the HCP Terraform API
Runs are triggered programmatically (not through Git commits)
The AI assistant manages the configuration lifecycle
Dual Transport Support: Both Stdio and StreamableHTTP transports with configurable endpoints
Terraform Registry Integration: Direct integration with public Terraform Registry APIs for providers, modules, and policies
HCP Terraform & Terraform Enterprise Support: Full workspace management, organization/project listing, and private registry access
Workspace Operations: Create, update, delete workspaces with support for variables, tags, and run management
Partner-Managed Resources: Security recommendation sync, analysis, and automated remediation
Security Note: At this stage, the MCP server is intended for local use only. If using the StreamableHTTP transport, always configure the MCP_ALLOWED_ORIGINS environment variable to restrict access to trusted origins only.
Security Note: Depending on the query, the MCP server may expose certain Terraform data to the MCP client and LLM. Do not use the MCP server with untrusted MCP clients or LLMs.
Caution: The outputs and recommendations provided by the MCP server are generated dynamically and may vary based on the query, model, and the connected MCP client. Users should thoroughly review all outputs/recommendations before implementation.
Quick Start (Partner-Managed Resources)
1. Build the Server
git clone <repository>
cd cc-partner-managed-resources
go build -o terraform-mcp-server ./cmd/terraform-mcp-server
User: "Configure AWS Security Hub for us-west-2"
User: "Sync security recommendations"
User: "Show me HIGH severity findings"
User: "Remediate the SSH security group finding"
Available Toolsets
Toolset
Description
Use Case
registry
Public Terraform Registry
Search providers, modules, documentation
registry-private
Private registry access
Private modules and providers
terraform
HCP Terraform operations
Workspace management, runs, state
partner
Partner-managed resources
Security recommendations, remediation
all
All toolsets combined
Full functionality
default
registry + terraform
Standard usage
Partner Toolset - Tools Reference
Configuration Tools
Tool
Description
configure_aws_security_hub
Set up AWS Security Hub as recommendation source
configure_aws_recommendations
Set up AWS Compute Optimizer (cost optimization)
list_recommendation_sources
List all configured sources
Discovery Tools
Tool
Description
sync_recommendations
Pull latest findings from configured sources
list_recommendations
Query with filters (severity, category, status)
get_recommendation
Get full details of a specific finding
Remediation Tools
Tool
Description
link_recommendation_resource
Map finding to Terraform resource address
remediate_recommendation
Generate fix and apply through HCP Terraform
preview_remediation
Preview changes without applying
apply_remediation
Apply previously previewed changes
Resource Management Tools
Tool
Description
register_resources
Register Terraform resources with partner registry
resolve_resources
Resolve ARNs to Terraform addresses
get_resource_state
Get current Terraform state for a resource
get_drift_status
Check for infrastructure drift
Tool Workflow Sequence
The partner tools follow a specific workflow sequence:
sync_recommendations with terraform_org auto-discovers and links resources
Manual linking via link_recommendation_resource is only needed if auto-discovery fails (e.g., unrecognized ARN format)
Use preview_remediation to review changes before applying
Environment Variables
Core Variables
Variable
Description
Default
TFE_ADDRESS
HCP Terraform or TFE address
https://app.terraform.io
TFE_TOKEN
Terraform Enterprise API token
(required)
TFE_SKIP_TLS_VERIFY
Skip TLS verification
false
ENABLE_TF_OPERATIONS
Enable Terraform operations
false
Partner Variables
Variable
Description
Default
AWS_ACCESS_KEY_ID
AWS access key
(required for partner)
AWS_SECRET_ACCESS_KEY
AWS secret key
(required for partner)
AWS_REGION
AWS region
us-west-2
GITHUB_TOKEN
GitHub token (for VCS workflow)
(optional)
Transport Variables
Variable
Description
Default
TRANSPORT_MODE
stdio or streamable-http
stdio
TRANSPORT_HOST
HTTP server host
127.0.0.1
TRANSPORT_PORT
HTTP server port
8080
MCP_ENDPOINT
HTTP endpoint path
/mcp
Testing
E2E Test Suite
A comprehensive E2E test environment is available in test-e2e-remediation/:
cd test-e2e-remediation/scripts
# Configure credentials
cp env.sh.template env.sh
# Edit env.sh with your credentials
# Run MCP CLI test (no Claude Desktop required)
source env.sh
python3 mcp-full-test.py
# Or run the full infrastructure test
./01-setup-workspace.sh
./02-deploy-infrastructure.sh
# ... (see test-e2e-remediation/README.md)
Default instructions for the MCP server is located in cmd/terraform-mcp-server/instructions.md, if those do not seem appropriate for your organization's Terraform practices or if the MCP server is producing inaccurate responses, please replace them with your own instructions and rebuild the container or binary.
Installation
Usage with Visual Studio Code
Add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing Ctrl + Shift + P and typing Preferences: Open User Settings (JSON).
claude mcp add terraform -s user -t stdio -- docker run -i --rm hashicorp/terraform-mcp-server
Install from source
go install github.com/hashicorp/terraform-mcp-server/cmd/terraform-mcp-server@latest
Building the Docker Image locally
git clone https://github.com/hashicorp/terraform-mcp-server.git
cd terraform-mcp-server
make docker-build
# Run in stdio mode
docker run -i --rm terraform-mcp-server:dev
# Run in streamable-http mode
docker run -p 8080:8080 --rm -e TRANSPORT_MODE=streamable-http -e TRANSPORT_HOST=0.0.0.0 terraform-mcp-server:dev
# Filter tools (optional)
docker run -i --rm terraform-mcp-server:dev --toolsets=registry,terraform
Control which tools are available using --toolsets (groups) or --tools (individual):
# Enable tool groups
terraform-mcp-server --toolsets=registry,terraform,partner
# Enable specific tools only
terraform-mcp-server --tools=search_providers,get_provider_details,list_workspaces
Transport Support
1. Stdio Transport (Default)
Standard input/output communication using JSON-RPC messages. Ideal for local development.
2. StreamableHTTP Transport
Modern HTTP-based transport supporting both direct HTTP requests and Server-Sent Events (SSE) streams.
अभी टूल सूची नहीं है। रिमोट सर्वर को पहले हेल्थ चेक के बाद सूची मिलती है।
FAQ
सवाल
Terraform Partner कैसे इंस्टॉल करें?
इस पेज पर Cursor, Claude Desktop, Claude Code या VS Code के लिए stdio कॉन्फ़िग कॉपी करें। यह पब्लिशर का इंस्टॉल इस्तेमाल करता है, PlugMCP प्रॉक्सी नहीं।
क्या Terraform Partner के लिए API key चाहिए?
इस रिकॉर्ड में कोई ज़रूरी एनवायरनमेंट वेरिएबल दर्ज नहीं है।
Terraform Partner कौन सा ट्रांसपोर्ट इस्तेमाल करता है?
Terraform Partner stdio पर लोकल चलता है।
Terraform Partner की पिछली जाँच कब हुई थी?
पिछली जाँच 2026-10-28 को हुई। Terraform MCP Server with partner managed resources for AI-assisted remediation