modelcontextprotocol / modelcontextprotocol/servers

fix(filesystem): improve search_files description and performance

Open
#3,419 1 comment 0 reactions 1 assignee View on GitHub

@olaservo is already working on this.

Since Feb 27, 2026.

Dominant language
TypeScript
Stars
90.5k
Forks
11.7k
Avg merge
2d 2h
Merged PRs (30d)
5

Description

Summary

The search_files tool description is ambiguous — LLMs frequently confuse it with a content search (grep) when it's actually a name-based file finder. This causes failed searches and poor user experience.

Originally raised in issues #896, #735, #1067, and extensively explored in PR #897 by @sebastien-rosset.

Proposed Changes

Based on the work in PR #897, adapted for the current registerTool() architecture:

  1. Improve search_files tool description to clearly state it searches by file/directory name, not file contents. Clarify that it supports glob patterns and substring matching.

  2. Improve search performance with parallel BFS directory traversal (breadth-first, processing directories in batches) instead of recursive DFS, for better performance in deeply nested directory trees.

  3. Add comprehensive test coverage for the search function, including:

    • Glob pattern matching
    • Case sensitivity behavior
    • Exclude patterns
    • Directory traversal
    • Error handling for inaccessible directories

Context

PR #897 implemented these improvements thoroughly but is now stale (merge conflicts after the Nov 2025 architecture refactoring). The valuable ideas and approach should be carried forward in a fresh PR targeting the current codebase (searchFilesByName in lib.ts, registerTool() in index.ts).

Credit: @sebastien-rosset for the original research, implementation, and LLM testing that validated these improvements.

Related

  • PR #897 (original implementation, to be closed after this is picked up)
  • Issues #896, #735, #1067

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.