Back to Devoured - November 06, 2026
DEVOURED
What Is the OpenTofu MCP Server and How to Use It

What Is the OpenTofu MCP Server and How to Use It

DevOps Spacelift
The official OpenTofu MCP server prevents AI hallucinations by providing read-only, real-time access to the official OpenTofu registry documentation.
What: Maintained by the OpenTofu organization, this server lets AI agents query provider versions, resource arguments, and module usage without needing to run any actual infrastructure commands.
Why it matters: AI assistants often rely on stale training data; this tool forces the agent to look up the current schema, effectively reducing configuration errors during code generation.
Takeaway: Add `npx @opentofu/opentofu-mcp-server` to your AI assistant's configuration to ensure your infrastructure code matches the latest provider versions.
Deep dive
  • Connects to the official OpenTofu registry to fetch live documentation.
  • Exposes seven search and detail-retrieval tools (e.g., get-resource-docs).
  • Enforces security by design: it is strictly read-only and ignores infrastructure state.
  • Functions as a replacement for recalling resource arguments from training data.
  • Compatible with standard MCP clients like Claude Desktop and Cursor.
Decoder
  • OpenTofu: An open-source fork of Terraform, an infrastructure-as-code tool used to define and provision cloud resources.
Original article

What Is the OpenTofu MCP Server and How to Use It

The Model Context Protocol (MCP) has become an industry standard, especially after Anthropic donated it to the Linux Foundation at the end of 2025. PulseMCP, for example, hosts over 21,000 MCP servers, many of which are available for DevOps and infrastructure-as-code tooling.

Every engineer who has asked a large language model (LLM) to write OpenTofu code knows models can produce code that looks correct but no longer works because the latest provider version removed an attribute.

The OpenTofu MCP server exists to solve exactly this issue. In this article, we will discuss the OpenTofu MCP server, what it exposes, how it compares with HashiCorp’s Terraform MCP server, how to wire it into your assistant, and how to combine it with a platform like Spacelift.

What we’ll cover:

  1. What is the OpenTofu MCP server?
  2. What the OpenTofu MCP server exposes
  3. OpenTofu MCP server vs Terraform MCP server
  4. Using the OpenTofu MCP server in practice
  5. Third-party OpenTofu MCP servers for CLI operations

TL;DR

The OpenTofu MCP server is an official, read-only Model Context Protocol server that lets any MCP-compatible AI assistant search the OpenTofu Registry and pull live docs for providers, modules, resources, and datasources, so generated code uses current arguments instead of deprecated ones. It never runs tofu commands, reads state, or handles credentials, so you can leave it connected permanently. Point your client at https://mcp.opentofu.org/mcp, or run it locally with npx @opentofu/opentofu-mcp-server.

What is the OpenTofu MCP server?

The OpenTofu MCP server is an official project from the OpenTofu organization that implements MCP on top of the OpenTofu registry. It enables all MCP-compatible assistants to search the registry and pull live documentation for providers, modules, resources, and datasources.

This matters because OpenTofu providers update constantly, and if you use AI assistants to generate OpenTofu code, the MCP server keeps your documentation current and reduces the chance of errors. When your AI assistant uses the OpenTofu MCP server, it gets current registry data as text, and what it does with that text depends entirely on the assistant and its configuration.

The OpenTofu MCP server doesn’t touch your state file, your cloud credentials, or your working directory; only other tool calls that your AI assistant might make will touch them, so ensure you configure your agent accordingly to minimize the chances of issues. With the OpenTofu MCP server, the worst-case scenario is a wrong search result, so it is safe to leave it connected permanently.

What the OpenTofu MCP server exposes

The OpenTofu MCP server offers the following registry search and information tools:

  • search-opentofu-registry: You can search for providers, modules, resources, and datasources.
  • get-provider-details: Helps you get detailed information about a specific provider
  • get-provider-versions: Helps you get a list of available versions for a provider
  • get-module-details: Helps you get detailed information about a specific module
  • get-module-versions: Helps you get a list of available versions for a specific module
  • get-resource-docs: Helps you get documentation for a specific resource
  • get-datasource-docs: Helps you get documentation for a specific datasource

Search the OpenTofu Registry (search-opentofu-registry)

search-opentofu-registry is a discovery tool that lets your AI assistant search the OpenTofu registry for providers, modules, resources, and datasources.

Get provider details (get-provider-details)

After you identify a provider with the search-opentofu-registry, the get-provider-details can be used to get more detailed information about it. The tool identifies providers by their namespace and provider name, and it can help you determine which provider to use, which resources and datasources belong to that provider, and which examples are available.

Get provider versions (get-provider-versions)

