[PR #923] [CLOSED] fix(mcp): strip recursive refs from advertised tool schemas #2352

Closed
opened 2026-10-16 21:17:41 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/923
Author: @advokat11
Created: 10/7/2026
Status: ❌ Closed

Base: main ← Head: fix/non-recursive-mcp-schemas


📝 Commits (1)

  • 3205a8d fix(mcp): strip recursive refs from advertised tool schemas

📊 Changes

3 files changed (+123 additions, -3 deletions)

View changed files

📝 src/generatedMcpToolCatalog.ts (+1 -1)
📝 src/server/toolRegistrationOptions.ts (+74 -2)
📝 tests/boundary/mcp/toolSchemaValidity.test.ts (+48 -0)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/923 **Author:** [@advokat11](https://github.com/advokat11) **Created:** 10/7/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/non-recursive-mcp-schemas` --- ### 📝 Commits (1) - [`3205a8d`](https://github.com/morluto/rea/commit/3205a8de7997e756c8340f43bee6c342ecd4d386) fix(mcp): strip recursive refs from advertised tool schemas ### 📊 Changes **3 files changed** (+123 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/generatedMcpToolCatalog.ts` (+1 -1) 📝 `src/server/toolRegistrationOptions.ts` (+74 -2) 📝 `tests/boundary/mcp/toolSchemaValidity.test.ts` (+48 -0) </details> ### 📄 Description 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 `$ref`s 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` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-16 21:17:41 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2352
No description provided.