Connect HCP Terraform to Claude Code
Read workspaces, runs, plans, state outputs, variables, and projects. Add Toolspoke to Claude Code once and it can use 11 HCP Terraform actions. Your HCP Terraform credential stays in Toolspoke, and you choose which actions Claude Code may call.
Set it up in Claude Code
Three steps, the first one once for every toolkit you will ever add.
Add Toolspoke to Claude Code
Run it in your project, then /mcp to sign in
claude mcp add --transport http toolspoke https://toolspoke.com/mcpThe sign-in opens in your browser, and Toolspoke asks you to approve it.
Install HCP Terraform and connect it
Add HCP Terraform to a project in your Toolspoke workspace.
API token. You provide it once, when you install the connector. Toolspoke encrypts it at rest and decrypts it only for the length of a single call, and the gateway attaches it to the outbound request itself, so it is never part of the arguments an agent sends.
- API token
- User Settings → Tokens → Create an API token, or a team token from the organization's Team settings. A user or team token is the better fit here: HashiCorp documents that an organization token cannot read a plan's JSON output at all, so get_plan_json_output will fail for one even though every other read works.
Choose what Claude Code may do
All 11 actions only read, and any of them can be switched off for a project.
What you can ask Claude Code for
A few of the HCP Terraform actions that only read, so they are safe to try first.
- List the organizations this token can see, with each one's name and settings
- Read the outputs of a workspace's current state, each output's name, type and value
- List an organization's projects with their names and ids
What Claude Code can do in HCP Terraform
11 actions read.
Reads
List organizations
List the organizations this token can see, with each one's name and settings. Call it first when you do not know which organization to act on, and to find out whether the connection reaches anything at all, an empty list means the token is valid but is a member of nothing. The `name` returned here is what every organization argument below takes.
List workspaces
List an organization's workspaces with each one's name, Terraform version, execution mode, current run status and id. Call it to get the workspace id (ws-…) that get_workspace, list_runs, list_variables and get_current_state_outputs all take.
Get workspace
Fetch one workspace by id, including its execution mode, Terraform version, auto-apply setting, VCS repository, working directory, lock state, and the id of its current run. Read auto-apply before trusting anything about how a run in this workspace behaves, a workspace with auto-apply on applies a successful plan without a person approving it.
List runs
List a workspace's runs, newest first, with each run's status, message, source, and the ids of its plan and apply. This is the operation that answers "what happened in this workspace lately" and "why is it stuck".
Get run
Fetch one run by id, its status, the timestamps of every status it passed through, who queued it, and its permissions block. Pass include to pull the related plan, apply or configuration version back in the same response instead of making a second call.
Get plan
Fetch one plan by id, its status, whether it has changes, and the counts of resources it would add, change and destroy. This is the cheap summary; get_plan_json_output is the full machine-readable plan. HashiCorp documents no endpoint that lists plans, so the id comes from a run: call get_run with include ["plan"], or read the run's relationships.
Get plan json output
Fetch the full machine-readable JSON execution plan, every resource change with its before and after attribute values. Use it to answer exactly what a run would do before a person approves it. Three things to expect. The endpoint answers 307 and the real content comes from a short-lived download URL, so the payload is the plan itself rather than a JSON:API envelope. It answers 204 when the plan has not finished yet, and 422 when the workspace runs a Terraform older than 0.12. And HashiCorp documents that an organization token cannot call it at all, use a user or team token with admin access to the workspace. The response is not written to the audit log: a plan carries the resolved values of the resources it touches.
List state versions
List a workspace's state versions, newest first, with each one's serial number, creation time, and the run that produced it. Use it to see how often state has changed and which run last wrote it. Both the workspace name and the organization name are required by the API, this endpoint is filtered rather than nested.
Get current state outputs
Read the outputs of a workspace's current state, each output's name, type and value. This is the workspace-scoped outputs endpoint on purpose: HashiCorp documents that it returns null for any output marked sensitive, while the state-version-output endpoints return the real value. This connector exposes only the redacting one, and does not expose the raw state download at all. Treat what does come back as sensitive anyway: an output is only masked if whoever wrote the Terraform remembered to mark it, and outputs routinely carry endpoints, ARNs and connection strings. The response is not written to the audit log for that reason.
List variables
List a workspace's own variables, key, category ("terraform" or "env"), whether the value is HCL, and whether it is marked sensitive. A variable marked sensitive is write-only in HCP Terraform, so its value does not come back; every other variable's value does, which is why this response is not written to the audit log. Variable sets shared across workspaces are a separate resource and are not covered here.
List projects
List an organization's projects with their names and ids. A project groups workspaces; pass the prj- id returned here to list_workspaces to see only that group.
HCP Terraform in Claude Code: questions
Does Claude Code see my HCP Terraform credential?
No. The credential is stored encrypted in Toolspoke, and the gateway adds it to each call. Claude Code only ever talks to Toolspoke, and the dashboard shows the last four characters of the credential and nothing more.
Will 11 actions crowd Claude Code's context?
No. Toolspoke shows Claude Code five bridge tools, plus a guide where a toolkit has one, and Claude Code searches for the HCP Terraform action it needs when it needs it. Adding more toolkits does not add more tools to its list.
Can I add it once for every project?
Yes. Add --scope user to the command and Claude Code keeps Toolspoke in every project on this machine. Without it, the server is added to the project you ran the command in.
What does it cost?
Tool calls are free on every plan, and a HCP Terraform call does not run in a sandbox, so it bills nothing.
HCP Terraform in your other apps
Try HCP Terraform in Claude Code
Free to start, and tool calls cost nothing on any plan.