Relax outputSchema to any JSON Schema 2020-12 document per SEP-2106 (#1568)

Co-authored-by: Mike Kistler <mikekistler@microsoft.com>
This commit is contained in:
Jayaraman Venkatesan 2026-06-16 18:02:04 -04:00 • committed by GitHub
commit 0663b7c878
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -825,9 +825,22 @@ internal sealed partial class McpServerImpl : McpServer
if (request.Params?.Cursor is null)
{
// SEP-2106 wire shaping: clients on protocol versions older than
// 2026-06-30 require outputSchema.type == "object", so the natural
// schema is reshaped before emission (type:["object","null"] normalized
// to "object", any other non-object schema wrapped in
// {"type":"object","properties":{"result":<schema>}}). Clients on
// 2026-06-30+ receive the natural JSON Schema 2020-12 document stored
// on Tool.OutputSchema. Only AIFunctionMcpServerTool tools go through
// reshaping; custom McpServerTool subclasses build their Tool directly
// and pass through unchanged at every protocol version.
bool useNaturalSchemas = McpSessionHandler.SupportsNaturalOutputSchemas(request.Server.NegotiatedProtocolVersion);
foreach (var t in tools)
{
result.Tools.Add(t.ProtocolTool);
Tool wireTool = useNaturalSchemas || t is not AIFunctionMcpServerTool aiFunctionTool
? t.ProtocolTool
: aiFunctionTool.BuildLegacyWireProtocolTool();
result.Tools.Add(wireTool);
}
}