Add client completion notification and details (#1368)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
4af2596019
commit
b965a7eca6
1 changed files with 691 additions and 31 deletions
|
|
@ -181,6 +181,23 @@ internal static class Program
|
|||
{
|
||||
TaskSupport = ToolTaskSupport.Optional
|
||||
}
|
||||
},
|
||||
new Tool
|
||||
{
|
||||
Name = "crash",
|
||||
Description = "Terminates the server process with a specified exit code.",
|
||||
InputSchema = JsonElement.Parse("""
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"exitCode": {
|
||||
"type": "number",
|
||||
"description": "The exit code to terminate with"
|
||||
}
|
||||
},
|
||||
"required": ["exitCode"]
|
||||
}
|
||||
"""),
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
@ -241,6 +258,17 @@ internal static class Program
|
|||
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))
|
||||
{
|
||||
throw new McpProtocolException("Missing required argument 'exitCode'", McpErrorCode.InvalidParams);
|
||||
}
|
||||
int exitCode = Convert.ToInt32(exitCodeValue.GetRawText());
|
||||
Console.Error.WriteLine($"Crashing with exit code {exitCode}");
|
||||
Environment.Exit(exitCode);
|
||||
throw new Exception("unreachable");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new McpProtocolException($"Unknown tool: {request.Params?.Name}", McpErrorCode.InvalidParams);
|
||||
|
|
|
|||
Loading…
Reference in a new issue