Skip to content

mcp: output schema mismatch hard-fails tool calls instead of degrading gracefully #56116

Closed as not planned

Description

@baobabcat

Summary

When a remote MCP server returns structured content that violates its own declared outputSchema, opencode hard-fails the entire tool call. A single mistyped field makes an otherwise-working tool 100% unusable and discards the (valid) content. opencode should degrade gracefully — normalize the value, or surface the raw text plus a warning — instead of treating the mismatch as fatal.

Environment

  • opencode version: 2.0.29
  • OS: Darwin 27.0.0 (arm64)
  • Terminal: Apple Terminal (TERM_PROGRAM=Apple_Terminal, TERM=xterm-256color, COLORTERM=truecolor)
  • Shell: /bin/zsh
  • Install/channel: latest
  • Active plugins: none found (~/.config/opencode/opencode.json defines only an MCP server)

Reproduction

  1. Configure a remote MCP server (example: Robinhood trading, https://agent.robinhood.com/mcp/trading) and authenticate via /mcps.

  2. Call review_advanced_order with any valid arguments, e.g.:

    {
      "account_number": "••••1971",
      "symbol": "SOFI",
      "side": "sell",
      "quantity": "6",
      "take_profit_limit_price": "15.64",
      "stop_loss_stop_price": "13.76",
      "time_in_force": "gtc",
      "market_hours": "regular_hours"
    }
  3. Observe the call fail with a schema-validation error.

Expected Behavior

The tool call succeeds or degrades gracefully. A response whose fields are valid JSON but do not exactly match the declared schema should not be a fatal error. opencode should normalize the value, or return the raw content with a warning, so the tool remains usable.

Actual Behavior

The call fails outright and no content is returned:

MCP tool "review_advanced_order" on server "robinhood" failed: Structured content does not match the tool's output schema: data/data/quote_data/previous_close_date must be null,object

Reproducible consistently — it failed on two consecutive attempts with identical parameters.

Additional Context

  • Root cause is server-side: review_advanced_order's declared output schema types quote_data.previous_close_date as null | object, but the server returns a string (e.g. "2026-10-14"). Sibling tools on the same server (place_equity_order, review_equity_order, get_equity_quotes) correctly declare the same field as null | string, so the server schema is inconsistent for this one tool.
  • Impact: because opencode treats the mismatch as fatal, the tool is completely unusable and the otherwise-valid response is discarded. A graceful path would keep users working while the server fixes its schema, since not every third-party server can be patched on the client's timeline.
  • Workaround: skip review_advanced_order and call place_advanced_order directly (different response schema; works).

Activity

  1. opencode-agent commented on Oct 16, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report and for tracking down the root cause in the server's schema.

    To restate the request: when an MCP server returns structured content that doesn't match its own declared outputSchema, opencode should still return the content, with a warning, instead of failing the whole tool call.

    Right now this is intended behaviour, not a bug. The MCP SDK client that opencode uses checks structuredContent against the declared output schema and rejects the call when they don't match. That check runs before opencode or any plugin sees the result, so a plugin can't work around it today. Maintainers will consider making this more forgiving, for example by treating a mismatch as a warning or adding a per-server option to turn the check off. I can't promise whether or when that will happen.

    Related issues about strict MCP schema handling (they reject schemas when tools are loaded, rather than tool results):

    Until then, your workaround of calling place_advanced_order directly is the best option. It may also help to report the previous_close_date schema mismatch to Robinhood.

  2. rekram1-node commented on Oct 22, 2026

    @rekram1-node
    Contributor

    Your server is in violation of the mcp spec. Not a bug on our end. Maybe we will be more graceful but this should be fixed in your server

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