Skip to content

get_file_contents directory results emit a top-level structuredContent array that object-only clients reject #3864

Backlog

Description

@self-gh-mcp-poc

Summary

get_file_contents works for individual files but fails to list directories in an MCP client that requires structuredContent to be an object. The directory path produces a top-level JSON array and advertises that shape in outputSchema; the client rejects the response before exposing the entries.

Reproduction

Using the GitHub MCP Server connector (reported server version 2.1.0), call get_file_contents with owner: "github", repo: "github-mcp-server", path: "/", fields: ["name", "type", "path"]. The same failure also occurs for path: "pkg/github" and path: "internal". Reading a single file such as pkg/github/repository_tool_types.go succeeds.

The directory call fails with:

Upstream call failed on target 'remote': 1 validation error for CallToolResult
structuredContent
  Input should be a valid dictionary [type=dict_type, input_value=[{'name': '.dockerignore'...}], input_type=list]

Evidence in the repository

This is a specific interoperability failure, distinct from the general request in #1929 to populate structuredContent for tools.

Expected behavior / suggested fix

Directory listings should remain usable by clients that expect an object-valued structuredContent. Wrap the entries in an object, e.g. { "entries": [...] }, and update the advertised output schema and tests accordingly. Preserve the existing text output for compatibility, and add a regression test that exercises a directory listing through an object-valued structured-content consumer.

Impact

Agents using such clients cannot browse repository directories through get_file_contents, even when file reads and code search work.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions