Skip to content

fix(mcp): strip recursive refs from advertised tool schemas - #923

Closed
advokat11 wants to merge 1 commit into
morluto:mainfrom
advokat11:fix/non-recursive-mcp-schemas
Closed

advokat11 wants to merge 1 commit into
morluto:mainfrom
advokat11:fix/non-recursive-mcp-schemas

Conversation

@advokat11

Copy link
Copy Markdown

Strict MCP clients (opencode) refuse the tool list with Recursive JSON schemas are not currently supported.

Every z.json() generic-JSON node projects a self-referential $defs/__schema0 loop — 141 cases across tool inputs (20 tools) and outputs (121 tools). The fix breaks the loop at the single registration choke point (toolRegistrationOptions), so both the live server and the regenerated generatedMcpToolCatalog.ts are cycle-free. Runtime Zod parsing is untouched; only the advertised wire shape relaxes cyclic $refs to free-form {}.

Fixes #919

Verification:

  • probe over live listTools: recursive defs 141 → 0, schemas remain Ajv-valid
  • tests/boundary/mcp/toolSchemaValidity.test.ts: +1 regression test (no recursive $refs), 6/6 pass
  • toolRegistrationOptions.test.ts + contractSnapshot.test.ts: pass
  • catalog regenerated via npm run mcp-catalog:generate

opencode rejects the MCP tool list with 'Recursive JSON schemas are
not currently supported'. Every z.json() generic-JSON node projects a
self-referential defs/__schema0 loop, 141 cases across inputs and
outputs. Break the loop at the single registration choke point so
both the live server and the generated catalog stay cycle-free;
runtime Zod parsing is unchanged.

Fixes morluto#919
@morluto

morluto commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Thanks, @advokat11, for your work on “fix(mcp): strip recursive refs from advertised tool schemas.” I appreciate your contribution to REA.

@morluto morluto added bug Something isn't working area: mcp MCP server, transport, and tool registration labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: mcp MCP server, transport, and tool registration bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP tool input schemas exceed Muse Spark 1.3 function-calling limits (recursive $ref, nesting depth > 10); no REA tool is usable with that model

2 participants