Skip to content

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

@dev-brewery

Description

@dev-brewery

Description

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. This causes a validation error when using the tool.

Error Message

MCP error -32602: Output validation error: Invalid structured content for tool directory_tree: [
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "content"
    ],
    "message": "Invalid input: expected string, received array"
  }
]

Reproduction

  1. Configure filesystem MCP server in Claude Code
  2. Call directory_tree tool with any valid path
  3. Observe validation error

Analysis

  • list_directory returns: {"content": "string here"} ✅ works
  • directory_tree returns: {"content": [{"type": "text", "text": "..."}]} ❌ fails validation

Tested versions:

  • 2025.11.25 (latest) - fails
  • 2025.8.21 - fails
  • 2025.7.29 - fails
  • 2025.1.14 - fails
  • 0.6.2 - tool doesn't exist

All date-based versions return the array format for directory_tree.

Expected Behavior

Either:

  1. directory_tree should return string content like list_directory does
  2. Or Claude Code's validation schema should be updated to accept structured content arrays

Environment

  • OS: Linux (WSL2)
  • Node: via npx
  • Claude Code: latest
  • @modelcontextprotocol/server-filesystem: 2025.11.25

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingserver-filesystemReference implementation for the Filesystem MCP server - src/filesystem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions