Skip to content

Commit 6199218

Browse files
committed
refactor: update find_files method to return a list of file paths instead of a dictionary
1 parent 3fb9afd commit 6199218

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

src/code_index_mcp/server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import logging
1414
from contextlib import asynccontextmanager
1515
from dataclasses import dataclass
16-
from typing import AsyncIterator, Dict, Any, Optional
16+
from typing import AsyncIterator, Dict, Any, Optional, List
1717

1818
# Third-party imports
1919
from mcp import types
@@ -185,8 +185,8 @@ def search_code_advanced(
185185
)
186186

187187
@mcp.tool()
188-
@handle_mcp_tool_errors(return_type='dict')
189-
def find_files(pattern: str, ctx: Context) -> Dict[str, Any]:
188+
@handle_mcp_tool_errors(return_type='list')
189+
def find_files(pattern: str, ctx: Context) -> List[str]:
190190
"""
191191
Find files matching a glob pattern using pre-built file index.
192192
@@ -206,7 +206,7 @@ def find_files(pattern: str, ctx: Context) -> Dict[str, Any]:
206206
pattern: Glob pattern to match files (e.g., "*.py", "test_*.js", "README.md")
207207
208208
Returns:
209-
Dictionary with files list and status information
209+
List of file paths matching the pattern
210210
"""
211211
return FileDiscoveryService(ctx).find_files(pattern)
212212

src/code_index_mcp/services/file_discovery_service.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, ctx):
3737
super().__init__(ctx)
3838
self._matcher_tool = FileMatchingTool()
3939

40-
def find_files(self, pattern: str, max_results: Optional[int] = None) -> Dict[str, Any]:
40+
def find_files(self, pattern: str, max_results: Optional[int] = None) -> List[str]:
4141
"""
4242
Find files matching the given pattern using intelligent discovery.
4343
@@ -50,7 +50,7 @@ def find_files(self, pattern: str, max_results: Optional[int] = None) -> Dict[st
5050
max_results: Maximum number of results to return (None for no limit)
5151
5252
Returns:
53-
Dictionary with discovery results and metadata
53+
List of file paths matching the pattern
5454
5555
Raises:
5656
ValueError: If pattern is invalid or project not set up
@@ -282,21 +282,14 @@ def _gather_discovery_metadata(self, all_files, matched_files, limited_files, pa
282282
'original_pattern': pattern
283283
}
284284

285-
def _format_discovery_result(self, discovery_result: FileDiscoveryResult) -> Dict[str, Any]:
285+
def _format_discovery_result(self, discovery_result: FileDiscoveryResult) -> List[str]:
286286
"""
287287
Format the discovery result according to business requirements.
288288
289289
Args:
290290
discovery_result: Raw discovery result
291291
292292
Returns:
293-
Formatted result dictionary for MCP response
293+
Simple list of file paths
294294
"""
295-
return {
296-
'files': discovery_result.files,
297-
'total': discovery_result.total_count,
298-
'pattern': discovery_result.pattern_used,
299-
'strategy': discovery_result.search_strategy,
300-
'metadata': discovery_result.metadata,
301-
'status': 'success'
302-
}
295+
return discovery_result.files

0 commit comments

Comments
 (0)