-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Rename "search_files" to "search_files_by_name". Add "search_file_contents" #897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Rename "search_files" to "search_files_by_name". Add "search_file_contents" #897
Conversation
8b48040
to
eaa92e1
Compare
Another typically test scenario is when refactoring code. I've noticed Claude typically tries to read a file if the user has provided the file name, as in the example below:
If the file is too large, then the LLM tries to search content within the file(s). Previously, it was invoking the
This makes it possible to have better discovery of a code base, e.g.: View result from list_allowed_directories from filesystem (local) |
eaa92e1
to
8277da8
Compare
I've noticed sometimes Claude invokes
I improved the description of the |
8277da8
to
58595de
Compare
4b1f2bb
to
cc4103f
Compare
cc4103f
to
8c36bff
Compare
I've noticed that Claude AI often tries to invoke the search functions with a regex, most likely because the name of the input argument is "pattern". I've added a |
b8ea5dc
to
63e1d59
Compare
ced817a
to
f668adc
Compare
f668adc
to
44e2d41
Compare
Thanks for this, I came here with the same issue that you've solved here. I was going to suggest |
af8476e
to
3259d90
Compare
I've used this for over a month and it generally works well. I don't mind changing to "find_files" and "grep_files". I'm not sure if it would change the behavior. |
3259d90
to
a940af0
Compare
… of its purpose. Rename "search_files" to search_files_by_name. Add new "search_file_contents" function. Add descriptions to help the LLM understand the fields. Support single file search. Support glob pattern for search by file name. Rename 'pattern' argument to 'searchText'. Sometimes the name 'pattern' caused Claude to pass a regex even though it was processed as a simple substring match.
a940af0
to
12c56bd
Compare
Description
search_files
function description leads to misunderstanding of its purpose #896: "Search file by name" enhancementssearch_files
function tosearch_files_by_name
search_file_contents
to search file content.Server Details
Motivation and Context
Both Claude and human users may misinterpret the
search_files
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.How Has This Been Tested?
Tested with Claude Desktop with the following prompts, before and after the change.
/Users/my_userid/my_project/
/Users/my_userid/my_project/
/Users/my_userid/my_project using filesystem MCP.
/Users/my_userid/my_project using filesystem MCP.
For prompt 1, the LLM can easily infer it should be searching for file contents, not matching file names. Previously, the LLM mistakenly invoked the
search_files
function, which typically would return no matching results.For prompts 3 and 4, there is intentionally some prompt ambiguity to test how the LLM decide whether to use
search_files_by_name
orsearch_file_content
based on the function names and descriptions.Breaking Changes
No, but I'm not sure I understand breaking changes. I'm unclear whether it's ok to rename a function, or if it's considered to be a breaking change.
Types of changes
Checklist
Additional context
Tests for the
search_file_contents
functionasync function \w+\(
**/*.test.ts
) correctly filter out matching files*config*
) correctly filter content containing those strings