Sponsored by Deepsite.site

Terraform Registry MCP Server

Created By
MCP-Mirror7 months ago
Mirror of
Content

Terraform Registry MCP Server

A Model Context Protocol (MCP) server that provides tools for interacting with the Terraform Registry API. This server enables AI agents to query provider information, resource details, and module metadata.

IMPORTANT

This project was used as a PoC for a new official Terraform MCP server. This repo has been archived in favor of that one.

Installation

Installing in Cursor

To install and use this MCP server in Cursor:

  1. In Cursor, open Settings (⌘+,) and navigate to the "MCP" tab.

  2. Click "+ Add new MCP server."

  3. Enter the following:

    • Name: terraform-registry
    • Type: command
    • Command: npx -y terraform-mcp-server
  4. Click "Add" then scroll to the server and click "Disabled" to enable the server.

  5. Restart Cursor, if needed, to ensure the MCP server is properly loaded.

terraform-registry MCP settings for Cursor

Installing in Claude Desktop

To install and use this MCP server in Claude Desktop:

  1. In Claude Desktop, open Settings (⌘+,) and navigate to the "Developer" tab.

  2. Click "Edit Config" at the bottom of the window.

  3. Edit the file (~/Library/Application Support/Claude/claude_desktop_config.json) to add the following code, then Save the file.

{
  "mcpServers": {
    "terraform-registry": {
      "command": "npx",
      "args": ["-y", "terraform-mcp-server"]
    }
  }
}
  1. Restart Claude Desktop to ensure the MCP server is properly loaded.

Tools

The following tools are available in this MCP server:

Core Registry Tools

ToolDescription
providerDetailsGets detailed information about a Terraform provider
resourceUsageGets example usage of a Terraform resource and related resources
moduleSearchSearches for and recommends Terraform modules based on a query
listDataSourcesLists all available data sources for a provider and their basic details
resourceArgumentDetailsFetches comprehensive details about a resource type's arguments
moduleDetailsRetrieves detailed metadata for a Terraform module
functionDetailsGets details about a Terraform provider function
providerGuidesLists and views provider-specific guides and documentation
policySearchSearches for policy libraries in the Terraform Registry
policyDetailsGets detailed information about a specific policy library

Terraform Cloud Tools

These tools require a Terraform Cloud API token (TFC_TOKEN):

ToolDescription
listOrganizationsLists all organizations the authenticated user has access to
privateModuleSearchSearches for private modules in an organization
privateModuleDetailsGets detailed information about a private module
explorerQueryQueries the Terraform Cloud Explorer API to analyze data
listWorkspacesLists workspaces in an organization
workspaceDetailsGets detailed information about a specific workspace
lockWorkspaceLocks a workspace to prevent runs
unlockWorkspaceUnlocks a workspace to allow runs
listRunsLists runs for a workspace
runDetailsGets detailed information about a specific run
createRunCreates a new run for a workspace
applyRunApplies a run that's been planned
cancelRunCancels a run that's in progress
listWorkspaceResourcesLists resources in a workspace

Resources

The MCP server supports the following resource URIs for listing and reading via the resources/* methods:

Resource TypeExample URI(s)Description
Providersterraform:providersList all namespaces/providers
terraform:provider:<namespace>/<name>Get details for a specific provider
Provider Versionsterraform:provider:<namespace>/<name>/versionsList available versions for a provider
Provider Resourcesterraform:provider:<namespace>/<name>/resourcesList resources for a provider
terraform:resource:<namespace>/<name>/<resource_name>Get details for a specific resource type
Provider Data Sourcesterraform:provider:<namespace>/<name>/dataSourcesList data sources for a provider
terraform:dataSource:<namespace>/<name>/<data_source_name>Get details for a specific data source
Provider Functionsterraform:provider:<namespace>/<name>/functionsList functions for a provider
terraform:function:<namespace>/<name>/<function_name>Get details for a specific function

The server also supports resources/templates/list to provide templates for creating:

  • terraform:provider
  • terraform:resource
  • terraform:dataSource

Prompts

The following prompts are available for generating contextual responses:

PromptDescriptionRequired Arguments
migrate-cloudsGenerate Terraform code to migrate infrastructure between cloud providerssourceCloud, targetCloud, terraformCode
generate-resource-skeletonHelps users quickly scaffold new Terraform resources with best practicesresourceType
optimize-terraform-moduleProvides actionable recommendations for improving Terraform codeterraformCode
migrate-provider-versionAssists with provider version upgrades and breaking changesproviderName, currentVersion, targetVersion, terraformCode (optional)
analyze-workspace-runsAnalyzes recent run failures and provides troubleshooting guidance for Terraform Cloud workspacesworkspaceId, runsToAnalyze (optional, default: 5)

Known Issues with Prompts

Note: There is a known issue with the getPrompt functionality that can cause server crashes. The server properly registers prompts and can list them, but direct requests using the getPrompt method may cause connectivity issues. This is being investigated and may be related to SDK compatibility or implementation details. Until resolved, use listPrompts to see available prompts but avoid direct getPrompt calls.

Running the Server

The server runs using stdio transport for MCP communication:

npm install
npm start

Configuration with Environment Variables

The server can be configured using environment variables:

Environment VariableDescriptionDefault Value
TERRAFORM_REGISTRY_URLBase URL for Terraform Registry APIhttps://registry.terraform.io
DEFAULT_PROVIDER_NAMESPACEDefault namespace for providershashicorp
LOG_LEVELLogging level (error, warn, info, debug)info
REQUEST_TIMEOUT_MSTimeout for API requests in milliseconds10000
RATE_LIMIT_ENABLEDEnable rate limiting for API requestsfalse
RATE_LIMIT_REQUESTSNumber of requests allowed in time window60
RATE_LIMIT_WINDOW_MSTime window for rate limiting in milliseconds60000
TFC_TOKENTerraform Cloud API token for private registry access (optional)

Example usage with environment variables:

# Set environment variables
export LOG_LEVEL="debug"
export REQUEST_TIMEOUT_MS="15000"
export TFC_TOKEN="your-terraform-cloud-token"

# Run the server
npm start

Testing

See the TESTS.md file for information about testing this project.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Serper MCP ServerA Serper MCP Server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Tavily Mcp
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
CursorThe AI Code Editor
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Amap Maps高德地图官方 MCP Server
DeepChatYour AI Partner on Desktop
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
ChatWiseThe second fastest AI chatbot™
WindsurfThe new purpose-built IDE to harness magic
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Playwright McpPlaywright MCP server
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs