Fix missing resultType on complete result responses (#1684)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Tarek Mahmoud Sayed <tarekms@ntdev.microsoft.com>
This commit is contained in:
Pranav Senthilnathan 2026-07-12 21:24:21 -04:00 • committed by GitHub
commit 374e76eecd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -58,6 +58,21 @@ public class McpServerTaskTests : ClientServerTestBase
};
}
if (toolName == "async-tool-default-resulttype")
{
// Intentionally leaves ResultType unset so the server boundary is responsible for
// filling in "task" on the wire.
var taskId = store.CreateTask();
return new CreateTaskResult
{
TaskId = taskId,
Status = McpTaskStatus.Working,
CreatedAt = DateTimeOffset.UtcNow,
LastUpdatedAt = DateTimeOffset.UtcNow,
PollIntervalMs = 50,
};
}
if (toolName == "input-required-tool")
{
var taskId = store.CreateTask(McpTaskStatus.InputRequired);
@ -292,6 +307,19 @@ public class McpServerTaskTests : ClientServerTestBase
Assert.Equal("task", augmented.TaskCreated!.ResultType);
}
[Fact]
public async Task CreateTaskResult_WithoutExplicitResultType_ServerFillsTask()
{
await using var client = await CreateMcpClientForServer();
var augmented = await client.CallToolRawAsync(
new CallToolRequestParams { Name = "async-tool-default-resulttype" },
TestContext.Current.CancellationToken);
Assert.True(augmented.IsTask);
Assert.Equal("task", augmented.TaskCreated!.ResultType);
}
[Fact]
public async Task GetTaskAsync_ImmediatelyAfterCreate_Resolves()
{