-
Notifications
You must be signed in to change notification settings - Fork 629
Open
Labels
bugSomething isn't workingSomething isn't working
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
bugSomething isn't workingSomething isn't working