terraform-test-mcp
Generates structured prompts for Claude Code to analyze Terraform infrastructure and create comprehensive test suites including unit, integration, and mock tests, along with documentation and coverage reports.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@terraform-test-mcpGenerate test cases for the Terraform infrastructure in /terraform/projects/webapp"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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/project3. 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.mdPrompt 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 outputKey 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 rootCheck file permissions and encoding
Development
To modify the prompt template:
Edit
prompt_template.mdwith new testing guidelinesRestart 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//terraform-test-mcp/main.py
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/dharani-sowndharya/terraform-test-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server