Implement SEP-2663 Tasks Extension (#1579)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
ed07fdb6f4
commit
dbb7a20176
1 changed files with 8190 additions and 11405 deletions
|
|
@ -162,27 +162,6 @@ internal static 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
|
||||
}
|
||||
},
|
||||
new Tool
|
||||
{
|
||||
Name = "crash",
|
||||
Description = "Terminates the server process with a specified exit code.",
|
||||
|
|
@ -245,19 +224,6 @@ internal static class Program
|
|||
Content = [new TextContentBlock { Text = cliArg ?? "null" }]
|
||||
};
|
||||
}
|
||||
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.GetRawText());
|
||||
await Task.Delay(durationMs, cancellationToken);
|
||||
return new CallToolResult
|
||||
{
|
||||
Content = [new TextContentBlock { Text = $"Long-running operation completed after {durationMs}ms" }]
|
||||
};
|
||||
}
|
||||
else if (request.Params.Name == "crash")
|
||||
{
|
||||
if (request.Params.Arguments is null || !request.Params.Arguments.TryGetValue("exitCode", out var exitCodeValue))
|
||||
|
|
|
|||
Loading…
Reference in a new issue