terraform-test-mcp

terraform-test-mcp

Generates structured prompts for Claude Code to create comprehensive Terraform test cases including unit, integration, and mock tests.

Category
访问服务器

README

Terraform Test Prompt Generator MCP

A lightweight MCP (Model Context Protocol) server that acts as an intelligent prompt generator for creating comprehensive Terraform test cases. This MCP generates detailed instructions for Claude Code to analyze Terraform infrastructure and create thorough test suites.

Purpose

This MCP serves as a prompt generator only - it does not create files or perform infrastructure analysis. Instead, it:

  1. Validates Terraform folder paths to ensure they contain .tf files
  2. Loads comprehensive testing guidelines from template files
  3. Generates structured prompts for Claude Code to process
  4. Returns detailed instructions for test case generation

Architecture

User Request → MCP Prompt Generator → Claude Code → Test Files
     ↓                ↓                    ↓           ↓
   Folder Path    Validates Path    Reads Terraform  Creates Tests
                 Loads Template     Analyzes Code    Writes Files
                 Returns Prompt     Follows Guide    In tests/

Quick Start

1. Install Dependencies

cd /path/to/terraform-test-mcp
pip install -e .

2. Test CLI Mode

python main.py cli /path/to/your/terraform/project

3. Configure with Claude Code

Add to your Claude Code MCP configuration:

{
  "mcpServers": {
    "terraform-test-mcp": {
      "command": "python",
      "args": ["/path/to/terraform-test-mcp/main.py"],
      "cwd": "/path/to/terraform-test-mcp"
    }
  }
}

Available Tools

generate_test_prompt

The single MCP tool that generates comprehensive testing prompts.

Parameters:

  • folder_path (string): Path to Terraform project folder

Returns:

  • Detailed prompt for Claude Code to generate test cases
  • Instructions for unit, integration, and mock tests
  • Guidelines for documentation and coverage reports

Example Usage:

# In Claude Code, this will be called automatically when you use the MCP
result = await generate_test_prompt("/path/to/terraform/project")

How It Works

  1. Path Validation: Verifies the folder exists and contains .tf files
  2. Template Loading: Loads comprehensive testing guidelines from prompt_template.md
  3. Prompt Generation: Creates structured instructions for Claude Code
  4. Return Instructions: Provides detailed guidance for:
    • Infrastructure analysis
    • Unit test creation with mocks
    • Integration test creation with real providers
    • Mock test creation with overrides
    • Documentation and coverage reports

Example Workflow

  1. User: "Generate test cases for my Terraform infrastructure in /infra"
  2. MCP: Validates path, loads template, generates comprehensive prompt
  3. Claude Code: Receives prompt, reads Terraform files, analyzes infrastructure
  4. Claude Code: Creates unit, integration, mock tests plus documentation
  5. Claude Code: Writes all files to /infra/tests/ directory

File Structure

terraform-test-mcp/
├── main.py                 # Main MCP server with single tool
├── prompt_template.md      # Comprehensive testing guidelines
├── README.md              # This file
├── pyproject.toml         # Project dependencies
└── logs/                  # Logging output

Key Features

Lightweight: Single tool, no file operations ✅ Intelligent: Comprehensive testing guidelines ✅ Flexible: Works with any Terraform project structure ✅ Structured: Clear instructions for Claude Code ✅ Complete: Covers all test types and documentation

Troubleshooting

MCP Not Responding

  • Check that Python dependencies are installed
  • Verify the path in Claude Code configuration
  • Check logs in the logs/ directory

Invalid Folder Path

  • Ensure the folder exists and contains .tf files
  • Check folder permissions
  • Use absolute paths when possible

Template Loading Issues

  • Verify prompt_template.md exists in the project root
  • Check file permissions and encoding

Development

To modify the prompt template:

  1. Edit prompt_template.md with new testing guidelines
  2. Restart the MCP server
  3. Test with CLI mode: python main.py cli /test/folder

Logging

The MCP logs to both console and /tmp/terraform-test-mcp.log for debugging purposes.


Note: This MCP is designed to work with Claude Code for the actual file creation and infrastructure analysis. It serves purely as an intelligent prompt generator to ensure comprehensive test coverage.


Remove the mcp

claude mcp remove terraform-test-mcp

Add the mcp

claude mcp add terraform-test-mcp python3 /Users/<folder>/terraform-test-mcp/main.py

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选