Add Trace-level logging for JSON-RPC payloads in transports (#1191)

This commit is contained in:
Copilot 2026-01-29 11:26:33 -08:00 • committed by GitHub
commit ee8c485d41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -74,7 +74,9 @@ public class StreamServerTransport : TransportBase
try
{
await JsonSerializer.SerializeAsync(_outputStream, message, McpJsonUtilities.DefaultOptions.GetTypeInfo(typeof(JsonRpcMessage)), cancellationToken).ConfigureAwait(false);
var json = JsonSerializer.Serialize(message, McpJsonUtilities.JsonContext.Default.JsonRpcMessage);
LogTransportSendingMessageSensitive(Name, json);
await _outputStream.WriteAsync(Encoding.UTF8.GetBytes(json), cancellationToken).ConfigureAwait(false);
await _outputStream.WriteAsync(s_newlineBytes, cancellationToken).ConfigureAwait(false);
await _outputStream.FlushAsync(cancellationToken).ConfigureAwait(false);
}