mcp-terraform mcp

v1.0.1 · MCP Tool · devops · registry.pascalai.org

HashiCorp Terraform CLI wrapper — init, plan, apply, destroy, show, output, fmt, state and workspace operations. Requires terraform binary in PATH.

terraformiacinfrastructuredevopscloudhashicorp

Input Parameters

ParameterTypeDescription
operationrequired string Operation to perform. One of: init, validate, plan, apply, destroy, show, output, fmt, state_list, state_show, workspace_list, workspace_select.
workdirrequired string Working directory containing .tf files (absolute path).
planFileoptional string Plan output file path (for plan -out= and apply with saved plan).
resourceoptional string Resource address for state_show (e.g. aws_instance.example).
workspaceoptional string Workspace name for workspace_select.
varsoptional string Extra variables as -var key=val pairs, comma-separated e.g. region=us-east-1,env=prod.
varFileoptional string Path to .tfvars file.
targetoptional string Target resource for plan/apply/destroy (-target=).
autoApproveoptional boolean Auto-approve for apply/destroy (default: true). Default: True.
checkoptional boolean Check mode for fmt — only reports diffs (default: false). Default: False.
timeoutoptional integer Command timeout in seconds (default: 300). Default: 300.

Output Fields

FieldTypeDescription
ok boolean
output string
exit_code integer
timeout boolean
error string

Examples

Plan infrastructure changes

// Input
{
  "operation": "plan",
  "workdir": "/infra/prod",
  "varFile": "prod.tfvars"
}

// Output
{
  "ok": true,
  "output": "Plan: 2 to add, 1 to change, 0 to destroy."
}

List state resources

// Input
{
  "operation": "state_list",
  "workdir": "/infra/prod"
}

// Output
{
  "ok": true,
  "output": "aws_instance.web\naws_s3_bucket.app"
}

Install & Discovery

Install

ppm install mcp-terraform

Get JSON Schema

GET /v1/packages/mcp-terraform/1.0.1/schema

Discover by keyword

GET /v1/mcp/discover?q=terraform
Discovery hint: Install with ppm install mcp-terraform or invoke remotely via POST /v1/invoke/mcp-terraform on the MCP Service.

PascalAI Usage

uses toolslib;
var Tool := LoadTool('mcp-terraform');
var R := Tool.Call(JsonObj(['operation','plan','workdir','/infra/prod']));
Writeln(R.ToJSON);