Skip to content

Commit 86f8afe

Browse files
committed
Use 3-arg RequestContext constructor in ref-rewrite tests
Migrate to the non-obsolete RequestContext overload that accepts a parameters argument, fixing CI build error MCP9003.
1 parent b15e7b2 commit 86f8afe

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

tests/ModelContextProtocol.Tests/Server/McpServerToolTests.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -813,12 +813,9 @@ public async Task StructuredOutput_WithDuplicateTypeRefs_RewritesRefPointers()
813813
JsonSerializerOptions options = new() { TypeInfoResolver = new DefaultJsonTypeInfoResolver() };
814814
McpServerTool tool = McpServerTool.Create(() => data, new() { Name = "tool", UseStructuredContent = true, SerializerOptions = options });
815815
var mockServer = new Mock<McpServer>();
816-
var request = new RequestContext<CallToolRequestParams>(mockServer.Object, CreateTestJsonRpcRequest())
817-
{
818-
Params = new CallToolRequestParams { Name = "tool" },
819-
};
820-
821-
var result = await tool.InvokeAsync(request, TestContext.Current.CancellationToken);
816+
var result = await tool.InvokeAsync(
817+
new RequestContext<CallToolRequestParams>(mockServer.Object, CreateTestJsonRpcRequest(), new() { Name = "tool" }),
818+
TestContext.Current.CancellationToken);
822819

823820
Assert.NotNull(tool.ProtocolTool.OutputSchema);
824821
Assert.Equal("object", tool.ProtocolTool.OutputSchema.Value.GetProperty("type").GetString());
@@ -858,12 +855,9 @@ public async Task StructuredOutput_WithRecursiveTypeRefs_RewritesRefPointers()
858855
JsonSerializerOptions options = new() { TypeInfoResolver = new DefaultJsonTypeInfoResolver() };
859856
McpServerTool tool = McpServerTool.Create(() => data, new() { Name = "tool", UseStructuredContent = true, SerializerOptions = options });
860857
var mockServer = new Mock<McpServer>();
861-
var request = new RequestContext<CallToolRequestParams>(mockServer.Object, CreateTestJsonRpcRequest())
862-
{
863-
Params = new CallToolRequestParams { Name = "tool" },
864-
};
865-
866-
var result = await tool.InvokeAsync(request, TestContext.Current.CancellationToken);
858+
var result = await tool.InvokeAsync(
859+
new RequestContext<CallToolRequestParams>(mockServer.Object, CreateTestJsonRpcRequest(), new() { Name = "tool" }),
860+
TestContext.Current.CancellationToken);
867861

868862
Assert.NotNull(tool.ProtocolTool.OutputSchema);
869863
Assert.Equal("object", tool.ProtocolTool.OutputSchema.Value.GetProperty("type").GetString());

0 commit comments

Comments
 (0)