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

@ -146,27 +146,6 @@ public class Program
}
"""),
},
new Tool
{
Name = "longRunning",
Description = "Simulates a long-running operation that supports task-based execution.",
InputSchema = JsonElement.Parse("""
{
"type": "object",
"properties": {
"durationMs": {
"type": "number",
"description": "Duration of the operation in milliseconds"
}
},
"required": ["durationMs"]
}
"""),
Execution = new ToolExecution
{
TaskSupport = ToolTaskSupport.Optional
}
}
]
};
},
@ -212,19 +191,6 @@ public class Program
Content = [new TextContentBlock { Text = $"LLM sampling result: {sampleResult.Content.OfType<TextContentBlock>().FirstOrDefault()?.Text}" }]
};
}
else if (request.Params.Name == "longRunning")
{
if (request.Params.Arguments is null || !request.Params.Arguments.TryGetValue("durationMs", out var durationMsValue))
{
throw new McpProtocolException("Missing required argument 'durationMs'", McpErrorCode.InvalidParams);
}
int durationMs = Convert.ToInt32(durationMsValue.ToString());
await Task.Delay(durationMs, cancellationToken);
return new CallToolResult
{
Content = [new TextContentBlock { Text = $"Long-running operation completed after {durationMs}ms" }]
};
}
else
{
throw new McpProtocolException($"Unknown tool: '{request.Params.Name}'", McpErrorCode.InvalidParams);