Skip to content

In the filesystem, the outputSchema type of the directory_tree tool is incorrect #3106

@zrq1523565

Description

@zrq1523565

Describe the bug
the outputSchema type of the directory_tree tool is incorrect

To Reproduce
call the directory_tree tool in the client

Expected behavior
return the correct information

Logs

meta=None content=[TextContent(type='text', text='MCP error -32602: Output validation error: Invalid structured content for tool directory_tree: [\n  {\n    "expected": "string",\n    "code": "invalid_type",\n    "path": [\n      "content"\n    ],\n    "message": "Invalid input: expected string, received array"\n  }\n]', annotations=None, meta=None)] structuredContent=None isError=True

Additional context

server.registerTool("directory_tree", {
...
    outputSchema: {
        content: z.array(z.object({
            type: z.string(),
            text: z.string()
        }))
    },
...

after making the above modifications in ./@modelcontextprotocol/server-filesystem/dist/index.js, the returned data is correct

correct logs:

[
  {
    "name": "kafka",
    "type": "directory",
    "children": [
      {
        "name": "mykafka",
        "type": "directory",
        "children": [
          {
            "name": ".git",
            "type": "directory",
            "children": [
              {
                "name": "COMMIT_EDITMSG",
                "type": "file"
              },
              {
                "name": "FETCH_HEAD",
                "type": "file"
              },
              {
                "name": "HEAD",
                "type": "file"
              },
              {
                "name": "branches",
                "type": "directory",
                "children": []
              },
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions