Terraform-MCP-Server
This project provides an MCP (Model Context Protocol) server that exposes Terraform infrastructure-as-code operations through natural language. It enables LLMs to execute Terraform commands and retrieve information about infrastructure without requiring specific command syntax knowledge.
# 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
Installation
- Clone the repository:
git clone https://github.com/yourusername/terraform-mcp-server.git
cd terraform-mcp-server
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\\\\Scripts\\\\activate
- Install dependencies:
pip install -r requirements.txt
- Optional: Install Graphviz for plan visualization:
- Windows: Download from Graphviz Download Page
- Linux:
sudo apt-get install graphviz - macOS:
brew install graphviz
Configuration
- Set up environment variables (optional):
export TERRAFORM_WORKSPACE="/path/to/terraform/workspace"
export LOG_LEVEL="INFO"
- Place your Terraform configuration files in the workspace directory.
Usage
- Start the MCP server:
python src/main.py
- 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
- Install development dependencies:
pip install -r requirements-dev.txt
- Run tests:
pytest
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
Recommend MCP Servers 💡
@upstash/mcp-server
An MCP server that enables natural language interaction with Upstash Developer APIs, allowing users to manage Redis databases, view usage, and perform other operations via MCP clients.
Ropz3/remote-mcp-server
A remote MCP server running on Cloudflare Workers with OAuth support, using SSE transport
edgeone-pages-mcp
An MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
@tiberriver256/mcp-server-azure-devops
An MCP server implementation for Azure DevOps, allowing AI assistants to interact with Azure DevOps APIs through a standardized protocol.
apisix-mcp
APISIX Model Context Protocol (MCP) server is used to bridge large language models (LLMs) with the APISIX Admin API.
mcp-teams-server
An MCP (Model Context Protocol) server implementation for Microsoft Teams integration, providing capabilities to read messages, create messages, reply to messages, mention members.