Skip to content

Calling a tool with structured output that returns an array of objects throws an error #872

Closed as not planned

Description

@pnedkovp

Inspector Version

  • v0.17

Describe the bug
I am using the cli option to get a tool result of a tool with structured output that returns an array of objects. But instead of getting the result I get the following error:

Failed to call tool get_sessions: [
{
"code": "invalid_type",
"expected": "object",
"received": "array",
"path": [
"structuredContent"
],
"message": "Expected object, received array"
}
]

Failed with exit code: 1

To Reproduce
Steps to reproduce the behavior:

  1. Call a tool using the cli option eg
    npx @modelcontextprotocol/inspector --cli http://localhost:8868/mcp --transport http --method tools/call --tool-name get_sessions

Expected behavior
The tool result should be displayed.

Environment (please complete the following information):

  • OS: OSX
  • Terminal

Activity

  1. added
    bugSomething isn't working
    cliIssues and PRs specific to cli mode
    on Oct 26, 2025
  2. olaservo commented on Dec 4, 2025

    @olaservo
    Member

    I was reviewing older issues and noticed this mentions returning an array, but structuredContent can only be an object per the MCP schema:

    "structuredContent": {
        "additionalProperties": {},
        "description": "An optional JSON object that represents the structured result of the tool call.",
        "type": "object"
    }

    This is a known limitation. (btw, [SEP-834](modelcontextprotocol/modelcontextprotocol#834) proposes loosening this restriction to allow any JSON (including arrays) validated by outputSchema.)

    Workaround: Wrap the array in an object:

    // Instead of:
    [{ "id": 1 }, { "id": 2 }]
    
    // Return:
    { "sessions": [{ "id": 1 }, { "id": 2 }] }

    With a corresponding outputSchema:

    {
      "type": "object",
      "properties": {
        "sessions": {
          "type": "array",
          "items": { ... }
        }
      }
    }
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

    cliIssues and PRs specific to cli mode

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions