Terraform
Terraform MCP server reference
This page contains reference information about the Terraform MCP server, including configuration options and tools.
Available tools
The Terraform MCP server provides specialized tools that AI models can use to access current Terraform registry information. These tools work automatically when you ask relevant questions—you don't need to invoke them manually.
Provider tools
Access comprehensive provider documentation for resources, data sources, functions, and configuration guides.
Tool | Purpose | What it returns |
---|---|---|
search_providers | Find provider documentation by service name | List of available documentation with IDs, titles, and categories |
get_provider_details | Retrieve complete documentation for a specific provider component | Full documentation content in markdown format |
get_latest_provider_version | Retrieve the latest version of a specifc provider | The latest version of a provider |
Example prompt: "How do I configure an AWS S3 bucket with versioning enabled?"
Module tools
Discover and explore community and verified modules from the Terraform registry.
Tool | Purpose | What it returns |
---|---|---|
search_modules | Find modules by name or functionality | Module details including names, descriptions, download counts, and verification status |
get_module_details | Get comprehensive module information | Complete documentation with inputs, outputs, examples, and submodules |
get_latest_module_version | Retrieve the latest version of a specifc module | The latest version of a module |
Example prompt: "Show me modules for deploying a Kubernetes cluster on AWS."
Policy tools
Access Sentinel policies for governance and compliance requirements.
Tool | Purpose | What it returns |
---|---|---|
search_policies | Find Sentinel policies by topic or requirement | Policy listings with IDs, names, and download statistics |
get_policy_details | Retrieve detailed policy documentation | Policy implementation details and usage instructions |
Example prompt: "What Sentinel policies are available for enforcing security best practices?"
Available resources
The Terraform MCP server provides several static read-only guides to the MCP clients to retrieve structured, contextual data. It helps generate standardized Terraform code.
Resource URI | Kind | Description |
---|---|---|
/terraform/style-guide | Resource | Terraform Style Guide - Provides access to the official Terraform style guide documentation in markdown format |
/terraform/module-development | Resource | Terraform Module Development Guide - Comprehensive guide covering module composition, structure, providers, publishing, and refactoring best practices |
/terraform/providers/{namespace}/name/{name}/version/{version} | Resource Template | Provider Resource Template - Dynamically retrieves detailed documentation and overview for any Terraform provider by namespace, name, and version |
Transport protocols
You can set one of the following transport protocols when starting the MCP server so that it operates correctly for your environment.
Transport | Best for | How it works | Usage |
---|---|---|---|
stdio | Local development and direct integration with MCP clients | Uses standard input/output for JSON-RPC message communication | Automatically used when no specific transport mode is configured |
streamableHTTP | Remote deployments, distributed setups, production environments | HTTP-based transport with support for both direct HTTP requests | Enable by setting TRANSPORT_MODE=streamable-http |
Environment variables
You can set the following environment variables to configure the server behavior.
Variable | Purpose | Default Value | Example | Options |
---|---|---|---|---|
TRANSPORT_MODE | Communication protocol | stdio | streamable-http | stdio , streamable-http |
TRANSPORT_HOST | HTTP server binding address | 127.0.0.1 | 0.0.0.0 | Any valid IP address |
TRANSPORT_PORT | HTTP server port | 8080 | 3000 | Any valid port number |
MCP_ENDPOINT | HTTP endpoint path | /mcp | /api/mcp | Any valid endpoint path |
MCP_SESSION_MODE | Session management | stateful | stateless | stateful , stateless |
MCP_ALLOWED_ORIGINS | CORS allowed origins | "" (none) | https://app.terraform.io | Comma-separated list of origins or "" |
MCP_CORS_MODE | CORS policy enforcement | strict | development | strict , development , disabled |