Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ private static Task WriteJsonRpcErrorAsync(HttpContext context, string errorMess
{
var jsonRpcError = new JsonRpcError
{
Id = default,
Error = new()
{
Code = errorCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ private protected JsonRpcMessageWithId()
/// Each ID is expected to be unique within the context of a given session.
/// </remarks>
[JsonPropertyName("id")]
public required RequestId Id { get; set; }
public RequestId Id { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ public static async Task<string> TestSamplingErrors(McpServer server)

var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendRequestAsync(new JsonRpcRequest
{
Id = default,
Method = RequestMethods.SamplingCreateMessage
}));
return ex.Message;
Expand All @@ -222,7 +221,6 @@ public static async Task<string> TestRootsErrors(McpServer server)

var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendRequestAsync(new JsonRpcRequest
{
Id = default,
Method = RequestMethods.RootsList
}));
return ex.Message;
Expand All @@ -241,7 +239,6 @@ public static async Task<string> TestElicitationErrors(McpServer server)

var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendRequestAsync(new JsonRpcRequest
{
Id = default,
Method = RequestMethods.ElicitationCreate
}));
return ex.Message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ public async Task PingAsync_Forwards_To_McpClient_SendRequestAsync()
.Setup(c => c.SendRequestAsync(It.IsAny<JsonRpcRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new JsonRpcResponse
{
Id = default,
Result = JsonSerializer.SerializeToNode(new object(), McpJsonUtilities.DefaultOptions),
});

Expand All @@ -226,7 +225,6 @@ public async Task GetPromptAsync_Forwards_To_McpClient_SendRequestAsync()
.Setup(c => c.SendRequestAsync(It.IsAny<JsonRpcRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new JsonRpcResponse
{
Id = default,
Result = JsonSerializer.SerializeToNode(resultPayload, McpJsonUtilities.DefaultOptions),
});

Expand All @@ -249,7 +247,6 @@ public async Task CallToolAsync_Forwards_To_McpClient_SendRequestAsync()
.Setup(c => c.SendRequestAsync(It.IsAny<JsonRpcRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new JsonRpcResponse
{
Id = default,
Result = JsonSerializer.SerializeToNode(callResult, McpJsonUtilities.DefaultOptions),
});

Expand All @@ -270,7 +267,6 @@ public async Task SubscribeToResourceAsync_Forwards_To_McpClient_SendRequestAsyn
.Setup(c => c.SendRequestAsync(It.IsAny<JsonRpcRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new JsonRpcResponse
{
Id = default,
Result = JsonSerializer.SerializeToNode(new EmptyResult(), McpJsonUtilities.DefaultOptions),
});

Expand All @@ -290,7 +286,6 @@ public async Task UnsubscribeFromResourceAsync_Forwards_To_McpClient_SendRequest
.Setup(c => c.SendRequestAsync(It.IsAny<JsonRpcRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new JsonRpcResponse
{
Id = default,
Result = JsonSerializer.SerializeToNode(new EmptyResult(), McpJsonUtilities.DefaultOptions),
});

Expand All @@ -313,7 +308,6 @@ public async Task CompleteAsync_Forwards_To_McpClient_SendRequestAsync()
.Setup(c => c.SendRequestAsync(It.IsAny<JsonRpcRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new JsonRpcResponse
{
Id = default,
Result = JsonSerializer.SerializeToNode(resultPayload, McpJsonUtilities.DefaultOptions),
});

Expand All @@ -336,7 +330,6 @@ public async Task ReadResourceAsync_String_Forwards_To_McpClient_SendRequestAsyn
.Setup(c => c.SendRequestAsync(It.IsAny<JsonRpcRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new JsonRpcResponse
{
Id = default,
Result = JsonSerializer.SerializeToNode(resultPayload, McpJsonUtilities.DefaultOptions),
});

Expand All @@ -359,7 +352,6 @@ public async Task ReadResourceAsync_Uri_Forwards_To_McpClient_SendRequestAsync()
.Setup(c => c.SendRequestAsync(It.IsAny<JsonRpcRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new JsonRpcResponse
{
Id = default,
Result = JsonSerializer.SerializeToNode(resultPayload, McpJsonUtilities.DefaultOptions),
});

Expand All @@ -382,7 +374,6 @@ public async Task ReadResourceAsync_Template_Forwards_To_McpClient_SendRequestAs
.Setup(c => c.SendRequestAsync(It.IsAny<JsonRpcRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new JsonRpcResponse
{
Id = default,
Result = JsonSerializer.SerializeToNode(resultPayload, McpJsonUtilities.DefaultOptions),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public async Task SendRequestAsync_Generic_Forwards_To_McpSession_SendRequestAsy
.Setup(s => s.SendRequestAsync(It.IsAny<JsonRpcRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new JsonRpcResponse
{
Id = default,
Result = JsonSerializer.SerializeToNode(42, McpJsonUtilities.DefaultOptions),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public async Task SampleAsync_Request_Forwards_To_McpServer_SendRequestAsync()
.Setup(s => s.SendRequestAsync(It.IsAny<JsonRpcRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new JsonRpcResponse
{
Id = default,
Result = JsonSerializer.SerializeToNode(resultPayload, McpJsonUtilities.DefaultOptions),
});

Expand Down Expand Up @@ -146,7 +145,6 @@ public async Task SampleAsync_Messages_Forwards_To_McpServer_SendRequestAsync()
})
.ReturnsAsync(new JsonRpcResponse
{
Id = default,
Result = JsonSerializer.SerializeToNode(resultPayload, McpJsonUtilities.DefaultOptions),
});

Expand All @@ -159,7 +157,7 @@ public async Task SampleAsync_Messages_Forwards_To_McpServer_SendRequestAsync()
Assert.Equal(ChatRole.Assistant, last.Role);
Assert.Equal("resp", last.Text);
mockServer.Verify(s => s.SendRequestAsync(It.IsAny<JsonRpcRequest>(), It.IsAny<CancellationToken>()), Times.Once);

// Verify that the default value was used
Assert.NotNull(capturedRequest);
Assert.Equal(CustomMaxSamplingOutputTokens, capturedRequest.MaxTokens);
Expand All @@ -180,7 +178,6 @@ public async Task RequestRootsAsync_Forwards_To_McpServer_SendRequestAsync()
.Setup(s => s.SendRequestAsync(It.IsAny<JsonRpcRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new JsonRpcResponse
{
Id = default,
Result = JsonSerializer.SerializeToNode(resultPayload, McpJsonUtilities.DefaultOptions),
});

Expand All @@ -207,7 +204,6 @@ public async Task ElicitAsync_Forwards_To_McpServer_SendRequestAsync()
.Setup(s => s.SendRequestAsync(It.IsAny<JsonRpcRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new JsonRpcResponse
{
Id = default,
Result = JsonSerializer.SerializeToNode(resultPayload, McpJsonUtilities.DefaultOptions),
});

Expand Down
Loading