Terraform Registry MCP Server
raw JSON → 0.13.0 verified Sat Apr 25 auth: no javascript
A Model Context Protocol (MCP) server that provides tools for interacting with the Terraform Registry API, enabling AI agents to query provider information, resource details, module metadata, and Terraform Cloud resources. Current stable version is v0.13.0, actively maintained. Key differentiators include a comprehensive set of tools for both public registry (providerDetails, resourceUsage, moduleSearch) and Terraform Cloud (workspaces, runs, organizations), with standardized tool naming and Docker support. Alternatives like terraform-mcp or official Terraform APIs offer more limited scope or require custom integration.
Common errors
error Error: Cannot find module 'terraform-mcp-server' (or 'ERR_MODULE_NOT_FOUND') ↓
cause Using CommonJS require() with an ESM-only package; also possible if package not installed globally.
fix
Use ESM import syntax (import ... from 'terraform-mcp-server') or run via npx (npx terraform-mcp-server) without local install.
error TypeError: terraformMcpServer is not a function ↓
cause Importing default export incorrectly, possibly using named import for default.
fix
Ensure default import: import terraformMcpServer from 'terraform-mcp-server'; (without braces).
error Error: TFC_TOKEN environment variable not set ↓
cause Terraform Cloud tools require the TFC_TOKEN env var; attempting to use them without setting it.
fix
Set TFC_TOKEN to your Terraform Cloud API token: export TFC_TOKEN='your_token_here' or pass in config.tfcToken if supported.
error Error: Tool 'searchModules' not found (or 'exampleConfigGenerator' not found) ↓
cause Tool renamed or removed in recent versions; using old tool names.
fix
Use new standardized names: 'moduleSearch' instead of 'searchModules'; 'resourceUsage' instead of 'exampleConfigGenerator'.
Warnings
breaking Tool naming standardized in v0.12.0; existing tool names may have changed (e.g., 'searchModules' renamed to 'moduleSearch'). ↓
fix Update tool names to new standardized patterns: e.g., use 'moduleSearch' instead of 'searchModules'.
breaking Removed 'exampleConfigGenerator' tool in v0.9.6; tool no longer available. ↓
fix Use 'resourceUsage' tool for example configurations instead.
breaking Removed 'providerSchemaDetails' tool in v0.9.5; tool no longer available. ↓
fix Use 'resourceArgumentDetails' tool to get resource argument details.
deprecated Terraform Cloud API token now required as environment variable 'TFC_TOKEN' instead of config file parameter. ↓
fix Set TFC_TOKEN environment variable before starting the server.
gotcha MCP protocol version mismatch: server sends protocol version '2024-11-05' but older clients may expect '2024-10-07'. ↓
fix Ensure your MCP client supports protocol version 2024-11-05; update client SDK if needed.
gotcha Rate limiting: Terraform Registry API may return 429 errors under heavy usage; server does not implement retry logic. ↓
fix Implement client-side rate limiting or exponential backoff; consider caching frequent queries locally.
Install
npm install terraform-mcp-server yarn add terraform-mcp-server pnpm add terraform-mcp-server Imports
- default wrong
const terraformMcpServer = require('terraform-mcp-server');correctimport terraformMcpServer from 'terraform-mcp-server'; - ProviderDetailsTool wrong
const { ProviderDetailsTool } = require('terraform-mcp-server');correctimport { ProviderDetailsTool } from 'terraform-mcp-server'; - ServerConfig
import { ServerConfig } from 'terraform-mcp-server';
Quickstart
// Quickstart: run the MCP server with npx (no code required for basic use)
// In your terminal:
// npx terraform-mcp-server
// To use programmatically:
import terraformMcpServer from 'terraform-mcp-server';
const config = {
// Optional: add Terraform Cloud token for private module/workspace tools
tfcToken: process.env.TFC_TOKEN ?? ''
};
const server = terraformMcpServer(config);
// The server implements the MCP protocol; connect it to a transport
// Example with stdin/stdout transport:
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
const transport = new StdioServerTransport();
await server.connect(transport);
console.log('Terraform Registry MCP server running on stdio');