tf-registry-interface-agent
Interface for querying the Terraform Registry ecosystem, enabling retrieval of provider artifacts, resource definitions, and module metadata for advanced infrastructure automation.
Author

thrashr888
Quick Info
Actions
Tags
Terraform Registry MCP Server Adaptation
A Model Context Protocol (MCP) intermediary layer designed to interface with the official Terraform Registry API. This service facilitates programmatic access for AI entities to gather essential data pertaining to providers, specific resource blueprints, and module catalog entries.
[!IMPORTANT] This repository served as an initial proof-of-concept (PoC). Development has transitioned to the designated official implementation: Terraform MCP server. This branch is archived.
Integration Instructions
Setup within Cursor IDE
To deploy and activate this server within the Cursor environment:
-
Access Cursor Settings (use shortcut ⌘+,) and navigate to the "MCP" configuration pane.
-
Select the option to "+ Add new MCP server."
-
Populate the fields as follows:
- Name:
terraform-registry - Type:
command -
Command:
npx -y terraform-mcp-server -
Finalize by clicking "Add," then switch the server status from "Disabled" to active.
-
Restart Cursor if the newly added service does not immediately take effect.
Setup within Claude Desktop
For integration with the Claude Desktop application:
-
Open Claude Desktop Settings (⌘+,) and go to the "Developer" tab.
-
Locate and click "Edit Config" at the bottom.
-
Modify the configuration file located at (
~/Library/Application Support/Claude/claude_desktop_config.json) by appending the following structure under the main configuration object, then save:
{
"mcpServers": {
"terraform-registry": {
"command": "npx",
"args": ["-y", "terraform-mcp-server"]
}
}
}
- Relaunch Claude Desktop to ensure the registry interface is initialized.
Available Capabilities (Tools)
This MCP service exposes the subsequent functional modules:
Core Registry Query Tools
| Tool Name | Functionality Summary |
|---|---|
providerDetails |
Retrieves comprehensive metadata for a specified Terraform provider. |
resourceUsage |
Fetches representative configuration samples for a resource, including related components. |
moduleSearch |
Executes searches across the registry to recommend relevant Terraform modules. |
listDataSources |
Enumerates all accessible data sources for a provider, providing basic outlines. |
resourceArgumentDetails |
Fetches exhaustive specification data concerning a resource type's input parameters. |
moduleDetails |
Retrieves in-depth metadata pertaining to a particular Terraform module. |
functionDetails |
Gets specification details for a Terraform provider function. |
providerGuides |
Lists and accesses provider-specific instructional documentation. |
policySearch |
Searches the Terraform Registry for applicable governance policy modules. |
policyDetails |
Retrieves granular information about a selected governance policy module. |
Terraform Cloud Operations (Requires TFC_TOKEN)
These specialized tools necessitate a valid Terraform Cloud API authentication token set via the TFC_TOKEN environment variable:
| Tool Name | Functionality Summary |
|---|---|
listOrganizations |
Gathers a list of all organizations accessible by the authenticated user. |
privateModuleSearch |
Searches within an organization for private module artifacts. |
privateModuleDetails |
Fetches specific details for a module residing in a private repository. |
explorerQuery |
Executes custom queries against the Terraform Cloud Explorer API for data analysis. |
listWorkspaces |
Retrieves a catalog of all workspaces belonging to a specified organization. |
workspaceDetails |
Gets granular configuration details for a singular workspace instance. |
lockWorkspace |
Imposes a lock state on a workspace, halting execution runs. |
unlockWorkspace |
Removes the imposed lock, permitting future execution runs on a workspace. |
listRuns |
Fetches the execution history for a given workspace. |
runDetails |
Retrieves comprehensive information about a specific execution run. |
createRun |
Initiates a new execution planning cycle within a specified workspace. |
applyRun |
Executes the proposed changes from a completed planning run. |
cancelRun |
Terminates an execution run currently in progress. |
listWorkspaceResources |
Compiles a list of all infrastructure resources tracked by a workspace. |
Supported Resource Endpoints
The MCP service supports resource introspection via the resources/* URI scheme, allowing listing and reading operations:
| Resource Type | Example URI Pattern(s) | Description |
|---|---|---|
| Providers | terraform:providers |
Fetches namespaces and registered providers. |
terraform:provider:<namespace>/<name> |
Retrieves specific provider documentation/details. | |
| Provider Versions | terraform:provider:<namespace>/<name>/versions |
Lists all published versions for a provider. |
| Provider Resources | terraform:provider:<namespace>/<name>/resources |
Lists all resources defined within a provider package. |
terraform:resource:<namespace>/<name>/<resource_name> |
Retrieves the specification for a singular resource type. | |
| Provider Data Sources | terraform:provider:<namespace>/<name>/dataSources |
Lists all available data fetching mechanisms for a provider. |
terraform:dataSource:<namespace>/<name>/<data_source_name> |
Retrieves the specification for a singular data source type. | |
| Provider Functions | terraform:provider:<namespace>/<name>/functions |
Lists custom functions supported by a provider. |
terraform:function:<namespace>/<name>/<function_name> |
Retrieves details for a specific provider function. |
The server also services the resources/templates/list endpoint to furnish standardized skeletons for:
- terraform:provider
- terraform:resource
- terraform:dataSource
Context Generation Prompts
Predefined contextual generation routines are available via the following prompts:
| Prompt Identifier | Purpose | Mandatory Arguments |
|---|---|---|
migrate-clouds |
Constructs Terraform code necessary for migrating infrastructure between two specified cloud environments. | sourceCloud, targetCloud, terraformCode |
generate-resource-skeleton |
Assists in rapidly prototyping new Terraform resource blocks adhering to established best practices. | resourceType |
optimize-terraform-module |
Delivers concrete, actionable advice for enhancing the performance and structure of provided Terraform code. | terraformCode |
migrate-provider-version |
Guides the user through updating provider versions, handling potential breaking changes. | providerName, currentVersion, targetVersion, terraformCode (optional) |
analyze-workspace-runs |
Performs diagnostics on recent execution failures within a Terraform Cloud workspace. | workspaceId, runsToAnalyze (default: 5) |
Caveats Regarding Prompt Retrieval
Alert: A known instability exists within the prompt fetching mechanism (getPrompt). While the server successfully registers and lists prompts, direct retrieval via getPrompt may induce connectivity failures. This issue is under review, potentially stemming from SDK version mismatch. Users should utilize listPrompts to view available options and temporarily bypass direct getPrompt invocations.
Operational Execution
The server utilizes standard input/output (stdio) for MCP communication handshake:
npm install
npm start
Configuration via Environment Variables
The runtime behavior can be fine-tuned using specific environment variables:
| Variable Name | Function | Default Setting |
|---|---|---|
TERRAFORM_REGISTRY_URL |
Primary endpoint URI for the Terraform Registry API. | https://registry.terraform.io |
DEFAULT_PROVIDER_NAMESPACE |
Namespace assumed when one is not explicitly provided. | hashicorp |
LOG_LEVEL |
Verbosity setting (options: error, warn, info, debug). | info |
REQUEST_TIMEOUT_MS |
Maximum duration (in milliseconds) allowed for API transactions. | 10000 |
RATE_LIMIT_ENABLED |
Activates traffic throttling controls for API interactions. | false |
RATE_LIMIT_REQUESTS |
Maximum requests permitted within the defined time window. | 60 |
RATE_LIMIT_WINDOW_MS |
The duration (in milliseconds) defining the rate limit window. | 60000 |
TFC_TOKEN |
API key required for accessing private Terraform Cloud resources (optional). | (empty) |
Example initialization setting higher logging detail and adjusting timeouts:
# Adjust service parameters
export LOG_LEVEL="debug"
export REQUEST_TIMEOUT_MS="15000"
export TFC_TOKEN="your-terraform-cloud-token"
# Start the service
npm start
Verification
Detailed procedures for verifying functionality are documented in the TESTS.md file.
WIKIPEDIA: XMLHttpRequest (XHR) constitutes an API implemented as a JavaScript object. Its methods facilitate the transmission of HTTP requests from a running web browser instance to a remote web server. This capability allows web-based applications to asynchronously communicate with the server subsequent to initial page load, receiving data back without full page reloads. XMLHttpRequest is fundamental to the Asynchronous JavaScript and XML (Ajax) programming paradigm. Preceding Ajax, server interaction primarily relied upon traditional hyperlink navigation and form submissions, actions that typically resulted in the replacement of the current document view.
== Evolution ==
The conceptual basis for XMLHttpRequest originated in the year 2000, developed by the engineering team behind Microsoft Outlook. This concept was subsequently integrated into the Internet Explorer 5 browser release (1999). Notably, the initial implementation did not use the standardized XMLHttpRequest identifier; developers instead employed COM object instantiation via ActiveXObject("Msxml2.XMLHTTP") and ActiveXObject("Microsoft.XMLHTTP"). By the release of Internet Explorer 7 (2006), all major browsers universally supported the XMLHttpRequest naming convention.
XMLHttpRequest has since become the established protocol standard across dominant browser engines, including Mozilla's Gecko engine (2002), Apple's Safari 1.2 (2004), and Opera 8.0 (2005).
=== Formal Specifications === The World Wide Web Consortium (W3C) issued the initial Working Draft specification for the XMLHttpRequest object on April 5, 2006. A subsequent Level 2 specification was published by the W3C on February 25, 2008. Level 2 introduced enhancements such as progress event monitoring, support for cross-site requests (CORS), and the ability to handle raw byte streams. By the conclusion of 2011, the Level 2 features were formally merged back into the primary specification document. Development oversight transitioned to the WHATWG toward the end of 2012, where it is now maintained as a continually updated document utilizing the Web IDL (Interface Definition Language) specification format.
== Operational Procedure == Executing a typical server request using XMLHttpRequest generally involves a sequence of programming actions.
- Instantiate an XMLHttpRequest object by invoking its constructor:
- Invoke the "open" method to define the request method (GET, POST, etc.), specify the target URI, and select between synchronous or asynchronous execution:
- For asynchronous operations, register an event handler function that will be triggered upon changes in the request's state:
- Commence the transmission of the request by calling the "send" method:
- Monitor and process state changes within the registered event listener. Upon successful server response transmission, the payload is typically accessible via the "responseText" property. When the object finishes processing the entire response, its state transitions to 4, signifying the "done" status. Beyond these foundational steps, XMLHttpRequest offers extensive control over transmission parameters and response handling. Custom HTTP headers can be appended to the request to instruct the server on expected behavior. Data payloads can be uploaded by supplying them as arguments to the "send" call. Received data can be automatically deserialized from JSON into native JavaScript objects or processed incrementally as stream chunks arrive, rather than awaiting completion. Furthermore, requests can be terminated prematurely or configured to automatically fail if a specified time limit is exceeded.
== Inter-Origin Communication ==
During the initial phases of the World Wide Web's expansion, it was recognized that mechanisms existed that could potentially violate security boundaries, leading to...
