MCPcopy Create free account
hub / github.com/JordanCoin/codemap / handleFindFile

Function handleFindFile

mcp/main.go:357–378  ·  view source on GitHub ↗
(ctx context.Context, req *mcp.CallToolRequest, input FindInput)

Source from the content-addressed store, hash-verified

355}
356
357func handleFindFile(ctx context.Context, req *mcp.CallToolRequest, input FindInput) (*mcp.CallToolResult, any, error) {
358 gitCache := scanner.NewGitIgnoreCache(input.Path)
359 files, err := scanner.ScanFiles(input.Path, gitCache, nil, nil)
360 if err != nil {
361 return errorResult("Scan error: " + err.Error()), nil, nil
362 }
363
364 // Filter files matching pattern (case-insensitive)
365 var matches []string
366 pattern := strings.ToLower(input.Pattern)
367 for _, f := range files {
368 if strings.Contains(strings.ToLower(f.Path), pattern) {
369 matches = append(matches, f.Path)
370 }
371 }
372
373 if len(matches) == 0 {
374 return textResult("No files found matching '" + input.Pattern + "'"), nil, nil
375 }
376
377 return textResult(fmt.Sprintf("Found %d files:\n%s", len(matches), strings.Join(matches, "\n"))), nil, nil
378}
379
380// EmptyInput for tools that don't need parameters
381type EmptyInput struct{}

Callers 1

Calls 5

NewGitIgnoreCacheFunction · 0.92
ScanFilesFunction · 0.92
errorResultFunction · 0.85
textResultFunction · 0.85
ErrorMethod · 0.45

Tested by 1