Skip to content

Commit 98c7a88

Browse files
committed
feat: integrate structured output validation in server
Add mandatory structured output validation in the handleToolCall flow. This ensures that any tool result with a defined output schema is validated before being sent to the client, as required by the MCP protocol.
1 parent 72b1723 commit 98c7a88

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

server/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,9 @@ func (s *MCPServer) handleToolCall(
10341034
}
10351035
}
10361036

1037+
if err := tool.Tool.ValidateStructuredOutput(result); err != nil {
1038+
return mcp.NewToolResultErrorFromErr("tool output schema validation failed", err), nil
1039+
}
10371040
return result, nil
10381041
}
10391042

0 commit comments

Comments
 (0)