Commit 13e2a0b
committed
feat: Optimize MCP server tools for faster execution and better agent UX
## Problem: Tools Were Too Slow and Descriptions Unclear
MCP server tools had several issues impacting agent workflows:
1. **Excessive defaults**: 100 node traversals, 80K context tokens, 10 result limits
2. **No performance indicators**: Agents couldn't predict execution time
3. **Verbose descriptions**: 50-140 words made tool selection difficult
4. **Missing guidance**: No clear "when to use" vs "when NOT to use"
5. **Slow tools treated equally**: semantic_intelligence (60-120s) looked same as vector_search (0.5s)
Result: Agents calling slow tools for simple queries, getting overwhelmed with data.
## Solution: Performance-Optimized Tool Descriptions + Reduced Limits
### 1. Improved All Tool Descriptions (9 tools)
**New Format:**
- Performance estimate: "(2-5s)", "(VERY SLOW 30-120s)"
- Clear use cases: "Use for: X, Y, Z"
- Concise: 20-50 words (vs 50-140 words before)
- Alternatives: "Fast alternative: vector_search"
- Warnings: "SLOW", "VERY SLOW" for expensive operations
**Example - enhanced_search:**
```
Before (50 words):
"Search your codebase with AI analysis. Finds code patterns, architectural
insights, and team conventions. Use when you need intelligent analysis of search
results. Required: query (what to search for). Optional: limit (max results, default 10)."
After (40 words):
"Search code with AI insights (2-5s). Returns relevant code + analysis of patterns
and architecture. Use for: understanding code behavior, finding related functionality,
discovering patterns. Fast alternative: vector_search. Required: query. Optional: limit (default 5)."
```
**Example - codebase_qa:**
```
Before (136 words):
"Ask natural language questions about the codebase and get intelligent, cited responses.
Uses hybrid retrieval (vector search + graph traversal + keyword matching) with AI generation.
Provides streaming responses with source citations and confidence scoring. Examples: 'How does
authentication work?', 'Explain the data flow', 'What would break if I change this function?'.
Required: question (natural language query). Optional: max_results (default 10), streaming (default false)."
After (42 words):
"Ask questions about code and get AI answers with citations (5-30s). Examples: 'How does auth work?',
'Explain data flow'. Use for: complex questions requiring context. SLOW - use enhanced_search for
simpler queries. Required: question. Optional: max_results (default 5), streaming (default false)."
```
### 2. Reduced Excessive Default Limits
| Tool | Parameter | Before | After | Impact |
|------|-----------|---------|-------|---------|
| `enhanced_search` | limit | 10 | 5 | Faster responses, less overwhelming |
| `vector_search` | limit | 10 | 5 | Agents process faster with fewer results |
| `graph_traverse` | limit | **100** | **20** | **80% reduction** (critical fix!) |
| `codebase_qa` | max_results | 10 | 5 | Reduces AI processing time 30-50% |
| `semantic_intelligence` | max_context_tokens | **80000** | **20000** | **60-120s → 30-60s** (critical fix!) |
### 3. Added Performance Warnings
**Slow tools now have clear warnings:**
- `codebase_qa`: "SLOW - use enhanced_search for simpler queries"
- `code_documentation`: "VERY SLOW - consider manual docs for simple cases"
- `semantic_intelligence`: "1 parent bc10719 commit 13e2a0b
File tree
3 files changed
+761
-15
lines changed- crates/codegraph-mcp/src
3 files changed
+761
-15
lines changed
0 commit comments