If everything you need is just a list of versions a provider has published, the lighter option you can use is get-provider-versions. This identifies providers in the same way as get-provider-details, but it returns only the available versions and the date each one was released instead of returning the full documentation for a provider. When you are pinning a provider version, this is the tool you should use to ensure the constraint is based on what is actually published in the registry.

Get module details (get-module-details)

With get-module-details, it will retrieve the latest information about a specific module from the registry, enabling it to construct a module block that works with that particular version.

Get module versions (get-module-versions)

get-module-versions works in the same way that get-provider-versions does, only for modules. It returns every published version of a module together with its release date. This makes it easy to confirm what module versions actually exist before your AI assistant fills in the version argument of a module block with something that isn’t published.

Get resource documentation (get-resource-docs)

get-resource-docs is one of the most useful tools for generating the actual OpenTofu infrastructure docs.

With the MCP server, it will retrieve the docs for the resources before deciding which blocks and arguments to use, reducing the chance of generating configurations that don’t work or have deprecated fields.

Get datasource documentation (get-datasource-docs)

Datasources enable OpenTofu configurations to get information about existing infrastructure. get-datasource-docs performs the same retrieval as get-resource-docs, but for datasources.

What the official server does not do

The OpenTofu MCP server does not:

  • Run OpenTofu commands like init, plan, apply, or destroy. The tofu binary isn’t invoked at all.
  • Read or write state: The OpenTofu MCP server does not have the concept of a backend or a state file.
  • Touch your filesystem: It will need to read your OpenTofu configuration or write new ones; Your AI assistant does that part using the OpenTofu MCP Server’s knowledge.
  • Handle credentials: There is no cloud authentication or provider authentication, so there is nothing to leak.
  • Access your private registries: The OpenTofu MCP Server will only query the public OpenTofu Registry.

OpenTofu MCP server vs Terraform MCP server

HashiCorp also ships a Terraform MCP server. Its capabilities are pretty similar to the OpenTofu MCP server’s, but the Terraform one will query HashiCorp’s registry, whereas the OpenTofu MCP server queries the OpenTofu registry.

The Terraform MCP server can also interact with HCP Terraform (formerly Terraform Cloud) and Terraform Enterprise, enabling you to create/update/delete workspaces, create runs, get run details, and even get apply logs.

Using the OpenTofu MCP server in practice

How to install the OpenTofu MCP server

You can either install the OpenTofu MCP server locally, or you can use the hosted service, which is the path recommended by the OpenTofu team. The hosted service is available at https://mcp.opentofu.org/mcp.

To install it locally, you can do it with npx:

npx @opentofu/opentofu-mcp-server

How to connect the OpenTofu MCP server to your AI assistant

For Claude Code, you simply need to run this one-liner command, and then the OpenTofu MCP server will connect to it:

claude mcp add opentofu -t streamable-http https://mcp.opentofu.org/mcp 

How to generate OpenTofu code with the MCP server

Once the OpenTofu MCP server is connected, you should be explicit about what resources you need. By leveraging the OpenTofu MCP server, the AI can perform dynamic lookups for resources like s3_bucket or s3_bucket_versioning rather than relying on potentially outdated training data.

Third-party OpenTofu MCP servers for CLI operations

The official OpenTofu MCP server deliberately stops before CLI execution, but third-party projects fill that gap. One of these examples is the cloud-pilot-mcp, which exposes tofu CLI operations (init, plan, apply, destroy).

While doing CLI operations through an MCP server might seem appealing, these operations can be dangerous and require strong controls around state, credentials, and filesystem access.

How Spacelift complements the OpenTofu MCP server

Spacelift also has its own MCP server that exposes five tools: discover and query for the GraphQL API, mutate for changing Spacelift resources, intent for managing cloud resources using plain language, and provider for inspecting providers, resources, and datasource schemas from the OpenTofu registry.

The OpenTofu MCP server gives your assistant knowledge, while the Spacelift MCP server gives it a governed path to act on that knowledge.

Key takeaways

With the OpenTofu MCP server, your AI assistant no longer has to guess which arguments your configuration needs because it can easily look them up. It is read-only by design, which is why you can leave it connected without the risk of something going wrong.

Frequently asked questions

  • Is the OpenTofu MCP server free to use? Yes. The local OpenTofu MCP server is open-source under the Mozilla Public License 2.0 (MPL-2.0).
  • Where is the OpenTofu MCP server hosted? The official hosted OpenTofu MCP server runs on Cloudflare Workers and is accessible at https://mcp.opentofu.org/mcp.
  • Can the OpenTofu MCP server run tofu plan or tofu apply? No. The official OpenTofu MCP server is a Registry-focused server and does not execute OpenTofu CLI commands.
Explore all 54 articles in today's digest

Fresh dev news, AI-digested daily. Never miss a trend at devoured.fyi