Skip to content

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

Open
lui62233 wants to merge 1 commit intomodelcontextprotocol:mainfrom
lui62233:fix-list-directory-depth
Open

fix(filesystem): add optional depth parameter to list_directory#3882
lui62233 wants to merge 1 commit intomodelcontextprotocol:mainfrom
lui62233:fix-list-directory-depth

Conversation

@lui62233
Copy link
Copy Markdown

@lui62233 lui62233 commented Apr 9, 2026

Summary

Add optional depth parameter to the list_directory tool's Zod schema, inputSchema, and handler to support recursive directory listing.

Problem

Some LLMs (e.g., lmstudio-community/gpt-oss-120b-MLX-8bit) generate a depth argument when calling list_directory, but the schema rejected it as "params is not allowed to have the additional property 'depth'".

Solution

  1. Added depth: z.number().optional() to ListDirectoryArgsSchema
  2. Added depth to the inputSchema in the tool registration
  3. Updated handler to perform recursive listing when depth > 0

Closes #2703

Add optional depth parameter to list_directory tool to support
recursive directory listing. Some LLMs generate a depth argument
for directory listing which was previously rejected as an
"additional property" error.

Fixes: modelcontextprotocol#2703
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.

[bug] list_directory params is not allowed to have the additional property depth

1 participant