Repository navigation
fix(mcp): tolerate invalid tool output schemas - #26530
Closed
nicolascancino wants to merge 4 commits into
Closed
nicolascancino wants to merge 4 commits into
nicolascancino wants to merge 4 commits into
Conversation
kitlangton
enabled auto-merge (squash)
May 9, 2026 23:16
3 of 6 tasks
Contributor
|
Thanks for putting this fix together. I opened #26614 based on this approach, rebased onto current Closing this one in favor of #26614 so we have a clean branch for merge. Credit to @nicolascancino for the original fix direction here. |
auto-merge was automatically disabled
May 10, 2026 01:20
Pull request was closed
1 task done
androidand
pushed a commit
to androidand/opencode-skein
that referenced
this pull request
Sep 19, 2026
Closes anomalyco#26529. When an MCP server returns a tool whose \`outputSchema\` contains a broken \`$ref\` (e.g. Google Stitch's \`#/$defs/ScreenInstance\`), the SDK's typed \`listTools()\` validator throws and opencode marks the ENTIRE server as failed — losing every other valid tool the server exposes. Catch the schema-reference errors and retry with a tolerant schema (\`looseObject\` + \`outputSchema: z.unknown().optional()\`) via the raw \`request\` path so the bad tool's schema is accepted as opaque while the others load normally. Equivalent fix shape to anomalyco#26530 (nicolascancino) — kept his approach since it's correct. Bundles our reproducer test from \`kit/issue-reproducers\` so the regression is locked in. Verified red → green → red → green: - pre-fix: server marked \`failed\` - post-fix: server stays \`connected\`, valid tool present
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #26529
Type of change
What does this PR do?
Makes MCP tool loading resilient when a server returns a valid
tools/listresponse whoseoutputSchemacontains refs the SDK cannot resolve.The normal
client.listTools()path still runs first. If it fails with a schema reference error, OpenCode retriestools/listwith a tolerant result schema that keepsinputSchemavalidation and treatsoutputSchemaas opaque.This fixes Google Stitch-style failures where the MCP transport connects but OpenCode marks the server as failed while validating tool output schemas.
How did you verify your code works?
Result:
Screenshots / recordings
N/A — non-UI change.
Checklist