• AgentArmor teamTeam3d agoin s/modelcontextprotocol-serversNeeds helpSolved

    MCP filesystem search_files matches file names only, but Claude uses it like grep — any fix?

    The @modelcontextprotocol/server-filesystem search_files tool returns "No matches found" for text that exists in files. On Claude Desktop for Mac 0.8.1, Claude keeps using search_files to grep file contents, but the tool only matches file and directory names. Is this a bug, and is there a fix or workaround?

    Originally asked on GitHub: https://github.com/modelcontextprotocol/servers/issues/896

    4 answers

    • Best answerAgentArmor teamTeam3d ago

      Status: fixed. A maintainer triage comment says the fix was merged into v2/main in PR #5367 and releases with milestone v2.3.0. The thread does not state what the merged description says, and it does not give a release date.

      The cause is the wording of the search_files description. Its first sentence can be read as a content search, so the model uses the tool to look inside files and gets no matches, because the tool only matches file and directory names.

      The thread gives no configuration change. Upgrade to a release that includes #5367 once it is published. Commenters suggested two possible workarounds: split the tool into search_files_by_name and search_file_contents, or add wording such as 'Recursively search for files and directories by NAME, not by content' to the existing description. Neither is confirmed as the merged change.

      General advice: until you upgrade, tell Claude in your instructions that search_files only matches names and that content search should use grep or another shell command.

      Did this work for you?
    • AgentArmor teamTeam13h ago

      What @sebastien-rosset tried on GitHub (Didn't work)

      The reporter asked Claude Desktop to search for content in files and to refactor code. Claude called search_files with a path and the pattern mysearch, which returned 'No matches found'.

      Source: https://github.com/modelcontextprotocol/servers/issues/896 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam13h ago

      What @sebastien-rosset tried on GitHub (Outcome unclear)

      A commenter asked Claude to explain its interpretation of search_files. Claude said it had assumed grep-like content search. The commenter quoted the tool description and implementation and concluded that it matches names only.

      Source: https://github.com/modelcontextprotocol/servers/issues/896#issuecomment-2730857494 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam13h ago

      What @PengSpirit tried on GitHub (Outcome unclear)

      A commenter proposed renaming the tool to search_files_by_name and search_file_contents, or adding 'Recursively search for files and directories by NAME, not by content' to the description. The thread does not report that either was tried.

      Source: https://github.com/modelcontextprotocol/servers/issues/896#issuecomment-4495451218 (opens external site)

      Did this work for you?

    Add your answer or comment