Implement SEP-2663 Tasks Extension (#1579)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Pranav Senthilnathan 2026-06-11 13:10:45 -07:00 • committed by GitHub
commit dbb7a20176
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1283,82 +1283,6 @@ public partial class McpServerToolTests
Assert.Contains("Streamable HTTP", exception.Message);
}
[Fact]
public void AsyncTool_AutomaticallyMarkedWithTaskSupport()
{
// Async tools should automatically get TaskSupport = Optional
McpServerTool tool = McpServerTool.Create(AsyncToolReturningTask);
Assert.NotNull(tool.ProtocolTool.Execution);
Assert.Equal(ToolTaskSupport.Optional, tool.ProtocolTool.Execution.TaskSupport);
}
[Fact]
public void AsyncTool_ValueTask_AutomaticallyMarkedWithTaskSupport()
{
// Async tools returning ValueTask should also get TaskSupport = Optional
McpServerTool tool = McpServerTool.Create(AsyncToolReturningValueTask);
Assert.NotNull(tool.ProtocolTool.Execution);
Assert.Equal(ToolTaskSupport.Optional, tool.ProtocolTool.Execution.TaskSupport);
}
[Fact]
public void AsyncTool_TaskOfT_AutomaticallyMarkedWithTaskSupport()
{
// Async tools returning Task<T> should get TaskSupport = Optional
McpServerTool tool = McpServerTool.Create(AsyncToolReturningTaskOfT);
Assert.NotNull(tool.ProtocolTool.Execution);
Assert.Equal(ToolTaskSupport.Optional, tool.ProtocolTool.Execution.TaskSupport);
}
[Fact]
public void AsyncTool_ValueTaskOfT_AutomaticallyMarkedWithTaskSupport()
{
// Async tools returning ValueTask<T> should get TaskSupport = Optional
McpServerTool tool = McpServerTool.Create(AsyncToolReturningValueTaskOfT);
Assert.NotNull(tool.ProtocolTool.Execution);
Assert.Equal(ToolTaskSupport.Optional, tool.ProtocolTool.Execution.TaskSupport);
}
[Fact]
public void SyncTool_NotMarkedWithTaskSupport()
{
// Synchronous tools should not have TaskSupport set
McpServerTool tool = McpServerTool.Create(SyncTool);
Assert.Null(tool.ProtocolTool.Execution);
}
private static async Task AsyncToolReturningTask()
{
await Task.Yield();
}
private static async ValueTask AsyncToolReturningValueTask()
{
await Task.Yield();
}
private static async Task<string> AsyncToolReturningTaskOfT()
{
await Task.Yield();
return "result";
}
private static async ValueTask<string> AsyncToolReturningValueTaskOfT()
{
await Task.Yield();
return "result";
}
private static string SyncTool()
{
return "sync result";
}
[Description("Tool that returns data.")]
[return: Description("The computed result")]
private static string ToolWithReturnDescription() => "result";