From 587d4c032ac7b1bded57b68766f656f7eef2c012 Mon Sep 17 00:00:00 2001 From: Andrzej Pomirski <167459559+andrzej-pomirski-yohana@users.noreply.github.com> Date: Wed, 5 Nov 2025 17:57:55 +0100 Subject: [PATCH] fix: do not use references in Zod to JSON Schema Many LLMs do not support references in the JSON Schemas for tool inputs/outputs and if they do, they mostly only support root-level references. Schemas produced with Zod to JSON Schema do not comply with this restriction thus, if using strict tool calling (e.g. in OpenAI), the request fails. --- src/server/mcp.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server/mcp.ts b/src/server/mcp.ts index 015f518a1..6af855f68 100644 --- a/src/server/mcp.ts +++ b/src/server/mcp.ts @@ -105,7 +105,8 @@ export class McpServer { inputSchema: tool.inputSchema ? (zodToJsonSchema(tool.inputSchema, { strictUnions: true, - pipeStrategy: 'input' + pipeStrategy: 'input', + $refStrategy: 'none' }) as Tool['inputSchema']) : EMPTY_OBJECT_JSON_SCHEMA, annotations: tool.annotations, @@ -115,7 +116,8 @@ export class McpServer { if (tool.outputSchema) { toolDefinition.outputSchema = zodToJsonSchema(tool.outputSchema, { strictUnions: true, - pipeStrategy: 'output' + pipeStrategy: 'output', + $refStrategy: 'none' }) as Tool['outputSchema']; }