@plugix/mcp-terraform
v0.1.0
Published
MCP Server for Terraform - Infrastructure as Code management
Maintainers
Readme
@plugix/mcp-terraform
MCP server for Terraform infrastructure management.
Features
- get_state - Get current terraform state summary
- list_resources - List all managed resources
- plan - Preview infrastructure changes
- apply - Apply changes (with confirmation)
- validate - Validate configuration files
- format - Check or fix file formatting
- get_outputs - Get output values
- init - Initialize terraform working directory
- show_resource - Show detailed resource information
Installation
npm install @plugix/mcp-terraformOr run directly:
npx @plugix/mcp-terraformPrerequisites
Terraform CLI must be installed and available in PATH:
# macOS
brew install terraform
# Linux (Ubuntu/Debian)
sudo apt-get install terraform
# Or download from https://www.terraform.io/downloadsConfiguration
Set environment variables:
# Plugix API connection
API_URL=wss://api.plugix.ai
API_TOKEN=plx_live_your_token_here
# Terraform settings
TERRAFORM_DIR=/path/to/your/terraform/project # Default: current directory
TERRAFORM_PATH=terraform # Default: terraformUsage
Development
npm run devProduction
npm run build
npm startDocker
docker build -t plugix-mcp-terraform .
docker run --env-file .env -v /path/to/terraform:/workspace plugix-mcp-terraformClaude Desktop Integration
Add to claude_desktop_config.json:
{
"mcpServers": {
"terraform": {
"command": "npx",
"args": ["@plugix/mcp-terraform"],
"env": {
"API_URL": "wss://api.plugix.ai",
"API_TOKEN": "plx_live_your_token",
"TERRAFORM_DIR": "/path/to/terraform/project"
}
}
}
}Tools Reference
get_state
Get current terraform state summary including all managed resources.
Parameters: None
Example:
{
"name": "get_state",
"arguments": {}
}list_resources
List all resources currently managed by terraform state.
Parameters: None
plan
Run terraform plan to preview changes.
Parameters:
| Name | Type | Description | |------|------|-------------| | target | string | Resource address to target (e.g., aws_instance.example) | | varFile | string | Path to terraform.tfvars file | | destroy | boolean | Create a destroy plan instead |
Example:
{
"name": "plan",
"arguments": {
"target": "aws_instance.web"
}
}apply
Apply terraform changes. Requires confirmation.
Parameters:
| Name | Type | Required | Description |
|------|------|----------|-------------|
| target | string | No | Resource address to target |
| varFile | string | No | Path to terraform.tfvars file |
| confirmed | boolean | Yes | Must be true to apply |
Example:
{
"name": "apply",
"arguments": {
"confirmed": true
}
}validate
Validate terraform configuration files.
Parameters: None
Example:
{
"name": "validate",
"arguments": {}
}format
Check or fix terraform file formatting.
Parameters:
| Name | Type | Description | |------|------|-------------| | check | boolean | Only check formatting without changes | | recursive | boolean | Format files in subdirectories |
Example:
{
"name": "format",
"arguments": {
"check": true,
"recursive": true
}
}get_outputs
Get all terraform output values.
Parameters: None
init
Initialize terraform working directory.
Parameters:
| Name | Type | Description | |------|------|-------------| | upgrade | boolean | Upgrade provider versions | | reconfigure | boolean | Reconfigure backend |
Example:
{
"name": "init",
"arguments": {
"upgrade": true
}
}show_resource
Show detailed information about a specific resource.
Parameters:
| Name | Type | Required | Description | |------|------|----------|-------------| | address | string | Yes | Resource address (e.g., aws_instance.example) |
Example:
{
"name": "show_resource",
"arguments": {
"address": "aws_instance.web"
}
}Workflow Examples
Check Infrastructure Status
1. list_resources -> See all managed resources
2. get_outputs -> Get output values
3. validate -> Check configuration is validMake Infrastructure Changes
1. plan -> Preview changes
2. apply (preview) -> Double-check with confirmed=false
3. apply -> Apply with confirmed=true
4. get_outputs -> Verify new outputsClean Up Infrastructure
1. plan (destroy) -> Preview destroy plan
2. apply -> Apply destroy with confirmed=trueSecurity Notes
- The MCP server executes terraform commands locally
- Terraform state files may contain sensitive data
- Use remote backends (S3, GCS, Terraform Cloud) for production
- Credentials are handled by terraform, not this MCP server
- Apply operations require explicit confirmation
Testing
npm testLicense
MIT
