cloudaxe-opencode/packages/opencode/test/mcp
Developer d3a69ad910 fix(mcp): tolerate invalid tool output schemas
Closes #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 #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
2026-05-09 19:00:34 -04:00
..
headers.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
lifecycle.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
oauth-auto-connect.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
oauth-browser.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
oauth-callback.test.ts feat(mcp): add OAuth redirect URI configuration for MCP servers (#21385) 2026-04-09 11:45:52 -05:00
output-schema-unresolved-refs.test.ts fix(mcp): tolerate invalid tool output schemas 2026-05-09 19:00:34 -04:00