- Terraform MCP Server
- v1.x (latest)
- v0.5.x
- v0.4.x
- v0.3.x
Prompt a model connected to the Terraform MCP server
This topic provides example prompts for helping you write Terraform configuration after installing the Terraform model context protocol (MCP) server. Refer to Deploy the Terraform MCP server for instructions on how to deploy the server.
Overview
To trigger the MCP server tools, ask your LLM questions about your provider configuration or general questions about Terraform providers and modules. Note that for your LLM 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.
Your client may use specific characters to invoke tools from connected MCP servers. For example, use #terraform in the Visual Studio Code chat interface to direct your connected model to use the Terraform MCP server. Refer to the documentation for your client or model for instructions on how to trigger specific behaviors.
Requirements
Verify that you have deployed the Terraform MCP server and configured your client. Refer to Deploy the Terraform MCP server for instructions.
Prompt your MCP client
Your model may still decide to use other resources to formulate responses, but you can use the following guidelines to help you create prompts that are more likely to be routed through the server:
- Include the names of specific providers or provider modules. For example, use
google_compute_diskin your prompt instead ofthe compute disk. - Use the full Terraform resource address in your query. Refer to Resource Address Reference in the Terraform CLI documentation for additional information about resource addresses.
- Ask for the latest information about the provider or module.
Examples
Use the following set of prompts as a guide to help you write your own configuration. The responses are returned from the server using ChatGPT 4.1 in GitHub Copilot on VS Code. Your responses may vary.
These examples show the prompt, the server's API request to the Terraform registry, and a representative AI response. Review responses carefully before applying any configuration. The server retrieves current registry documentation, but AI models can still misinterpret or omit argument details.
Google provider AI resources
The server obtains a list of Google provider document IDs so that you can decide which resources to create.
Prompt
I need help understanding what resources are available
in the Google provider that are for AI
Request
The server sends the following request payload to the registry:
{
"provider_Data_Type": "resources",
"provider_Name": "google",
"provider_Namespace": "hashicorp",
"providerVersion": "latest",
"serviceSlug": "ai"
}
What the server does
The server calls search_providers with serviceSlug: "ai" to filter the Google provider's documentation index to AI-related entries and returns the matching document IDs and titles. The providerVersion: "latest" field ensures the results reflect the most recently published version of the provider.
Response
The Google Terraform provider offers several resources related to AI, primarily under the Vertex AI and Document AI services. Here are the main AI-related resources available:
**Vertex AI Resources**
- `vertex_ai_dataset`
- `vertex_ai_deployment_resource_pool`
- `vertex_ai_endpoint`
- `vertex_ai_endpoint_iam`
- `vertex_ai_feature_group`
- `vertex_ai_featurestore`
- `vertex_ai_index`
- `vertex_ai_metadata_store`
- `vertex_ai_tensorboard`
- `document_ai_processor`
- `document_ai_warehouse_document_schema`
These resources allow you to manage datasets, endpoints, feature stores, indexes, metadata, and more for AI/ML workflows on Google Cloud, as well as Document AI processors and schemas.
What to verify
The resource names in the response, such as vertex_ai_dataset and
vertex_ai_endpoint, are derived from current registry documentation. Confirm
that a resource exists in your target provider version before writing
configuration. You can check the Google provider resource
list
directly.
What to do next
To retrieve the full argument schema and an example configuration for any of these resources, follow up with a prompt such as:
Show me the configuration schema for google_vertex_ai_endpoint
Azure storage buckets
The following prompt gets a list of provider documentation IDs. Then, it calls the appropriate documentation for the use case.
Prompt
I need help setting up storage buckets in the azure provider
Request
The server sends the following request payloads to the registry:
{
"providerDataType": "resources",
"providerName": "azurerm",
"providerNamespace": "hashicorp",
"providerVersion": "latest",
"serviceSlug": "storage_account"
}
{
"providerDocID": "8957547"
}
{
"providerDocID": "8957555"
}
What the server does
The server makes two sequential calls:
search_providerswithserviceSlug: "storage_account"to find documentation IDs for storage-related resources in theazurermproviderget_provider_detailsfor each returned document ID to retrieve the full documentation, including example HCL configurations
This two-step pattern of search then fetch is how the server resolves broad questions into specific, versioned documentation.
Response
The server retrieves several responses from each tool, including example configurations from the registry. This response is one of the examples.
Available Documentation (top matches) for resources in Terraform provider hashicorp/azurerm version: 4.29.0
# azurerm_storage_account
Manages an Azure Storage Account.
## Example Usage
```hcl
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}
resource "azurerm_storage_account" "example" {
name = "storageaccountname"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "GRS"
tags = {
environment = "staging"
}
}
```
To set up storage buckets in Azure using the Terraform azurerm provider, you need to use the azurerm_storage_account resource. Here's a quick guide and example configuration:
1. Terraform Resource for Azure Storage Account
```hcl
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}
resource "azurerm_storage_account" "example" {
name = "storageaccountname" # must be globally unique, lowercase
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = "Standard" # or "Premium"
account_replication_type = "GRS" # or "LRS", "RAGRS", "ZRS", etc.
tags = {
environment = "staging"
}
}
```
What to verify
The HCL in the response is pulled from the live registry for azurerm version 4.29.0. The name value for azurerm_storage_account must be globally unique and lowercase. Confirm the account_replication_type value is valid for your Azure region before applying. Not all replication types are available in all regions. Refer to the azurerm_storage_account documentation for the full argument reference.
What to do next
To add a blob container to the storage account, follow up with:
How do I add an azurerm_storage_container to this storage account?
Create an IBM VM
The following prompt gets a list of modules:
Is there a module to help with setting up an IBM VM?
Request
The server sends the following request payload:
{
"moduleQuery": "ibm vm"
}
What the server does
The server calls search_modules with the query "ibm vm" to search the public
Terraform registry for modules matching that text. It returns module metadata
including the namespace, module ID, version, and source repository. The response
does not retrieve the full module documentation because it is a discovery step.
Response
The client prints the following response using the context acquired from the MCP server.
Yes, there is a Terraform module to help with setting up an IBM VM:
- IBM VM Module
- ID: intel/ibm-vm/intel/1.2.2
- Description: Intel Cloud Optimization Module - IBM VM
- Module Version: 1.2.2
- Namespace: intel
- Source: GitHub - intel/terraform-intel-ibm-vm
You can use this module to set up and manage IBM VMs with Terraform.
If you need more details or usage examples, let me know.
What to verify
The module ID intel/ibm-vm/intel and version 1.2.2 were current at the time this example was captured. Verify the latest version and review the required inputs before using the module. You can inspect the module at registry.terraform.io/modules/intel/ibm-vm/intel.
What to do next
To retrieve the full module documentation, including required inputs, optional variables, and usage examples, follow up with:
Show me the full details for the intel/ibm-vm/intel module