- Notifications
You must be signed in to change notification settings - Fork 8.4k
Description
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:
- Search for files/directories whose names match a pattern (actual behavior)
- 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
- Install Claude desktop for Mac Version 0.8.1
- Install and configure the
filesystem
server. Cleanup npm cache just to be sure the latest version is installed. - 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.
- 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
-
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." -
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."