|
| 1 | +diff --git a/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js b/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js |
| 2 | +index 23639ce..7b8a325 100644 |
| 3 | +--- a/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js |
| 4 | ++++ b/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js |
| 5 | +@@ -194,15 +194,20 @@ export class McpServer { |
| 6 | + return; |
| 7 | + } |
| 8 | + if (!result.structuredContent) { |
| 9 | +- throw new McpError(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 = normalizeObjectSchema(tool.outputSchema); |
| 15 | +- const parseResult = await safeParseAsync(outputObj, result.structuredContent); |
| 16 | +- if (!parseResult.success) { |
| 17 | +- const error = 'error' in parseResult ? parseResult.error : 'Unknown error'; |
| 18 | +- const errorMessage = getParseErrorMessage(error); |
| 19 | +- throw new McpError(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 = normalizeObjectSchema(tool.outputSchema); |
| 23 | ++ const parseResult = await safeParseAsync(outputObj, result.structuredContent); |
| 24 | ++ if (!parseResult.success) { |
| 25 | ++ const error = 'error' in parseResult ? parseResult.error : 'Unknown error'; |
| 26 | ++ const errorMessage = 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 | + /** |
0 commit comments