From fb2e52abcd22f342b3aa5b138f686c76a1683928 Mon Sep 17 00:00:00 2001 From: Will-hxw <1176843521@qq.com> Date: Thu, 23 Apr 2026 10:23:52 +0800 Subject: [PATCH 1/2] fix(filesystem): add optional depth parameter to list_directory Adds optional depth parameter to list_directory tool to support recursive directory listing. When depth > 1, entries from subdirectories are shown with indentation. Fixes issue where LLMs calling list_directory with depth argument received schema validation error 'params is not allowed to have the additional property depth'. --- src/filesystem/index.ts | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/filesystem/index.ts b/src/filesystem/index.ts index 7b67e63e58..2b825f47cc 100644 --- a/src/filesystem/index.ts +++ b/src/filesystem/index.ts @@ -132,6 +132,7 @@ const CreateDirectoryArgsSchema = z.object({ const ListDirectoryArgsSchema = z.object({ path: z.string(), + depth: z.number().optional().describe('Maximum directory depth to list (default: 1, max: 10)') }); const ListDirectoryWithSizesArgsSchema = z.object({ @@ -427,17 +428,35 @@ server.registerTool( "prefixes. This tool is essential for understanding directory structure and " + "finding specific files within a directory. Only works within allowed directories.", inputSchema: { - path: z.string() + path: z.string(), + depth: z.number().optional().describe('Maximum directory depth to list (default: 1, max: 10)') }, outputSchema: { content: z.string() }, annotations: { readOnlyHint: true } }, async (args: z.infer) => { const validPath = await validatePath(args.path); - const entries = await fs.readdir(validPath, { withFileTypes: true }); - const formatted = entries - .map((entry) => `${entry.isDirectory() ? "[DIR]" : "[FILE]"} ${entry.name}`) - .join("\n"); + const maxDepth = Math.min(args.depth ?? 1, 10); + + async function listDirRecursive(currentPath: string, currentDepth: number): Promise { + const entries = await fs.readdir(currentPath, { withFileTypes: true }); + const lines: string[] = []; + + for (const entry of entries) { + const indent = ' '.repeat(currentDepth - 1); + lines.push(`${indent}${entry.isDirectory() ? "[DIR]" : "[FILE]"} ${entry.name}`); + + if (entry.isDirectory() && currentDepth < maxDepth) { + const subPath = path.join(currentPath, entry.name); + const subEntries = await listDirRecursive(subPath, currentDepth + 1); + lines.push(...subEntries); + } + } + + return lines; + } + + const formatted = (await listDirRecursive(validPath, 1)).join("\n"); return { content: [{ type: "text" as const, text: formatted }], structuredContent: { content: formatted } From f61be1616b8666ae75521fae88877a3b9b61319b Mon Sep 17 00:00:00 2001 From: Will-hxw <1176843521@qq.com> Date: Thu, 23 Apr 2026 12:40:24 +0800 Subject: [PATCH 2/2] fix(everything): add description to get-resource-reference resourceType Missing .describe() on resourceType field per issue #3985. Co-Authored-By: Claude Opus 4.7 --- src/everything/tools/get-resource-reference.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/everything/tools/get-resource-reference.ts b/src/everything/tools/get-resource-reference.ts index d3dc5d3ecb..bc60e4b61e 100644 --- a/src/everything/tools/get-resource-reference.ts +++ b/src/everything/tools/get-resource-reference.ts @@ -15,7 +15,8 @@ import { const GetResourceReferenceSchema = z.object({ resourceType: z .enum([RESOURCE_TYPE_TEXT, RESOURCE_TYPE_BLOB]) - .default(RESOURCE_TYPE_TEXT), + .default(RESOURCE_TYPE_TEXT) + .describe("Type of resource — must be 'Text' or 'Blob'."), resourceId: z .number() .default(1)