Skip to main content
Glama
jashkahar

Terraform MCP Assistant

by jashkahar

# Terraform MCP Assistant

A FastMCP-based server that provides natural language interface to Terraform operations. This assistant allows you to manage your infrastructure using simple English commands instead of remembering specific Terraform syntax.

Features

  • Natural language processing of Terraform commands

  • Execution plan visualization

  • State inspection and management

  • Infrastructure deployment and destruction

  • Configuration documentation

  • Automatic workspace validation

  • Error handling and formatted output

Related MCP server: mcp-server-terraform

Installation

  1. Clone the repository:

git clone https://github.com/yourusername/terraform-mcp-server.git
cd terraform-mcp-server
  1. Create and activate a virtual environment:

python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install dependencies:

pip install -r requirements.txt
  1. Optional: Install Graphviz for plan visualization:

Configuration

  1. Set up environment variables (optional):

export TERRAFORM_WORKSPACE="/path/to/terraform/workspace"
export LOG_LEVEL="INFO"
  1. Place your Terraform configuration files in the workspace directory.

Usage

  1. Start the MCP server:

python src/main.py
  1. Example commands:

  • "Initialize the Terraform workspace"

  • "What will change if I apply?"

  • "Show me the current state"

  • "Apply the configuration"

  • "List all resources"

  • "Destroy the infrastructure"

Project Structure

terraform-mcp-assistant/
├── docs/                  # Documentation
├── examples/             # Example Terraform configurations
├── src/                  # Source code
│   ├── handlers/        # Command handlers
│   ├── main.py         # Entry point
│   └── config.py       # Configuration management
├── tests/               # Test files
├── .env                # Environment variables (not in VCS)
└── README.md           # This file

Development

  1. Install development dependencies:

pip install -r requirements-dev.txt
  1. Run tests:

pytest

Contributing

  1. Fork the repository

  2. Create a feature branch

  3. Commit your changes

  4. Push to the branch

  5. Create a Pull Request

Related MCP Connectors

Related MCP Servers