| 355 | } |
| 356 | |
| 357 | func 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 |
| 381 | type EmptyInput struct{} |