Improve progress reporting (#145)
* Improve progress reporting - Enable injecting an `IProgress<>` into a tool call to report progress when the client has supplied a progress token - Add a custom type for ProgressToken and ProgressNotification to map to the schema - Simplify RequestId to match ProgressToken's shape - Serialize StdioClientTransport's SendMessageAsync implementation - Add strongly-typed names for all request methods - Change all request IDs created by McpJsonRpcEndpoint to include a guid for that endpoint * Address PR feedback
This commit is contained in:
parent
0294c574a6
commit
2c75acded8
1 changed files with 627 additions and 228 deletions
|
|
@ -77,7 +77,7 @@ public class StdioServerTransportTests : LoggedTest
|
|||
// Verify transport is connected
|
||||
Assert.True(transport.IsConnected, "Transport should be connected after StartListeningAsync");
|
||||
|
||||
var message = new JsonRpcRequest { Method = "test", Id = RequestId.FromNumber(44) };
|
||||
var message = new JsonRpcRequest { Method = "test", Id = new RequestId(44) };
|
||||
|
||||
await transport.SendMessageAsync(message, TestContext.Current.CancellationToken);
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ public class StdioServerTransportTests : LoggedTest
|
|||
[Fact]
|
||||
public async Task ReadMessagesAsync_Should_Read_Messages()
|
||||
{
|
||||
var message = new JsonRpcRequest { Method = "test", Id = RequestId.FromNumber(44) };
|
||||
var message = new JsonRpcRequest { Method = "test", Id = new RequestId(44) };
|
||||
var json = JsonSerializer.Serialize(message, McpJsonUtilities.DefaultOptions);
|
||||
|
||||
// Use a reader that won't terminate
|
||||
|
|
@ -125,7 +125,7 @@ public class StdioServerTransportTests : LoggedTest
|
|||
Assert.True(transport.MessageReader.TryPeek(out var readMessage));
|
||||
Assert.NotNull(readMessage);
|
||||
Assert.IsType<JsonRpcRequest>(readMessage);
|
||||
Assert.Equal(44, ((JsonRpcRequest)readMessage).Id.AsNumber);
|
||||
Assert.Equal("44", ((JsonRpcRequest)readMessage).Id.ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -158,7 +158,7 @@ public class StdioServerTransportTests : LoggedTest
|
|||
var chineseMessage = new JsonRpcRequest
|
||||
{
|
||||
Method = "test",
|
||||
Id = RequestId.FromNumber(44),
|
||||
Id = new RequestId(44),
|
||||
Params = new Dictionary<string, JsonElement>
|
||||
{
|
||||
["text"] = JsonSerializer.SerializeToElement(chineseText)
|
||||
|
|
@ -180,7 +180,7 @@ public class StdioServerTransportTests : LoggedTest
|
|||
var emojiMessage = new JsonRpcRequest
|
||||
{
|
||||
Method = "test",
|
||||
Id = RequestId.FromNumber(45),
|
||||
Id = new RequestId(45),
|
||||
Params = new Dictionary<string, JsonElement>
|
||||
{
|
||||
["text"] = JsonSerializer.SerializeToElement(emojiText)
|
||||
|
|
|
|||
Loading…
Reference in a new issue