HashiCorp · Codex
Add the Terraform MCP server to Codex
Look up providers and modules in the Terraform Registry and work with HCP Terraform workspaces.
Official serverLocalCloud & infrastructure
1. Add the server
Run in your terminal
# ~/.codex/config.toml [mcp_servers.terraform] command = "docker" args = ["run", "-i", "--rm", "docker.io/hashicorp/terraform-mcp-server:1.0.0"]
2. Sign in
Run codex mcp login <name> to complete OAuth for a remote server. Terraform runs locally; set any credentials HashiCorp asks for before starting Codex.
3. Try it
Ask Codex for something Terraform can do. Look up providers and modules in the Terraform Registry and work with HCP Terraform workspaces. Approve the first tool call and check the result before allowing write actions automatically.
- · Each server is a [mcp_servers.<name>] table in config.toml.
- · Use enabled_tools or disabled_tools to keep the tool list short.
FAQ
- How do I add the Terraform MCP server to Codex?
- Run: # ~/.codex/config.toml …. Run codex mcp login <name> to complete OAuth for a remote server.
- Is this the official Terraform MCP server?
- Yes. It is published by HashiCorp as io.github.hashicorp/terraform-mcp-server in the official MCP registry.
- Does the Terraform MCP server need an API key?
- It runs locally from a package. See HashiCorp's docs for any credentials it needs.
Links
Terraform in other clients
More cloud & infrastructure for Codex
Work at HashiCorp?
Feature Terraform across the directory and its category from $49/month.
Reviewed Oct 5, 2026. Command generated from the registry record and checked against Codex's documented syntax.