# OpenTofu Test

> OpenTofu Test is an open-source MCP server for developer tools. MCP server that scaffolds, mocks, validates and runs OpenTofu/Terraform native tests. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, Linux, macOS, Windows, Self-hosted
- **Repository:** https://github.com/ogormans-deptstack/opentofu-test-mcp
- **MCP Registry name:** io.github.ogormans-deptstack/opentofu-test
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-11-18

## About

The server gives an AI agent reference material for the OpenTofu and Terraform test grammar, covering run, assert and mock_provider blocks. Its scaffolding tool reads a module's variables and outputs to produce a starter .tftest.hcl file, and its schema-based tool emits mock_provider blocks from an initialized module's provider schema.

The README says it drives the tofu CLI when present and falls back to terraform. Static validation of test files works without either CLI, while schema and run-backed tools need one installed. The container image bundles OpenTofu.

It suits developers who use coding agents to write Terraform module tests and want the agent to check its own work before running the suite. Native tests can apply real infrastructure, so the README advises mounting only trusted modules.

## Features

- **Test block reference:** Returns reference text and an example for a test-framework block such as run, assert or expect_failures.
- **Test scaffolding from module:** Generates a .tftest.hcl starter with a run block, per-output assertions and placeholders for required variables.
- **Mock provider generation:** Builds mock_provider blocks from the provider schema of an initialized module, with defaults for computed attributes.
- **Static test validation:** Checks test files for invalid commands, missing assert fields and duplicate run names without running OpenTofu.
- **Native test runner summary:** Runs tofu test in JSON mode and returns a condensed pass/fail summary per run.

## Good for

- Letting a coding agent draft native tests for a Terraform module
- Catching malformed run or assert blocks before running a test suite
- Generating mock providers so module tests run without cloud credentials
- Summarising pass and fail results from tofu test runs for an agent

## Install

### Claude Code (Terminal)

```sh
claude mcp add opentofu-test -- docker run -i --rm ghcr.io/ogormans-deptstack/opentofu-test-mcp:0.1.0
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "opentofu-test": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "ghcr.io/ogormans-deptstack/opentofu-test-mcp:0.1.0"
      ]
    }
  }
}
```

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "opentofu-test": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "ghcr.io/ogormans-deptstack/opentofu-test-mcp:0.1.0"
      ]
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "opentofu-test": {
      "type": "stdio",
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "ghcr.io/ogormans-deptstack/opentofu-test-mcp:0.1.0"
      ]
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "opentofu-test": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "ghcr.io/ogormans-deptstack/opentofu-test-mcp:0.1.0"
      ]
    }
  }
}
```

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "opentofu-test": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "ghcr.io/ogormans-deptstack/opentofu-test-mcp:0.1.0"
      ]
    }
  }
}
```

## Tools

- `tf_explain_test_schema`: Reference and example for a test-framework block.
- `tf_scaffold_test`: Generates a .tftest.hcl starter from module variables and outputs.
- `tf_gen_mock_provider`: Emits mock_provider blocks from the provider schema.
- `tf_validate_test`: Statically checks a .tftest.hcl file or content.
- `tf_run_tests`: Runs tofu test -json and returns a pass/fail summary.

## FAQ

### Which CLI does the server need?

The README says it uses tofu when present and falls back to terraform. Schema- and run-backed tools need one of them; the explain and validate tools work without either.

### Does OpenTofu Test need cloud credentials?

The README says the container image does not inherit host cloud credentials, and its own fixtures use the built-in terraform_data provider so no credentials are needed.

### How is OpenTofu Test installed?

The README gives a go install command, prebuilt binaries on GitHub Releases, and a Docker image at ghcr.io/ogormans-deptstack/opentofu-test-mcp.

### Is OpenTofu Test free?

Yes. OpenTofu Test is open source, so you can use and self-host it for free.

### How do I add OpenTofu Test to Claude Code?

Run this command in your terminal: claude mcp add opentofu-test -- docker run -i --rm ghcr.io/ogormans-deptstack/opentofu-test-mcp:0.1.0

### What are the best alternatives to OpenTofu Test?

The closest alternatives to OpenTofu Test are Universal Test Framework, Tofu, Testing, Forge Test MCP and Test Intel.

## Where this comes from

- Description: written from the project's README and its MCP Registry entry.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [Universal Test Framework](https://ai-powered.com/mcp/universal-test-framework): Universal Test Framework is an open-source MCP server for developer tools.
- [Tofu](https://ai-powered.com/mcp/tofu): Tofu is a freemium MCP server for cloud and infrastructure.
- [Testing](https://ai-powered.com/mcp/testing): Testing is an open-source MCP server for developer tools.
- [Forge Test MCP](https://ai-powered.com/mcp/forge-test-mcp): Forge Test MCP is an open-source MCP server for developer tools.
- [Test Intel](https://ai-powered.com/mcp/test-intel): Test Intel is an open-source MCP server for developer tools.
- [MCP Test Runner](https://ai-powered.com/mcp/mcp-test-runner): MCP Test Runner is an open-source MCP server for developer tools.
- [toolmenu](https://ai-powered.com/mcp/toolmenu): toolmenu is an open-source MCP server for developer tools.
- [Dave-London](https://ai-powered.com/mcp/dave-london): Dave-London is an open-source MCP server for developer tools.

---
Source: https://ai-powered.com/mcp/opentofu-test
