Skip to content

Commit 63461de

Browse files
cliffhallclaude
andcommitted
feat(filesystem): keep only the empty-result hint, drop the example patterns
The reporter's later measurement on 2.3.0 shows realistic example patterns in the description no longer change how often small models search, so the description and the pattern input go back to their existing wording. The empty-result hint stays: it is the part with a rationale of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent 731abb0 commit 63461de

4 files changed

Lines changed: 6 additions & 32 deletions

File tree

‎.changeset/search-files-empty-result-hint.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@modelcontextprotocol/server-filesystem": patch
33
---
44

5-
`search_files` no longer answers a search that matched nothing with a bare `No matches found`. The result still begins with those words, and now names the pattern and the directory searched, says the pattern is a case-sensitive glob over names relative to that directory (never file contents), and, for a pattern with no `**`, suggests the `**/` form that reaches subdirectories. The tool's description and its `pattern` input also gain realistic example patterns (`**/*.json`, `**/*report*`) next to the generic ones.
5+
`search_files` no longer answers a search that matched nothing with a bare `No matches found`. The result still begins with those words, and now names the pattern and the directory searched, says the pattern is a case-sensitive glob over names relative to that directory (never file contents), and, for a pattern with no `**`, suggests the `**/` form that reaches subdirectories.

‎src/filesystem/README.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,7 @@ Files inside the allowed directories are also [resources](https://modelcontextpr
283283
- `path` (string): Starting directory
284284
- `pattern` (string): Glob matched, case-sensitively, against each entry's
285285
path relative to `path`: `*.ext` matches entries directly under `path`,
286-
`**/*.ext` or `**/name` matches at any depth. For example, `**/*.json`
287-
finds every JSON file and `**/*report*` every entry with `report` in its
288-
name
286+
`**/*.ext` or `**/name` matches at any depth
289287
- `excludePatterns` (string[]): Entries to leave out, read the same way as
290288
`directory_tree`'s. A bare name such as `node_modules` excludes an entry
291289
of that name at any depth and everything below it; it matches whole

‎src/filesystem/__tests__/search-files-description.test.ts‎

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
// contents. These tests pin that wording and each matching rule it states, so
66
// the description cannot drift from the behavior again.
77
//
8-
// They also pin the realistic example patterns the description carries next to
9-
// the generic ones, and what an empty result says (#5553): a bare "No matches
10-
// found" gave a model nothing to correct a pattern with, so it repeated
8+
// They also pin what an empty result says (#5553): a bare "No matches found"
9+
// gave a model nothing to correct a pattern with, so it repeated
1110
// '*.ext' patterns that cannot reach a subdirectory. The empty result now
1211
// names the pattern and the directory, restates how the pattern is read, and
1312
// suggests the '**/' form when the pattern has no '**'.
@@ -68,27 +67,6 @@ describe("search_files description (#896, #3419)", () => {
6867
expect(description).not.toContain("working directory");
6968
});
7069

71-
it("gives realistic example patterns, each of which matches as described", async () => {
72-
const { tools } = await client.listTools();
73-
const tool = tools.find((t) => t.name === "search_files");
74-
expect(tool?.description).toContain("'**/*.json'");
75-
expect(tool?.description).toContain("'**/*report*'");
76-
const properties = tool?.inputSchema.properties as Record<
77-
string,
78-
{ description?: string }
79-
>;
80-
expect(properties.pattern.description).toContain("'**/*report*'");
81-
82-
await fs.writeFile(path.join(dir, "src", "config", "app.json"), "");
83-
await fs.writeFile(path.join(dir, "src", "q3-report-final.txt"), "");
84-
expect(await search("**/*.json")).toEqual([
85-
path.join(dir, "src", "config", "app.json"),
86-
]);
87-
expect(await search("**/*report*")).toEqual([
88-
path.join(dir, "src", "q3-report-final.txt"),
89-
]);
90-
});
91-
9270
it("does not match a file's contents", async () => {
9371
expect(await search("**/needle")).toEqual([
9472
`No matches found for pattern '**/needle' under ${dir}. ` +

‎src/filesystem/server.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ const SearchFilesArgsSchema = z.object({
190190
.string()
191191
.describe(
192192
"Glob matched against each entry's path relative to path, never its content: " +
193-
"'*.ts' matches directly under path, '**/*.ts' at any depth, " +
194-
"'**/*report*' any name containing 'report'.",
193+
"'*.ts' matches directly under path, '**/*.ts' at any depth.",
195194
),
196195
excludePatterns: z
197196
.array(z.string())
@@ -1031,8 +1030,7 @@ export function createServer(
10311030
description:
10321031
"Find files and directories by NAME, not by content: this tool never reads or searches inside files. " +
10331032
"It walks the tree under 'path' and matches a glob pattern against each entry's path relative to 'path' (case-sensitive). " +
1034-
"Use '*.ext' to match entries directly under 'path', and '**/*.ext' or '**/name' to match at any depth: " +
1035-
"for example, '**/*.json' finds every JSON file and '**/*report*' every entry with 'report' in its name. " +
1033+
"Use '*.ext' to match entries directly under 'path', and '**/*.ext' or '**/name' to match at any depth. " +
10361034
"Returns full paths to all matching items. Great for finding files when you don't know their exact location. " +
10371035
"Only searches within allowed directories.",
10381036
inputSchema: jsonSchema2020(SearchFilesArgsSchema.shape),

0 commit comments

Comments
 (0)