Make McpJsonUtilities public and remove IVT to sample (#5)

Also adds in the same encoder used by AIJsonUtilities.
This commit is contained in:
Stephen Toub 2025-03-20 10:00:23 -04:00 • committed by GitHub
commit 6b8c288029
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 56 additions and 27 deletions

View file

@ -45,7 +45,7 @@ public static class McpEndpointRouteBuilderExtensions
return;
}
var message = await context.Request.ReadFromJsonAsync<IJsonRpcMessage>(JsonSerializerOptionsExtensions.DefaultOptions, context.RequestAborted);
var message = await context.Request.ReadFromJsonAsync<IJsonRpcMessage>(McpJsonUtilities.DefaultOptions, context.RequestAborted);
if (message is null)
{
await Results.BadRequest("No message in request body.").ExecuteAsync(context);

View file

@ -28,7 +28,7 @@ public class SseServerStreamTransport(Stream sseResponseStream) : ITransport
return;
}
JsonSerializer.Serialize(GetUtf8JsonWriter(writer), item.Data, JsonSerializerOptionsExtensions.DefaultOptions);
JsonSerializer.Serialize(GetUtf8JsonWriter(writer), item.Data, McpJsonUtilities.DefaultOptions);
}
// The very first SSE event isn't really an IJsonRpcMessage, but there's no API to write a single item of a different type,