Automate Terraform Cloud/Enterprise operations: create workspaces, trigger runs, manage variables, and search registries for infrastructure-as-code projects.
Ships in terraform-mcp-as-code. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Automate HashiCorp Cloud Platform (HCP) Terraform infrastructure management through type-safe TypeScript wrappers for Terraform Cloud and Terraform Enterprise.
Invoke this skill when you need to:
This skill is ideal for infrastructure-as-code automation and programmatic HCP Terraform management workflows.
Required:
TFE_TOKEN environment variable with a valid Terraform API tokenMCP Server Command:
docker run -i --rm -e TFE_TOKEN=your_token hashicorp/terraform-mcp-server
⚠️ Important Security Guidelines:
TFE_TOKENExample of secure token handling:
// ✅ Correct: Use environment variables
const token = process.env.TFE_TOKEN;
// ❌ Wrong: Hardcoded token
const token = "abc123..."; // NEVER DO THIS
This skill provides 34 type-safe tools organized into 6 categories:
Workspaces (7 tools) - scripts/workspaces/
Runs (3 tools) - scripts/runs/
Variables (9 tools) - scripts/variables/
Public Registry (9 tools) - scripts/public-registry/
Private Registry (4 tools) - scripts/private-registry/
Organization (2 tools) - scripts/organization/
For detailed parameters and types, see the TypeScript files in each category directory. All functions include full type definitions and JSDoc comments for IDE autocomplete.
import { initializeMCPClient, closeMCPClient } from "./scripts/client.js";
import { CreateWorkspace } from "./scripts/workspaces/index.js";
import { CreateRun } from "./scripts/runs/index.js";
// 1. Initialize connection
await initializeMCPClient({
command: "docker",
args: [
"run", "-i", "--rm",
"-e", `TFE_TOKEN=${process.env.TFE_TOKEN}`,
"hashicorp/terraform-mcp-server"
]
});
try {
// 2. Create a workspace
const workspace = await CreateWorkspace({
workspace_name: "my-infrastructure",
terraform_org_name: "my-org",
auto_apply: "false"
});
// 3. Trigger a run
const run = await CreateRun({
workspace_name: "my-infrastructure",
terraform_org_name: "my-org",
message: "Initial deployment"
});
} finally {
// 4. Clean up
await closeMCPClient();
}
// Use case: Setting up a new production environment for an API service
import { CreateWorkspace } from "./scripts/workspaces/index.js";
const workspace = await CreateWorkspace({
workspace_name: "production-api",
terraform_org_name: "acme-corp",
description: "Production API infrastructure",
auto_apply: "false", // Require manual approval for production
execution_mode: "remote",
terraform_version: "1.6.0",
tags: "production,api,critical"
});
// Use case: Discovering the right VPC module for AWS infrastructure
import { SearchModules, GetModuleDetails } from "./scripts/public-registry/index.js";
// 1. Search for VPC modules
const modules = await SearchModules({
module_query: "vpc aws terraform-aws-modules"
});
// 2. Get detailed documentation for the best match
const moduleDetails = await GetModuleDetails({
module_id: "terraform-aws-modules/vpc/aws/5.1.2"
});
console.log(moduleDetails.content[0].text);
// Use case: Setting up environment-specific configuration
import { CreateVariableSet, CreateVariableInVariableSet, AttachVariableSetToWorkspaces } from "./scripts/variables/index.js";
// 1. Create a variable set for AWS credentials
const varSet = await CreateVariableSet({
terraform_org_name: "acme-corp",
name: "aws-production-credentials",
description: "AWS credentials for production workspaces",
global: false
});
// 2. Add variables to the set
await CreateVariableInVariableSet({
variable_set_id: varSet.id,
key: "AWS_REGION",
value: "us-east-1",
category: "env",
sensitive: false
});
// 3. Attach to workspaces
await AttachVariableSetToWorkspaces({
variable_set_id: varSet.id,
workspace_ids: "ws-123,ws-456,ws-789"
});
// Use case: Deploying infrastructure changes with monitoring
import { CreateRun, GetRunDetails } from "./scripts/runs/index.js";
// 1. Trigger a run
const run = await CreateRun({
workspace_name: "production-api",
terraform_org_name: "acme-corp",
message: "Deploy v2.1.0 API changes",
run_type: "plan-and-apply"
});
// 2. Monitor run status
const runDetails = await GetRunDetails({
run_id: run.id
});
console.log(`Run status: ${runDetails.status}`);
console.log(`Plan output: ${runDetails.content[0].text}`);
Import from category indexes or individual files:
// Import from category index
import { CreateWorkspace, UpdateWorkspace, ListWorkspaces } from "./scripts/workspaces/index.js";
// Or import specific tool with types
import { CreateWorkspace, CreateWorkspaceInput, CreateWorkspaceOutput } from "./scripts/workspaces/createWorkspace.js";
All wrapper functions are fully typed with Input/Output interfaces. Use your IDE's autocomplete to discover parameters and see JSDoc documentation.
try {
const result = await CreateWorkspace({
workspace_name: "my-workspace",
terraform_org_name: "my-org"
});
if (result.isError) {
console.error("Workspace creation failed:", result.content);
} else {
console.log("Workspace created successfully");
}
} catch (error) {
console.error("MCP call failed:", error);
}
Before Using:
TFE_TOKEN is set: echo $TFE_TOKENdocker --versiondocker run -i --rm -e TFE_TOKEN=$TFE_TOKEN hashicorp/terraform-mcp-server
Troubleshooting:
TFE_TOKEN has correct permissions for the operationscripts/client.ts - MCP connection manager (initializeMCPClient, callMCPTool, closeMCPClient)scripts/{category}/ - Type-safe wrapper functions organized by category
.ts file with Input/Output interfacesindex.ts provides barrel exports for convenient importingThis skill is NOT suitable for:
This skill was auto-generated by mcp-to-claude-skill
CLAUDE.md (opens in a new tab)README.md (opens in a new tab)plugin.json (opens in a new tab)scripts/client.ts (opens in a new tab)scripts/organization/index.ts (opens in a new tab)scripts/organization/listTerraformOrgs.ts (opens in a new tab)scripts/organization/listTerraformProjects.ts (opens in a new tab)scripts/private-registry/getPrivateModuleDetails.ts (opens in a new tab)scripts/private-registry/getPrivateProviderDetails.ts (opens in a new tab)scripts/private-registry/index.ts (opens in a new tab)scripts/private-registry/searchPrivateModules.ts (opens in a new tab)scripts/private-registry/searchPrivateProviders.ts (opens in a new tab)scripts/public-registry/getLatestModuleVersion.ts (opens in a new tab)scripts/public-registry/getLatestProviderVersion.ts (opens in a new tab)scripts/public-registry/getModuleDetails.ts (opens in a new tab)scripts/public-registry/getPolicyDetails.ts (opens in a new tab)scripts/public-registry/getProviderCapabilities.ts (opens in a new tab)scripts/public-registry/getProviderDetails.ts (opens in a new tab)scripts/public-registry/index.ts (opens in a new tab)scripts/public-registry/searchModules.ts (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/hashi-demo-lab-terraform-mcp-as-code-terraform-mcp-as-code:Terraform-Infrastructure-as-Codefrom terraform-mcp-as-code
Claude Code refuses to install this plugin
plugin.json: skills: Invalid input
Checked against Claude Code 2.1.332's install rules. The listing below is what the repository ships; Claude Code cannot install it as published.