Skip to content

Commit de85bc8

Browse files
committed
test: register nested tool argument serialization metadata
AI assistance: Codex prepared this test-only change and validation summary. Signed-off-by: FenjuFu <[email protected]>
1 parent 39ec6e5 commit de85bc8

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎tests/ModelContextProtocol.Tests/Server/McpServerToolTests.cs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ public async Task BindsNestedArgumentPropertiesCaseInsensitively()
7272
{
7373
Mock<McpServer> mockServer = new();
7474

75-
McpServerTool tool = McpServerTool.Create((WeatherRequest request) => $"{request.Location?.City}/{request.Days}");
75+
JsonSerializerOptions options = new(McpJsonUtilities.DefaultOptions);
76+
options.TypeInfoResolverChain.Add(JsonContext2.Default);
77+
McpServerTool tool = McpServerTool.Create(
78+
(WeatherRequest request) => $"{request.Location?.City}/{request.Days}",
79+
new() { SerializerOptions = options });
7680

7781
var result = await tool.InvokeAsync(
7882
new RequestContext<CallToolRequestParams>(mockServer.Object, CreateTestJsonRpcRequest(), new()
@@ -1303,6 +1307,7 @@ public async Task EnablePollingAsync_ThrowsInvalidOperationException_WhenTranspo
13031307
[JsonSerializable(typeof(int?))]
13041308
[JsonSerializable(typeof(DateTimeOffset?))]
13051309
[JsonSerializable(typeof(Person))]
1310+
[JsonSerializable(typeof(WeatherRequest))]
13061311
partial class JsonContext2 : JsonSerializerContext;
13071312

13081313
// ===== x-mcp-header tests =====

0 commit comments

Comments
 (0)