Skip to content

Commit 6330dd0

Browse files
committed
Address PR feedback
1 parent 3e4308f commit 6330dd0

File tree

5 files changed

+5
-9
lines changed

5 files changed

+5
-9
lines changed

src/ModelContextProtocol/Protocol/Messages/ProgressNotification.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ public sealed class Converter : JsonConverter<ProgressNotification>
4242
switch (propertyName)
4343
{
4444
case "progressToken":
45-
if (JsonSerializer.Deserialize(ref reader, options.GetTypeInfo(typeof(ProgressToken))) is not ProgressToken token)
46-
{
47-
throw new JsonException("Invalid value for 'progressToken'.");
48-
}
49-
progressToken = token;
45+
progressToken = (ProgressToken)JsonSerializer.Deserialize(ref reader, options.GetTypeInfo(typeof(ProgressToken)))!;
5046
break;
5147

5248
case "progress":

src/ModelContextProtocol/Protocol/Messages/ProgressToken.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public ProgressToken(long value)
3636

3737
/// <inheritdoc />
3838
public override string? ToString() =>
39-
_id is string stringValue ? stringValue :
39+
_id is string stringValue ? $"\"{stringValue}\"" :
4040
_id is long longValue ? longValue.ToString(CultureInfo.InvariantCulture) :
4141
null;
4242

src/ModelContextProtocol/Protocol/Messages/RequestId.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public RequestId(long value)
3636

3737
/// <inheritdoc />
3838
public override string ToString() =>
39-
_id is string stringValue ? stringValue :
39+
_id is string stringValue ? $"\"{stringValue}\"" :
4040
_id is long longValue ? longValue.ToString(CultureInfo.InvariantCulture) :
4141
string.Empty;
4242

tests/ModelContextProtocol.Tests/Configuration/McpServerBuilderExtensionsToolsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ public async Task HandlesIProgressParameter()
554554
Assert.Equal(10, array.Length);
555555
for (int i = 0; i < array.Length; i++)
556556
{
557-
Assert.Equal("abc123", array[i].ProgressToken.ToString());
557+
Assert.Equal("\"abc123\"", array[i].ProgressToken.ToString());
558558
Assert.Equal(i, array[i].Progress.Progress);
559559
Assert.Equal(10, array[i].Progress.Total);
560560
Assert.Equal($"Progress {i}", array[i].Progress.Message);

tests/ModelContextProtocol.Tests/Transport/SseClientTransportTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public async Task ReceiveMessagesAsync_Handles_Messages()
214214
Assert.True(session.MessageReader.TryRead(out var message));
215215
Assert.NotNull(message);
216216
Assert.IsType<JsonRpcRequest>(message);
217-
Assert.Equal("44", ((JsonRpcRequest)message).Id.ToString());
217+
Assert.Equal("\"44\"", ((JsonRpcRequest)message).Id.ToString());
218218
}
219219

220220
[Fact]

0 commit comments

Comments
 (0)