Skip to content

Output schema for arrays #142

@nilcolor

Description

@nilcolor

Describe the bug
When output schema is described like

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "name": {"type": "string"},
      "nick": {"type": "string"},
    },
    "required": ["name", "nick"]
  }
}

MCP clients will see just ({type: "object}) because of this logic https://github.com/modelcontextprotocol/ruby-sdk/blob/main/lib/mcp/tool/output_schema.rb#L22-L27 (Am I right?).

To Reproduce
Steps to reproduce the behavior:

  1. Create a new tool like
class TestTool < MCP::Tool
  output_schema({
    description: "A list of things",
    type: "array",
    items: {
      type: "object",
      properties: {
        name: {type: "string"},
        nick: {type: "string"},
      },
      required: ["name", "nick"],
    },
  })
end
  1. Check tool's information using something like @modelcontextprotocol/inspector

Expected behavior
It is expected that tool can notify client about output schema that is a list of something.

Logs
none

Additional context
I can try to propose a PR... Might not cover all the cases tho. Unless { type: "object" }.tap was used specifically and is not subject to change,

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