Skip to content

fix(filesystem): add optional depth parameter to list_directory#4017

Open
Will-hxw wants to merge 2 commits intomodelcontextprotocol:mainfrom
Will-hxw:fix/2703-list-directory-depth
Open

fix(filesystem): add optional depth parameter to list_directory#4017
Will-hxw wants to merge 2 commits intomodelcontextprotocol:mainfrom
Will-hxw:fix/2703-list-directory-depth

Conversation

@Will-hxw
Copy link
Copy Markdown

Summary

  • Adds optional depth parameter to list_directory tool
  • When depth > 1, recursively lists subdirectories with indentation
  • Clamps depth to max 10 to prevent excessive recursion

Problem

LLMs (e.g., LM Studio with gpt-oss-120b-MLX-8bit model) are calling list_directory with a depth argument, but the schema rejected it with:

params is not allowed to have the additional property "depth"

Solution

  1. Added depth: z.number().optional() to ListDirectoryArgsSchema
  2. Updated inputSchema in tool registration
  3. Implemented recursive listing with indentation for depth > 1

Test Plan

  • npm run build passes
  • Existing tests pass (2 pre-existing Unicode/root-dir failures unrelated to this change)

Will-hxw and others added 2 commits April 23, 2026 10:23
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'.
Missing .describe() on resourceType field per issue modelcontextprotocol#3985.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant