Skip to content

Commit 9101c12

Browse files
committed
docs: Update tool count to 59, add depth limit to discover_files
- Update MCP_IMPROVEMENTS.md to reflect 59 tools (was 55) - Mark implemented tools in potential tools table - Add MAX_DISCOVERY_DEPTH (20) to prevent excessive recursion - Track depth in discover_files stack for safety Addresses CodeRabbit review comments
1 parent 4f001f4 commit 9101c12

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

docs/MCP_IMPROVEMENTS.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This document outlines potential improvements to make the Context Engine MCP Ser
55
## Current Implementation Status
66

77
### ✅ Fully Implemented
8-
- **Tools** - All 55 tools for retrieval, indexing, memory, planning, review, navigation, and workspace analysis
8+
- **Tools** - All 59 tools for retrieval, indexing, memory, planning, review, navigation, and workspace analysis
99
- **JSON-RPC 2.0** - Full request/response/notification handling
1010
- **Stdio Transport** - Standard input/output for MCP clients
1111
- **HTTP Transport** - Axum-based HTTP server with SSE
@@ -156,26 +156,29 @@ Allow clients to cancel in-progress operations.
156156

157157
## Enhanced Tool Capabilities
158158

159-
### Current Tools (49)
159+
### Current Tools (59)
160160
- **Retrieval (6):** semantic_search, grep_search, file_search, etc.
161161
- **Index (5):** index_status, index_directory, clear_index, etc.
162162
- **Memory (4):** memory_store, memory_retrieve, memory_list, memory_delete
163163
- **Planning (20):** create_review, analyze_changes, etc.
164164
- **Review (14):** review_code, suggest_fixes, etc.
165+
- **Navigation (3):** find_references, go_to_definition, diff_files
166+
- **Workspace (7):** workspace_stats, git_status, extract_symbols, git_blame, git_log, dependency_graph, file_outline
165167

166168
### Potential New Tools
167169

168-
| Tool | Description | Priority |
169-
|------|-------------|----------|
170-
| `diff_files` | Compare two files | High |
171-
| `find_references` | Find all references to a symbol | High |
172-
| `go_to_definition` | Find definition of a symbol | High |
173-
| `call_hierarchy` | Show call graph for a function | Medium |
174-
| `type_hierarchy` | Show class/type inheritance | Medium |
175-
| `ast_query` | Query AST with tree-sitter | Medium |
176-
| `git_blame` | Show git blame for a file | Low |
177-
| `git_history` | Show commit history | Low |
178-
| `dependency_graph` | Show module dependencies | Low |
170+
| Tool | Description | Priority | Status |
171+
|------|-------------|----------|--------|
172+
| `diff_files` | Compare two files | High | ✅ Implemented |
173+
| `find_references` | Find all references to a symbol | High | ✅ Implemented |
174+
| `go_to_definition` | Find definition of a symbol | High | ✅ Implemented |
175+
| `call_hierarchy` | Show call graph for a function | Medium | 🔲 Planned |
176+
| `type_hierarchy` | Show class/type inheritance | Medium | 🔲 Planned |
177+
| `ast_query` | Query AST with tree-sitter | Medium | 🔲 Planned |
178+
| `git_blame` | Show git blame for a file | Low | ✅ Implemented |
179+
| `git_history` | Show commit history | Low | ✅ Implemented (git_log) |
180+
| `dependency_graph` | Show module dependencies | Low | ✅ Implemented |
181+
| `file_outline` | Get structured outline of symbols | Low | ✅ Implemented |
179182

180183
---
181184

src/mcp/resources.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,10 @@ impl ResourceRegistry {
262262
Ok(())
263263
}
264264

265-
/// Discover files in directory (with pagination).
265+
/// Maximum recursion depth for file discovery to prevent excessive traversal.
266+
const MAX_DISCOVERY_DEPTH: usize = 20;
267+
268+
/// Discover files in directory (with pagination and depth limit).
266269
async fn discover_files(
267270
&self,
268271
dir: &std::path::Path,
@@ -272,14 +275,20 @@ impl ResourceRegistry {
272275
use tokio::fs::read_dir;
273276

274277
let mut files = Vec::new();
275-
let mut stack = vec![dir.to_path_buf()];
278+
// Stack contains (path, depth) tuples
279+
let mut stack = vec![(dir.to_path_buf(), 0usize)];
276280
let mut past_cursor = after.is_none();
277281

278-
while let Some(current) = stack.pop() {
282+
while let Some((current, depth)) = stack.pop() {
279283
if files.len() >= limit {
280284
break;
281285
}
282286

287+
// Skip if we've exceeded the maximum depth
288+
if depth > Self::MAX_DISCOVERY_DEPTH {
289+
continue;
290+
}
291+
283292
let mut entries = match read_dir(&current).await {
284293
Ok(e) => e,
285294
Err(_) => continue,
@@ -299,7 +308,7 @@ impl ResourceRegistry {
299308
}
300309

301310
if path.is_dir() {
302-
stack.push(path);
311+
stack.push((path, depth + 1));
303312
} else if path.is_file() {
304313
let relative = path
305314
.strip_prefix(dir)

0 commit comments

Comments
 (0)