Terraform
Terraform MCP server overview
This topic provides an overview of the Terraform model context protocol (MCP) server, which helps you write Terraform configuration using an AI or LLM. The server requests information directly from the Terraform registry so that your model can formulate responses using provider code and documentation as the source of truth.
Note
This feature is currently in beta. Do not use beta functionality in production environments.
Introduction
MCP standardizes how AI models can discover and interact with external tools, applications, and data sources. You can configure MCP clients, such as an AI or LLM chat, to send requests through an MCP server so that the model can provide answers to prompts that it may not have been trained on. Refer to the MCP documentation for details about how MCP works.
You can configure your AI model to connect to the Terraform MCP server so that it can request information about providers, modules, and other objects from data stored in the Terraform registry. When the Terraform MCP is available to your AI client, the model retrieves information from the most up-to-date source code stored in the registry, instead of relying on outdated training data. As a result, you can get more accurate and actionable information.
Note that to use the server, your questions must pertain to provider configuration from the registry. The LLM uses other sources, such as content from the internet, to respond to general questions about Terraform configuration or requests to generate code.
Workflow
The Terraform MCP server runs in a Docker container that you can deploy to either your local workstation or a remote instance. When running locally, start the server in stdio
mode. When running on a remote instance, start the server in http
mode so that you can communicate with the server using the Streamable HTTP transport. Refer to Deploy server for more information.
After deploying the server, you prompt your model to invoke MCP server tools that retrieve different types of information from the Terraform registry. Refer to Prompt your model for more information.
Terraform MCP server tools
The following table describes tools available in the Terraform MCP server:
Toolset | Tool | Description |
---|---|---|
providers | resolveProviderDocID | Queries the Terraform Registry for available documentation about a specific provider. This tool uses serviceSlug to return a list of provider document IDs with their titles and categories for resources, data sources, functions, or guides. |
providers | getProviderDocs | Fetches the complete documentation content for a specific provider resource, data source, or function using a document ID obtained from the resolveProviderDocID tool. Returns the raw documentation in Markdown format. |
modules | searchModules | Searches the Terraform Registry for modules based on the specified moduleQuery with pagination. Returns a list of module IDs with their names, descriptions, download counts, verification status, and publish dates. |
modules | moduleDetails | Retrieves detailed documentation for a module using a module ID obtained from the searchModules tool, including inputs, outputs, configuration, submodules, and examples. |
policies | searchPolicies | Queries the Terraform Registry for the appropriate Sentinel policy based on the provided query policyQuery . This tool uses terraformPolicyIDs to return a list of policies, including their name, title, and download counts. |
policies | policyDetails | Retrieves detailed documentation for a policy set using a terraformPolicyID obtained from the searchPolicies tool including policy readme and implementation details. |
Release notes
For information about new releases, refer to the Terraform MCP server repository.
Provide feedback
We want to hear from you. Complete the Terraform MCP server feedback form to help us improve this feature.