-
Notifications
You must be signed in to change notification settings - Fork 643
Open
Labels
P3Nice to haves, rare edge casesNice to haves, rare edge casesenhancementNew feature or requestNew feature or requestneeds confirmationUnclear if still relevantUnclear if still relevant
Description
Similar issue to #1259 which was fixed in #1274.
Read / deserialization is still encoding to a string. We should try to keep as utf8 bytes and deserialize from those:
csharp-sdk/src/ModelContextProtocol.Core/Server/StreamServerTransport.cs
Lines 100 to 116 in 411cef6
| var line = await _inputReader.ReadLineAsync(shutdownToken).ConfigureAwait(false); | |
| if (string.IsNullOrWhiteSpace(line)) | |
| { | |
| if (line is null) | |
| { | |
| LogTransportEndOfStream(Name); | |
| break; | |
| } | |
| continue; | |
| } | |
| LogTransportReceivedMessageSensitive(Name, line); | |
| try | |
| { | |
| if (JsonSerializer.Deserialize(line, McpJsonUtilities.DefaultOptions.GetTypeInfo(typeof(JsonRpcMessage))) is JsonRpcMessage message) |
csharp-sdk/src/ModelContextProtocol.Core/Client/StreamClientSessionTransport.cs
Lines 108 to 121 in 411cef6
| if (await _serverOutput.ReadLineAsync(cancellationToken).ConfigureAwait(false) is not string line) | |
| { | |
| LogTransportEndOfStream(Name); | |
| break; | |
| } | |
| if (string.IsNullOrWhiteSpace(line)) | |
| { | |
| continue; | |
| } | |
| LogTransportReceivedMessageSensitive(Name, line); | |
| await ProcessMessageAsync(line, cancellationToken).ConfigureAwait(false); |
csharp-sdk/src/ModelContextProtocol.Core/Client/StreamClientSessionTransport.cs
Lines 140 to 145 in 411cef6
| private async Task ProcessMessageAsync(string line, CancellationToken cancellationToken) | |
| { | |
| try | |
| { | |
| var message = (JsonRpcMessage?)JsonSerializer.Deserialize(line.AsSpan().Trim(), McpJsonUtilities.DefaultOptions.GetTypeInfo(typeof(JsonRpcMessage))); | |
| if (message != null) |
Reactions are currently unavailable
Metadata
Metadata
Labels
P3Nice to haves, rare edge casesNice to haves, rare edge casesenhancementNew feature or requestNew feature or requestneeds confirmationUnclear if still relevantUnclear if still relevant