Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit ecacba4

Browse files
committed
Release v0.9.7: Enhanced Terraform Registry API Interactions and Response Handling
- Added comprehensive helper functions for standardized API responses - Implemented `createStandardResponse` for consistent response formatting - Added utility functions like `formatAsMarkdown`, `formatUrl`, and `addContextInfo` - Enhanced `resourceUsage` tool with more robust documentation retrieval - Improved error handling and fallback mechanisms for resource documentation - Added metadata generation with context and compatibility information - Updated tests to cover more edge cases and resource retrieval scenarios - Simplified documentation parsing and example generation logic - Added README.md update with testing section reference - Updated tests/setup.js to enable fetch mocking
1 parent 9e0ceea commit ecacba4

File tree

6 files changed

+976
-309
lines changed

6 files changed

+976
-309
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ To install and use this MCP server in Claude Desktop:
6060

6161
Alternatively, you can use `npx -y terraform-mcp-server` as a command.
6262

63+
## Testing
64+
65+
For information about testing this project, please see the [TESTS.md](TESTS.md) file.
66+
6367
## Tools
6468

6569
### 1. Provider Lookup

TESTS.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Terraform MCP Server Testing
2+
3+
This document provides information about the testing approach and available test scripts for the Terraform MCP Server.
4+
5+
## Test Scripts Overview
6+
7+
The project includes several test scripts for different purposes:
8+
9+
| Script | Description |
10+
|--------|-------------|
11+
| `test.sh` | Main test script that tests all tools with formatted output |
12+
| `test-simple.sh` | Simplified test script that doesn't require jq |
13+
| `test-resources.sh` | Minimal resource testing script focused on ResourceUsage handler |
14+
| `test-tool.sh` | Tests a specific tool interactively |
15+
| `test-server.js` | Starts a test server for manual testing |
16+
17+
## Running Jest Tests
18+
19+
The project uses Jest for unit tests. To run the tests:
20+
21+
```bash
22+
# Run all tests
23+
npm test
24+
25+
# Run specific tests
26+
npm test -- -t "resourceUsage"
27+
28+
# Run minimal resource tests
29+
npm test -- -t "minimal resource tests"
30+
```
31+
32+
## Resource Testing
33+
34+
The `test-resources.sh` script tests a minimal set of commonly used resources for the `resourceUsage` handler:
35+
36+
```bash
37+
# Run minimal test set
38+
run_test "aws" "aws_s3_bucket" "AWS S3 Bucket"
39+
run_test "google" "google_compute_instance" "Google Compute Instance"
40+
```
41+
42+
### Basic Usage
43+
44+
To run the resource test script:
45+
46+
```bash
47+
./test-resources.sh
48+
```
49+
50+
The output will show:
51+
- Which resources were tested
52+
- A simple content preview
53+
- A summary of passed and failed tests
54+
55+
## Integration with Jest Test Suite
56+
57+
The Jest test suite in `tests/tools/resourceUsage.test.ts` includes minimal resource tests:
58+
59+
```typescript
60+
// Minimal resource tests - testing just core providers
61+
describe("minimal resource tests", () => {
62+
test("should handle aws_s3_bucket resource", async () => {
63+
await testResourceFetch("aws", "aws_s3_bucket");
64+
});
65+
66+
test("should handle google_compute_instance resource", async () => {
67+
await testResourceFetch("google", "google_compute_instance");
68+
});
69+
});
70+
```
71+
72+
## Main Test Scripts
73+
74+
### test.sh
75+
76+
The main test script runs through all available tools with detailed output formatting.
77+
78+
Usage:
79+
```bash
80+
./test.sh
81+
```
82+
83+
### test-simple.sh
84+
85+
A simplified version of the main test script without dependencies on external tools like jq.
86+
87+
Usage:
88+
```bash
89+
./test-simple.sh
90+
```
91+
92+
### test-tool.sh
93+
94+
This script allows you to test a specific tool interactively.
95+
96+
Usage:
97+
```bash
98+
./test-tool.sh <tool-name>
99+
```
100+
101+
Example:
102+
```bash
103+
./test-tool.sh providerLookup
104+
```
105+
106+
## Troubleshooting
107+
108+
If tests fail, check:
109+
1. That the server builds correctly with `npm run build`
110+
2. Network connectivity to the Terraform Registry API
111+
3. Any console error messages in the output
112+
4. If using Jest tests, ensure dependencies are installed with `npm install`

0 commit comments

Comments
 (0)