Add client completion notification and details (#1368)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Stephen Toub 2026-03-02 09:17:22 -05:00 • committed by GitHub
commit b965a7eca6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);