terraform-test-mcp
Generates structured prompts for Claude Code to create comprehensive Terraform test cases including unit, integration, and mock tests.
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:
- Validates Terraform folder paths to ensure they contain .tf files
- Loads comprehensive testing guidelines from template files
- Generates structured prompts for Claude Code to process
- 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
- Path Validation: Verifies the folder exists and contains .tf files
- Template Loading: Loads comprehensive testing guidelines from
prompt_template.md - Prompt Generation: Creates structured instructions for Claude Code
- 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
- User: "Generate test cases for my Terraform infrastructure in
/infra" - MCP: Validates path, loads template, generates comprehensive prompt
- Claude Code: Receives prompt, reads Terraform files, analyzes infrastructure
- Claude Code: Creates unit, integration, mock tests plus documentation
- 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.mdexists in the project root - Check file permissions and encoding
Development
To modify the prompt template:
- Edit
prompt_template.mdwith new testing guidelines - Restart the MCP server
- 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
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.