Filesystem MCP server returns structuredContent that violates its own outputSchema, so the coding agent's MCP client rejects directory_tree results
The filesystem MCP server's directory_tree (and move_file, list_directory_with_sizes) tools returned structuredContent.content as an array of content blocks while their outputSchema declared a string. Claude Code's MCP client validated the output and failed the tool call with MCP error -32602.
- Framework / agent
- MCP filesystem server · coding agent (Claude Code) using an MCP server
- Remediation attempts
- TESTED
- Recurrence
- not documented
- Source languages
- en
- Updated
- 2026-09-30
Sources
- GITHUB ISSUE filesystem: directory_tree returns structured content array instead of string, breaking Claude Code — github.com/modelcontextprotocol/servers, retrieved 2026-09-29
- GITHUB PULL REQUEST fix(filesystem): return string in structuredContent to match outputSchema — github.com/modelcontextprotocol/servers, retrieved 2026-09-29
Public sample: the full evidence record is free.
Symptoms
- Calling directory_tree from Claude Code fails with an output validation error REPORTED CLAIM
Error messages (verbatim)
MCP error -32602: Output validation error: Invalid structured content for tool directory_tree
Invalid input: expected string, received array
Context and trigger
- Agent type
- coding agent (Claude Code) using an MCP server
- Component
- @modelcontextprotocol/server-filesystem directory_tree, move_file, list_directory_with_sizes
- Framework
- MCP filesystem server (2025.11.25 (also 2025.8.21, 2025.7.29, 2025.1.14))
- Model
- not stated
- Task
- file system exploration by a coding agent
- Tools
- directory_tree, move_file, list_directory_with_sizes
- An MCP client that validates structuredContent against outputSchema calls directory_tree REPORTED CLAIM
Root cause VERIFIED
The tools returned structuredContent: { content: [contentBlock] } while outputSchema declares content as a string, so schema validation failed.
cause stated by the project and addressed by an applied fix
These three tools were returning `structuredContent: { content: [contentBlock] }` (array) but their `outputSchema` declares `{ content: z.string() }`. This mismatch caused schema validation to fail.Remediation attempts (1)
Return structuredContent.content as a string matching the declared outputSchema; merged with integration tests for schema compliance.
Status basis: fix merged; regression test changed in the fix. Verification: regression test added with the fix; no independent confirmation that the original failure is gone.
Change: https://github.com/modelcontextprotocol/servers/pull/3113 · merged · tests changed
Changed `structuredContent` from `{ content: [contentBlock] }` to `{ content: text }` to match the declared `outputSchema`Manually tested `directory_tree` tool in Claude Code - no validation error
Outcome outcome: RESOLVED UNVERIFIED
fix with regression test; no independent confirmation (2025-12-08)
Recurrence
Not documented in the sources (absence of reports is not evidence of absence).
Confidence HIGH
Root cause stated by the project, a fix was applied, and it is backed by a regression test or independent confirmation.
| Factor | Present | Meaning |
|---|---|---|
| first_party_evidence | yes | a quote from the affected project/vendor (or a controlled test) |
| fix_applied | yes | a fix was merged/released |
| regression_test | yes | tests changed with the fix |
| independent_confirmation | no | reporter/maintainer/vendor confirmed the failure is gone |
| root_cause_verified | yes | cause stated by the project and addressed by the fix |
| reproduction_documented | no | steps or conditions to reproduce were quoted |
| multiple_independent_sources | no | 1 independent source group(s) |
| failed_attempts_documented | no | unsuccessful remediation recorded |
All evidence (6 verified quotes)
MCP error -32602: Output validation error: Invalid structured content for tool directory_tree
"message": "Invalid input: expected string, received array"
The `directory_tree` tool returns structured content (array of content blocks) while Claude Code's MCP client expects a plain string for the `content` field.These three tools were returning `structuredContent: { content: [contentBlock] }` (array) but their `outputSchema` declares `{ content: z.string() }`. This mismatch caused schema validation to fail.Manually tested `directory_tree` tool in Claude Code - no validation error
Changed `structuredContent` from `{ content: [contentBlock] }` to `{ content: text }` to match the declared `outputSchema`Evidence-gate notes
- attempt 1: confirmation written by the fix author is not independent; ignored
- attempt 1: claimed VERIFIED_SUCCESS, evidence allows TESTED
Categories: INTEGRATION FAILURE TOOL FAILUREDATA FAILURE · extraction curated, gate-2026-09-29-v1
Similarity to your system is not implied. A remediation that worked in the documented context may not work in yours.