Testing Terraform Best Practices MCP Server
March 10, 2026 ยท View on GitHub
This document describes repeatable tests for the Terraform Best Practices MCP server.
Dependencies for Testing
- Node.js
>=24.0.0 - npm
- Optional CLIs for tool-backed checks:
tflintcheckovtrivykicsinfracost
Prerequisites
-
Build the server:
npm run build -
Reload VS Code so MCP config is reloaded:
Cmd+Shift+P->Developer: Reload Window
Copilot Chat Validation
Use your configured server alias in Copilot Chat (for example @tf-best-practices; aliases are user-configurable).
Test 1: Analyze Terraform code quality
Analyze Terraform code for modularity issues and suggest refactoring options.
Expected: Structured findings for module boundaries, naming consistency, and maintainability.
Test 2: Generate cost report
Generate a Terraform cost report and highlight optimization opportunities.
Expected: Cost-oriented summary with actionable optimization recommendations.
Test 3: Security hardening guidance
Suggest security hardening actions for Terraform code handling IAM, networking, and secrets.
Expected: Prioritized security recommendations and risk categories.
Test 4: Compliance summary
Generate a compliance summary from recent Terraform scan results.
Expected: Consolidated compliance output with pass/fail style categorization.
Test 5: Architecture recommendation
Suggest a Terraform architecture for multi-environment and multi-region deployment.
Expected: Architecture pattern recommendation with tradeoffs.
Test 6: State management analysis
Analyze Terraform state management and suggest backend/locking improvements.
Expected: State safety findings around remote state, locking, and team workflows.
Unit Tests
Run the test suite:
npm test
Run tests with coverage:
npm run test:coverage
Lint and Build Validation
npm run lint
npm run build
Troubleshooting
Tool binary not found
- Ensure required CLI tools are installed and available in
PATH - Re-run with optional tools removed from the request to validate core server behavior
Server not visible in Copilot Chat
- Verify
.vscode/mcp.jsonexists - Reload VS Code window
- Check
Output->MCP Serversfor startup errors
Build failures
- Reinstall dependencies:
npm install - Re-run checks:
npm run check - Rebuild:
npm run build
MegaLinter failures
- Review
megalinter-reports/artifacts for detailed findings - Fix reported markdown, yaml, spelling, or TypeScript issues
- Re-run locally (if configured):
npx mega-linter-runner