Skip to content

fix(filesystem): clarify that search_files matches names, not contents - #3716

Open
chasewhughes wants to merge 1 commit into
modelcontextprotocol:mainfrom
chasewhughes:fix/search-files-description
Open

fix(filesystem): clarify that search_files matches names, not contents#3716
chasewhughes wants to merge 1 commit into
modelcontextprotocol:mainfrom
chasewhughes:fix/search-files-description

Conversation

@chasewhughes

Copy link
Copy Markdown

Summary

Fixes #896 — the search_files tool description was ambiguous, leading AI assistants (including Claude) to misinterpret it as a content search (like grep) when it actually matches file/directory names against a glob pattern.

Changes

  • Clarified the opening sentence: "matching a pattern" → "whose names match a glob pattern"
  • Added an explicit note: "This searches by file/directory name only — it does not search file contents."

No logic changes — description only.

Test plan

  • Verified the implementation in lib.ts uses minimatch against relativePath (name-based matching)
  • Description now unambiguously communicates the tool's actual behavior

The description for search_files was ambiguous — it could be interpreted
as searching file contents (like grep) when it actually matches
file/directory names against a glob pattern. This caused AI assistants
to misuse the tool by passing content strings as the pattern.

Fixes modelcontextprotocol#896
@cliffhall cliffhall added bug Something isn't working server-filesystem Reference implementation for the Filesystem MCP server - src/filesystem labels Apr 20, 2026
@cliffhall

Copy link
Copy Markdown
Member

@claude review

@claude

claude Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Claude finished @cliffhall's task in 1m 5s —— View job


PR Review

  • Gather context and read changed files
  • Review diff and implementation
  • Post review feedback

Summary: This is a clean, minimal documentation fix that correctly disambiguates search_files behavior. The change is accurate, well-motivated, and easy to verify against the implementation.

What changed (src/filesystem/index.ts:631-632)

- "Recursively search for files and directories matching a pattern. "
+ "Recursively search for files and directories whose names match a glob pattern. "
+ "This searches by file/directory name only — it does not search file contents. "

Verification against implementation

The PR author's claim holds up. In src/filesystem/lib.ts:392-400, the search logic calls minimatch(relativePath, pattern) where relativePath is the path of the entry relative to the search root — it never reads or inspects file contents. The tool is purely a path/name matcher.

Minor precision note

The phrase "whose names match a glob pattern" is technically slightly imprecise — minimatch is applied to the relative path (e.g. subdir/myfile.ts), not just the bare filename. This means *.ts only matches .ts files directly in the search root, while **/*.ts matches them at any depth. However, the existing sentence that immediately follows — "The patterns should be glob-style patterns that match paths relative to the working directory" — already corrects for this, so the overall description is accurate. No change needed.

Verdict

LGTM. The critical addition is the explicit "does not search file contents" sentence, which directly addresses the confusion described in issue #896. This is exactly the kind of concise, targeted documentation fix that prevents AI assistants (and humans) from misusing the tool. No logic is touched, and the new wording aligns with the actual implementation.


@LuuOW LuuOW left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technical audit: Verified MCP server implementation for consistency with current SDK patterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working server-filesystem Reference implementation for the Filesystem MCP server - src/filesystem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confusing search_files function description leads to misunderstanding of its purpose

3 participants