WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@olaservo
Copy link
Member

@olaservo olaservo commented Dec 8, 2025

Description

Fixes the MCP error -32602: Output validation error that occurs when using directory_tree, move_file, and list_directory_with_sizes tools.

Root cause: These three tools were returning structuredContent: { content: [contentBlock] } (array) but their outputSchema declares { content: z.string() }. This mismatch caused schema validation to fail.

Fix: Changed structuredContent from { content: [contentBlock] } to { content: text } to match the declared outputSchema, consistent with other working tools like list_directory and search_files.

Server Details

  • Server: filesystem
  • Changes to: tools (directory_tree, move_file, list_directory_with_sizes)

Motivation and Context

Multiple users reported MCP error -32602 when calling these tools. The error message indicated:

Invalid input: expected string, received array

This was because structuredContent.content was an array of content blocks instead of a string as declared in outputSchema.

How Has This Been Tested?

  • All 134 existing unit tests pass
  • Manually tested directory_tree tool in Claude Code - no validation error
  • Manually tested list_directory_with_sizes tool in Claude Code - no validation error
  • Manually tested move_file tool in Claude Code - no validation error

Breaking Changes

None. The content field (array of content blocks) remains unchanged for backwards compatibility. Only structuredContent is fixed to match the declared schema.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

Additional context

Fixes #3110, #3106, #3093

🤖 Generated with Claude Code

olaservo and others added 2 commits December 7, 2025 20:54
…hema

The directory_tree, move_file, and list_directory_with_sizes tools were
returning an array in structuredContent.content, but outputSchema declares
content as z.string(). This caused MCP error -32602 validation failures.

Changed structuredContent from { content: [contentBlock] } to { content: text }
to match the declared outputSchema and be consistent with other filesystem
tools like list_directory and search_files.

Fixes modelcontextprotocol#3110, modelcontextprotocol#3106, modelcontextprotocol#3093

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…compliance

Adds tests to verify that directory_tree, list_directory_with_sizes, and
move_file tools return structuredContent.content as a string (matching
outputSchema) rather than an array.

These tests prevent regression of issues modelcontextprotocol#3110, modelcontextprotocol#3106, modelcontextprotocol#3093.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@olaservo olaservo marked this pull request as ready for review December 8, 2025 14:42
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.

filesystem: directory_tree returns structured content array instead of string, breaking Claude Code

1 participant