Skip to content

Confusing search_files function description leads to misunderstanding of its purpose #896

@sebastien-rosset

Description

@sebastien-rosset

Describe the bug

The description of the search_files function is ambiguous and easily misinterpreted. It suggests it might search file contents (like grep) when it actually only searches file and directory names. Claude itself is misinterpreting the function to search content in files, rather than file names matching input patterns.

Why it's confusing
The function description starts with "Recursively search for files and directories matching a pattern." This phrasing is ambiguous - it could mean either:

  1. Search for files/directories whose names match a pattern (actual behavior)
  2. Search recursively through directories for files containing content that matches a pattern (grep-like behavior many users expect)

This ambiguity leads to confusion when users (and Claude) attempt to use the function to search file contents and receive "No matches found" despite knowing the content exists in the files.

To Reproduce

  1. Install Claude desktop for Mac Version 0.8.1
  2. Install and configure the filesystem server. Cleanup npm cache just to be sure the latest version is installed.
  3. Ask Claude desktop to search for content in files. Or ask Claude to refactor code, which typically leads Claude to try to "grep" content recursively in a directory.
  4. Notice Claude uses the search_files function to find content inside the files. Notice no matching content is found.
{ "path": "/Users/my_userid/my_project_path/", "pattern": "mysearch" } No matches found

Expected behavior
Claude should not use the search_files function to search for content.

Additional context
Both Claude and human users may misinterpret this function as a content search tool (like grep) rather than a file/directory name matcher. The suggested description makes the distinction clear from the beginning and explicitly notes that it doesn't search file contents.

Suggested functions

  1. search_files_by_name:
    "Find files and directories whose names match a pattern. Searches recursively
    through all subdirectories from the starting path. The search is case-insensitive
    and matches partial file or directory names. Returns full paths to all items with
    matching names. Great for finding files when you don't know their exact location.
    Only searches within allowed directories."

  2. search_file_contents:
    "Search for text patterns within file contents. Recursively examines all files
    under the specified directory and returns paths to files containing the search
    pattern. Functions similar to 'grep' command. The search can be case-sensitive
    or insensitive based on parameters. Returns matching file paths along with line
    numbers and context. Only searches within allowed directories."

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingserver-filesystemReference implementation for the Filesystem MCP server - src/filesystem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions