Skip to main content

Multi-cloud MCP server for discovering and generating Terraform code from module catalogs

Project description

Terraform Modules MCP Server

A multi-cloud MCP server that lets AI assistants discover, understand, and generate Terraform code from module catalogs across AWS, Azure, and GCP.

What it does

  • Discover modules — list modules across all clouds with descriptions, dependencies, and costs
  • Understand wiring — see how modules connect (e.g., VPC outputs feed into EKS inputs)
  • Estimate costs — get per-module cost breakdowns by tier (dev/staging/prod)
  • Generate code — produce ready-to-use .tf files for single modules or full stacks

Quick start

Install via Claude Code

Add to your ~/.mcp.json (global) or .claude/mcp.json (per-project):

{
  "mcpServers": {
    "tf-modules": {
      "command": "uvx",
      "args": ["tf-mcp"],
      "env": {
        "TF_MODULES_AWS_DIR": "/path/to/your/aws-tf/modules",
        "TF_MODULES_AZURE_DIR": "/path/to/your/azure-tf/modules",
        "TF_MODULES_GCP_DIR": "/path/to/your/gcp-tf/modules"
      }
    }
  }
}

Only include the env entries for clouds you have modules for.

Install via pip

pip install tf-mcp

Run standalone

tf-mcp

Prerequisites

  • Python >= 3.11
  • One or more directories containing Terraform modules

Module directory layout

Point the server at directories containing Terraform modules. Each module should be a subdirectory with at least a main.tf:

your-modules-dir/
  vpc/
    main.tf
    variables.tf
    outputs.tf
  eks-cluster/
    main.tf
    variables.tf
    outputs.tf

The server auto-discovers all subdirectories containing a main.tf.

Configuration

Tell the server where your modules live using environment variables:

Variable Description
TF_MODULES_AWS_DIR Path to AWS modules/ directory
TF_MODULES_AZURE_DIR Path to Azure modules/ directory
TF_MODULES_GCP_DIR Path to GCP modules/ directory

If no env vars are set, the server looks for sibling repos in the default layout:

parent-dir/
  aws-tf/modules/
  azure-tf/modules/
  gcp-tf/modules/
  tf-mcp-server/        # this repo

Tools

Tool Description
list_modules List modules with optional cloud filter
get_module_details Full variable/output/cost reference for one module
get_module_dependencies Dependency graph and output-to-input wiring
estimate_costs Cost estimates for a set of modules by tier
generate_module_code Generate .tf for a single module
generate_stack_code Generate a complete multi-module stack with auto-wiring

Resources

URI Description
modules://catalog Full listing across all clouds
modules://{cloud}/catalog Listing for one cloud
modules://{cloud}/{name}/readme Module README.md
modules://{cloud}/{name}/examples Module examples/main.tf
modules://{cloud}/dependency-graph Text dependency graph
modules://conventions Terraform conventions

Development

git clone https://github.com/m-ujifusa/tf-mcp-server.git
cd tf-mcp-server
uv sync
uv run tf-mcp

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tf_mcp-0.3.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tf_mcp-0.3.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file tf_mcp-0.3.0.tar.gz.

File metadata

  • Download URL: tf_mcp-0.3.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tf_mcp-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d1b075322b405cb1c279e0a4f50d2f30f5075299d336edc485fee0da9892484c
MD5 bbfa712c8b2345efe792d2300ada858e
BLAKE2b-256 7f9e09ab4d65df2023272e36c6da5d0597b049f92f034156d9240f5b0f427202

See more details on using hashes here.

File details

Details for the file tf_mcp-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: tf_mcp-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tf_mcp-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 724cf7d26125d62d0c38edd074fb79d244ef6f58f872800ab3ade3bf3bd02001
MD5 b3c05c0f29e7c34c5592e91a243dd8e8
BLAKE2b-256 873c3a4a9e28639b998cd0912a22a84c908e3e1a415d86df5175335e661a7ed8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page