A Terraform MCP server allowing AI assistants to manage and operate Terraform environments, enabling reading configurations, analyzing plans, applying configurations, and managing Terraform state.
Unleash the power of Large Language Models (LLMs) to manage and automate your Terraform infrastructure with tfmcp
, the Terraform Model Context Protocol tool. This innovative tool bridges the gap between AI and Infrastructure as Code (IaC), enabling seamless integration and intelligent automation of your Terraform environments.
Witness tfmcp
in action, seamlessly interacting with Claude Desktop to manage Terraform configurations:
This demo showcases the potential of LLMs to:
The first stable release of tfmcp
is now available on Crates.io! Install it effortlessly using Cargo:
cargo install tfmcp
Clone the repository:
git clone https://github.com/nwiizo/tfmcp cd tfmcp
Build and install:
cargo install --path .
cargo install tfmcp
$ tfmcp --help โจ A CLI tool to manage Terraform configurations and operate Terraform through the Model Context Protocol (MCP). Usage: tfmcp [OPTIONS] [COMMAND] Commands: mcp Launch tfmcp as an MCP server analyze Analyze Terraform configurations help Print this message or the help of the given subcommand(s) Options: -c, --config <PATH> Path to the configuration file -d, --dir <PATH> Terraform project directory -V, --version Print version -h, --help Print help
Install tfmcp:
cargo install tfmcp
Locate tfmcp Executable:
which tfmcp
Configure Claude Desktop: Add the following configuration to ~/Library/Application\ Support/Claude/claude_desktop_config.json
:
{ "mcpServers": { "tfmcp": { "command": "/path/to/your/tfmcp", // Replace with the actual path from step 2 "args": ["mcp"], "env": { "HOME": "/Users/yourusername", // Replace with your username "PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin", "TERRAFORM_DIR": "/path/to/your/terraform/project" // Optional: specify your Terraform project } } } }
Restart Claude Desktop: Enable the tfmcp
tool within Claude Desktop.
Automatic Project Creation: tfmcp
will automatically create a sample Terraform project in ~/terraform
if one doesn't exist, allowing Claude to immediately interact with Terraform. This sample project is based on the examples in the example/demo
directory of this repository.
Log Location: The tfmcp
server logs are located at ~/Library/Logs/Claude/mcp-server-tfmcp.log
.
Common Issues:
tfmcp
executable in your configuration.tfmcp
automatically creates a sample project if none is found.resources/list
and prompts/list
methods.TERRAFORM_DIR
: Specifies a custom Terraform project directory. Defaults to ~/terraform
if not set. The project directory can also be changed at runtime using the set_terraform_directory
tool.TFMCP_LOG_LEVEL
: Controls logging verbosity (debug
, info
, warn
, error
).TFMCP_DEMO_MODE
: Enables demo mode with enhanced safety features (true
).tfmcp
executes Terraform commands, potentially modifying infrastructure.Contributions are highly encouraged!
git checkout -b feature/amazing-feature
).git commit -m 'Add some amazing feature'
).git push origin feature/amazing-feature
).resources/list
, prompts/list
).๐ A gateway demo for MCP SSE Server.
๐ โ๏ธ A lightweight mcp server that tells you exactly what time is it.
#๏ธโฃ ๐ A C# SDK for building MCP servers on .NET 9 with NativeAOT compatibility โก ๐
โ Java SDK for building MCP servers using Quarkus.