Should McpClient normalize JSON-RPC errors across stdio and Streamable HTTP #1847
Pre-submission Checklist
Question Category
Your QuestionWe are adding Streamable HTTP coverage to the Azure MCP Server and found that unsupported MCP methods produce different client exceptions depending on transport when using C# MCP SDK 2.1.0: stdio: Is this transport-dependent client behavior intentional and part of the expected public contract? More generally: Should callers catch both |
Replies: 1 comment
|
For C# SDK 2.1.0, the behavior you observed matches the current implementation, but it is an SDK compatibility choice rather than a transport-independent MCP contract.
Every other non-success status—including a 404 carrying So, today:
SEP-2575 requires an unsupported 2026 RPC to use both HTTP 404 and JSON-RPC I do not see a complete public server-error-to-client-exception matrix in the current C# SDK docs. Given that the response is a valid addressed JSON-RPC error, normalizing it would make cross-transport callers simpler—but it would be a behavioral change and needs a narrowly scoped SDK issue/test that preserves the distinct session-expired and plain HTTP 404 paths. For Azure MCP Server tests on 2.1.0, I would assert both the exception type and the HTTP/JSON-RPC evidence per transport rather than collapsing all 404s into MethodNotFound. |
For C# SDK 2.1.0, the behavior you observed matches the current implementation, but it is an SDK compatibility choice rather than a transport-independent MCP contract.
StreamableHttpClientSessionTransportconverts a parsed JSON-RPC error toMcpProtocolExceptiononly when either:HeaderMismatch,MissingRequiredClientCapability, orUnsupportedProtocolVersion).Every other non-success status—including a 404 carrying
-32601 MethodNotFound—continues throughEnsureSuccessStatusCode...and becomesHttpRequestException. The source comment says this preserves compatibility with transport-level 404 behavior:h…