Skip to content

Commit b401c86

Browse files
fix: Various Fixes (#2)
* tests: fix test mocks * fix: logic bug in file filter * precommit fixes * chore: update common dev * fix: input sanitaization for lists * fix: improve tool descriptions for better llm guidance * fix: enhance prompts * refactor: simplify search_modules interface and clean unused parameters - Remove namespace and provider parameters from search_modules tool - Server now uses configured namespace automatically - Remove unused provider and verified parameters from TerraformClient - Clean up LLM documentation to focus on actionable guidance - Update all tests to match simplified interface This reduces complexity for LLMs while maintaining all functionality through server-side configuration. * feat: add download count sorting to search results - Always fetch 100 results internally for better sorting accuracy - Sort modules by download count in descending order (highest first) - Return user's requested limit from the sorted results - Add comprehensive tests for download sorting functionality * docs: update readme
1 parent 612148f commit b401c86

25 files changed

+1323
-342
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,4 @@ dmypy.json
120120
.env
121121

122122
.bob/
123-
.bobignore
123+
.bobignore

.secrets.baseline

Lines changed: 85 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-08-11T08:44:39Z",
6+
"generated_at": "2025-09-24T11:38:27Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -77,13 +77,93 @@
7777
}
7878
],
7979
"results": {
80-
"README.md": [
80+
"test/test_get_content.py": [
8181
{
82-
"hashed_secret": "ff9ee043d85595eb255c05dfe32ece02a53efbb2",
82+
"hashed_secret": "887c04fb792699ceb6b29d9d4cb017d2854f8314",
8383
"is_secret": false,
8484
"is_verified": false,
85-
"line_number": 65,
86-
"type": "Secret Keyword",
85+
"line_number": 44,
86+
"type": "Base64 High Entropy String",
87+
"verified_result": null
88+
},
89+
{
90+
"hashed_secret": "f2fc748e82e02ed29053ddbb52f241a7e10e9a4f",
91+
"is_secret": false,
92+
"is_verified": false,
93+
"line_number": 45,
94+
"type": "Base64 High Entropy String",
95+
"verified_result": null
96+
},
97+
{
98+
"hashed_secret": "52a3342b7890ccda14efd7f947fa9ee6fda62529",
99+
"is_secret": false,
100+
"is_verified": false,
101+
"line_number": 62,
102+
"type": "Base64 High Entropy String",
103+
"verified_result": null
104+
},
105+
{
106+
"hashed_secret": "67e1c41f7a21c2c3e818b0192a161092ab074b69",
107+
"is_secret": false,
108+
"is_verified": false,
109+
"line_number": 63,
110+
"type": "Base64 High Entropy String",
111+
"verified_result": null
112+
},
113+
{
114+
"hashed_secret": "5eb844612e49e7ae88d1297b833d1057f4dddcb8",
115+
"is_secret": false,
116+
"is_verified": false,
117+
"line_number": 80,
118+
"type": "Base64 High Entropy String",
119+
"verified_result": null
120+
},
121+
{
122+
"hashed_secret": "462c772756a6e7e0f4c042b643072166fe491e80",
123+
"is_secret": false,
124+
"is_verified": false,
125+
"line_number": 232,
126+
"type": "Base64 High Entropy String",
127+
"verified_result": null
128+
},
129+
{
130+
"hashed_secret": "6aee17ecbbef021e3e8e9529facc4fa044180b64",
131+
"is_secret": false,
132+
"is_verified": false,
133+
"line_number": 284,
134+
"type": "Base64 High Entropy String",
135+
"verified_result": null
136+
},
137+
{
138+
"hashed_secret": "f10ba892b2ef72888d523de9812f53860cb752b5",
139+
"is_secret": false,
140+
"is_verified": false,
141+
"line_number": 300,
142+
"type": "Base64 High Entropy String",
143+
"verified_result": null
144+
},
145+
{
146+
"hashed_secret": "8744edae886af9ba92b6394b0b8820c228fecbcf",
147+
"is_secret": false,
148+
"is_verified": false,
149+
"line_number": 687,
150+
"type": "Base64 High Entropy String",
151+
"verified_result": null
152+
},
153+
{
154+
"hashed_secret": "ccd9fa3711ccbf21e2951d7443fcb0c53b651eb9",
155+
"is_secret": false,
156+
"is_verified": false,
157+
"line_number": 695,
158+
"type": "Base64 High Entropy String",
159+
"verified_result": null
160+
},
161+
{
162+
"hashed_secret": "0de58b3d996020b8925e18e91bd571cf25cb7fd8",
163+
"is_secret": false,
164+
"is_verified": false,
165+
"line_number": 703,
166+
"type": "Base64 High Entropy String",
87167
"verified_result": null
88168
}
89169
]

README.md

Lines changed: 140 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ Get started with TIM-MCP in Claude Desktop in under 2 minutes:
1616
```
1717

1818
2. **Add to Claude Desktop** - Copy this configuration to `~/Library/Application Support/Claude/claude_desktop_config.json`:
19+
```json
20+
{
21+
"mcpServers": {
22+
"tim-terraform": {
23+
"command": "uv",
24+
"args": ["run", "--from", "git+https://github.com/terraform-ibm-modules/tim-mcp.git", "tim-mcp"]
25+
}
26+
}
27+
}
28+
```
29+
30+
**Optional: Add GitHub Token** (recommended to avoid rate limits):
1931
```json
2032
{
2133
"mcpServers": {
@@ -71,7 +83,11 @@ uv run tim-mcp
7183

7284
### Environment Variables
7385

74-
- `GITHUB_TOKEN`: GitHub API token for accessing private repositories and avoiding rate limits
86+
- `GITHUB_TOKEN` (optional): GitHub personal access token
87+
- **When to use:** Recommended for frequent usage to avoid GitHub API rate limits
88+
- **Not required for:** Basic functionality - the server works fine without it for light usage
89+
- **Permissions needed:** None (read-only access to public repositories)
90+
- **Create token at:** https://github.com/settings/tokens
7591
- `TIM_ALLOWED_NAMESPACES`: Comma-separated list of allowed module namespaces (default: `terraform-ibm-modules`)
7692
- `TIM_EXCLUDED_MODULES`: Comma-separated list of module IDs to exclude from search results
7793

@@ -83,8 +99,24 @@ TIM-MCP can be configured as an MCP server for use with Claude Desktop or other
8399

84100
This method downloads and runs TIM-MCP directly from the GitHub repository without requiring local installation.
85101

86-
Add this configuration to your Claude Desktop MCP settings (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
102+
**Basic Configuration** (works without GitHub token):
103+
```json
104+
{
105+
"mcpServers": {
106+
"tim-terraform": {
107+
"command": "uv",
108+
"args": [
109+
"run",
110+
"--from",
111+
"git+https://github.com/terraform-ibm-modules/tim-mcp.git",
112+
"tim-mcp"
113+
]
114+
}
115+
}
116+
}
117+
```
87118

119+
**Enhanced Configuration** (with GitHub token to avoid rate limits):
88120
```json
89121
{
90122
"mcpServers": {
@@ -112,6 +144,23 @@ Add this configuration to your Claude Desktop MCP settings (`~/Library/Applicati
112144

113145
This method is ideal for development and testing, using your local clone of the repository.
114146

147+
**Basic Configuration:**
148+
```json
149+
{
150+
"mcpServers": {
151+
"tim-terraform": {
152+
"command": "uv",
153+
"args": [
154+
"run",
155+
"tim-mcp"
156+
],
157+
"cwd": "/path/to/your/tim-mcp"
158+
}
159+
}
160+
}
161+
```
162+
163+
**With GitHub Token** (recommended for heavy usage):
115164
```json
116165
{
117166
"mcpServers": {
@@ -146,12 +195,96 @@ Test the connection by asking Claude: "What IBM Cloud Terraform modules are avai
146195

147196
## Available MCP Tools
148197

149-
Once configured, TIM-MCP provides these tools to Claude:
198+
Once configured, TIM-MCP provides these tools to Claude for comprehensive Terraform module discovery and implementation:
199+
200+
### 1. `search_modules`
201+
**Search Terraform Registry for IBM Cloud modules with intelligent result optimization.**
202+
203+
**Purpose:** Find relevant modules based on search terms, with results optimized by download count for better quality.
204+
205+
**Inputs:**
206+
- `query` (string, required): Specific search term (e.g., "vpc", "kubernetes", "security")
207+
- `limit` (integer, optional): Maximum results to return (default: 10, range: 1-100)
208+
209+
**Output:** JSON formatted search results including:
210+
- Module identifiers and basic metadata
211+
- Download counts and verification status
212+
- Descriptions and source repository URLs
213+
- Publication dates and version information
214+
215+
**Usage Examples:**
216+
- Quick reference: `limit=3` for "I need a VPC module"
217+
- Exploring options: `limit=10-15` (default) for comparing alternatives
218+
- Comprehensive research: `limit=20+` for thorough analysis
219+
220+
### 2. `get_module_details`
221+
**Retrieve structured module metadata from Terraform Registry - lightweight module interface overview.**
222+
223+
**Purpose:** Get comprehensive module interface information including inputs, outputs, and dependencies without fetching source code.
224+
225+
**Inputs:**
226+
- `module_id` (string, required): Full module identifier (e.g., "terraform-ibm-modules/vpc/ibm")
227+
- `version` (string, optional): Specific version or "latest" (default: "latest")
228+
229+
**Output:** Markdown formatted module details including:
230+
- Module description and documentation
231+
- Required and optional input variables with types, descriptions, and defaults
232+
- Available outputs with types and descriptions
233+
- Provider requirements and version constraints
234+
- Module dependencies and available versions
235+
236+
**When to Use:** First step after finding a module to understand its interface - often sufficient to answer user questions without fetching implementation files.
237+
238+
### 3. `list_content`
239+
**Discover available paths in a module repository with README summaries.**
240+
241+
**Purpose:** Explore repository structure to understand available examples, submodules, and solutions before fetching specific content.
242+
243+
**Inputs:**
244+
- `module_id` (string, required): Full module identifier (e.g., "terraform-ibm-modules/vpc/ibm")
245+
- `version` (string, optional): Git tag/branch to scan (default: "latest")
246+
247+
**Output:** Markdown formatted content listing organized by category:
248+
- **Root Module:** Main terraform files, inputs/outputs definitions
249+
- **Examples:** Deployable examples showing module usage (ideal starting point)
250+
- **Submodules:** Reusable components within the module
251+
- **Solutions:** Complete architecture patterns for complex scenarios
252+
253+
**Usage Tips:** Use before `get_content` to select the most relevant path for your needs.
254+
255+
### 4. `get_content`
256+
**Retrieve source code, examples, and documentation from GitHub repositories with targeted content filtering.**
257+
258+
**Purpose:** Fetch actual implementation files, examples, and documentation with precise filtering to avoid large responses.
259+
260+
**Inputs:**
261+
- `module_id` (string, required): Full module identifier (e.g., "terraform-ibm-modules/vpc/ibm")
262+
- `path` (string, optional): Specific path - "" (root), "examples/basic", "modules/vpc", etc.
263+
- `include_files` (list[string], optional): Regex patterns for files to include
264+
- `exclude_files` (list[string], optional): Regex patterns for files to exclude
265+
- `include_readme` (boolean, optional): Include README.md for context (default: true)
266+
- `version` (string, optional): Git tag/branch to fetch from (default: "latest")
267+
268+
**Output:** Markdown formatted content with file contents, organized by:
269+
- File paths and content
270+
- File sizes for reference
271+
- Context from README files when requested
272+
273+
**Common Patterns:**
274+
- Input variables only: `include_files=["variables\\.tf$"]`
275+
- Basic example: `path="examples/basic", include_files=["main\\.tf$", "variables\\.tf$"]`
276+
- Complete module: `include_files=[".*\\.tf$"]`
277+
278+
## Tool Workflow
279+
280+
The tools are designed to work together in an efficient workflow:
281+
282+
1. **`search_modules`** → Find relevant modules
283+
2. **`get_module_details`** → Understand module interface (often sufficient)
284+
3. **`list_content`** → Explore repository structure if needed
285+
4. **`get_content`** → Fetch specific implementation details
150286

151-
1. **`search_modules`** - Search Terraform Registry for IBM Cloud modules
152-
2. **`get_module_details`** - Retrieve detailed module metadata and documentation
153-
3. **`list_content`** - Discover available files and structure in module repositories
154-
4. **`get_content`** - Fetch source code, examples, and documentation from GitHub
287+
This progressive approach minimizes API calls and provides context-aware information at each step.
155288

156289
## Troubleshooting
157290

examples/claude_desktop.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
}
1010
}
1111
}
12-
}
12+
}

examples/claude_desktop_simple.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
"env": {}
88
}
99
}
10-
}
10+
}

0 commit comments

Comments
 (0)