Commit 276bde4
Surface HeaderMismatch errors instead of falling back to legacy
McpClientImpl.ConnectAsync's draft probe path catches McpProtocolException to
fall back to a legacy `initialize` exchange. The handler had passthrough
cases for the two modern draft error codes whose semantics are not ""I'm a
legacy server"" (UnsupportedProtocolVersion -32004 and
MissingRequiredClientCapability -32003) but was missing the third:
HeaderMismatch -32001 from SEP-2243. That code means the body's
`_meta.io.modelcontextprotocol/protocolVersion` does not match the
`MCP-Protocol-Version` HTTP header — which is a client-side bug that should
surface to the caller, not a signal to retry with `initialize`.
Add the third passthrough so all three modern draft codes propagate, with an
in-memory transport regression test that exercises the path against a server
which only returns `-32001`.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 00d57f7 commit 276bde4
2 files changed
Lines changed: 35 additions & 2 deletions
File tree
- src/ModelContextProtocol.Core/Client
- tests/ModelContextProtocol.Tests/Client
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
343 | 351 | | |
344 | 352 | | |
345 | 353 | | |
346 | 354 | | |
347 | 355 | | |
348 | 356 | | |
349 | 357 | | |
350 | | - | |
| 358 | + | |
351 | 359 | | |
352 | | - | |
| 360 | + | |
| 361 | + | |
353 | 362 | | |
354 | 363 | | |
355 | 364 | | |
| |||
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
99 | 123 | | |
100 | 124 | | |
101 | 125 | | |
| |||
0 commit comments