|
| 1 | +diff --git a/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js b/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js |
| 2 | +index e10bb3d..2e99bee 100644 |
| 3 | +--- a/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js |
| 4 | ++++ b/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js |
| 5 | +@@ -197,15 +197,20 @@ class McpServer { |
| 6 | + return; |
| 7 | + } |
| 8 | + if (!result.structuredContent) { |
| 9 | +- throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Output validation error: Tool ${toolName} has an output schema but no structured content was provided`); |
| 10 | ++ // Log warning but don't throw - allow tools to omit structured content |
| 11 | ++ console.warn(`[MCP SDK Patch] Output validation warning: Tool ${toolName} has an output schema but no structured content was provided`); |
| 12 | + } |
| 13 | +- // if the tool has an output schema, validate structured content |
| 14 | +- const outputObj = (0, zod_compat_js_1.normalizeObjectSchema)(tool.outputSchema); |
| 15 | +- const parseResult = await (0, zod_compat_js_1.safeParseAsync)(outputObj, result.structuredContent); |
| 16 | +- if (!parseResult.success) { |
| 17 | +- const error = 'error' in parseResult ? parseResult.error : 'Unknown error'; |
| 18 | +- const errorMessage = (0, zod_compat_js_1.getParseErrorMessage)(error); |
| 19 | +- throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${toolName}: ${errorMessage}`); |
| 20 | ++ else { |
| 21 | ++ // if the tool has an output schema, validate structured content |
| 22 | ++ const outputObj = (0, zod_compat_js_1.normalizeObjectSchema)(tool.outputSchema); |
| 23 | ++ const parseResult = await (0, zod_compat_js_1.safeParseAsync)(outputObj, result.structuredContent); |
| 24 | ++ if (!parseResult.success) { |
| 25 | ++ const error = 'error' in parseResult ? parseResult.error : 'Unknown error'; |
| 26 | ++ const errorMessage = (0, zod_compat_js_1.getParseErrorMessage)(error); |
| 27 | ++ // Log warning but don't throw - allow schema mismatches |
| 28 | ++ console.warn(`[MCP SDK Patch] Output validation warning: Invalid structured content for tool ${toolName}: ${errorMessage}`); |
| 29 | ++ // Keep the structuredContent despite validation failure |
| 30 | ++ } |
| 31 | + } |
| 32 | + } |
| 33 | + /** |
| 34 | +diff --git a/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js b/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js |
| 35 | +index 23639ce..7b8a325 100644 |
| 36 | +--- a/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js |
| 37 | ++++ b/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js |
| 38 | +@@ -194,15 +194,20 @@ export class McpServer { |
| 39 | + return; |
| 40 | + } |
| 41 | + if (!result.structuredContent) { |
| 42 | +- throw new McpError(ErrorCode.InvalidParams, `Output validation error: Tool ${toolName} has an output schema but no structured content was provided`); |
| 43 | ++ // Log warning but don't throw - allow tools to omit structured content |
| 44 | ++ console.warn(`[MCP SDK Patch] Output validation warning: Tool ${toolName} has an output schema but no structured content was provided`); |
| 45 | + } |
| 46 | +- // if the tool has an output schema, validate structured content |
| 47 | +- const outputObj = normalizeObjectSchema(tool.outputSchema); |
| 48 | +- const parseResult = await safeParseAsync(outputObj, result.structuredContent); |
| 49 | +- if (!parseResult.success) { |
| 50 | +- const error = 'error' in parseResult ? parseResult.error : 'Unknown error'; |
| 51 | +- const errorMessage = getParseErrorMessage(error); |
| 52 | +- throw new McpError(ErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${toolName}: ${errorMessage}`); |
| 53 | ++ else { |
| 54 | ++ // if the tool has an output schema, validate structured content |
| 55 | ++ const outputObj = normalizeObjectSchema(tool.outputSchema); |
| 56 | ++ const parseResult = await safeParseAsync(outputObj, result.structuredContent); |
| 57 | ++ if (!parseResult.success) { |
| 58 | ++ const error = 'error' in parseResult ? parseResult.error : 'Unknown error'; |
| 59 | ++ const errorMessage = getParseErrorMessage(error); |
| 60 | ++ // Log warning but don't throw - allow schema mismatches |
| 61 | ++ console.warn(`[MCP SDK Patch] Output validation warning: Invalid structured content for tool ${toolName}: ${errorMessage}`); |
| 62 | ++ // Keep the structuredContent despite validation failure |
| 63 | ++ } |
| 64 | + } |
| 65 | + } |
| 66 | + /** |
0 commit comments