fastmcp/tests/client
marvin-context-protocol[bot] 98edf1a05d Implement SSE fallback for 405 errors in MCP client
Add backwards compatibility support for MCP clients when connecting to SSE-only servers.
When a StreamableHttpTransport receives a 405 Method Not Allowed error, the client now
automatically falls back to SSETransport using the same URL and authentication settings.

This implements the backwards compatibility requirement from the MCP specification:
https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#backwards-compatibility

Key changes:
- Modified Client._context_manager() to detect 405 errors from StreamableHttpTransport
- Automatically retry with SSETransport preserving auth, headers, and timeouts
- Added comprehensive test coverage for fallback behavior
- Non-405 HTTP errors are re-raised without fallback attempt

Fixes #853

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: William Easton <strawgate@users.noreply.github.com>
2025-08-28 22:37:37 +00:00
..
auth Remove trailing slash in unit tests (#1535) 2025-08-18 08:10:46 -04:00
transports Add UV Transport (#1270) 2025-07-28 15:41:36 -04:00
__init__.py clean up test inits 2025-05-31 19:32:08 -04:00
test_client.py Implement SSE fallback for 405 errors in MCP client 2025-08-28 22:37:37 +00:00
test_elicitation.py Fix elicitation enums (#1632) 2025-08-25 22:14:00 -04:00
test_logs.py Fix client-side logging bug #1394 (#1397) 2025-08-08 11:37:10 -04:00
test_notifications.py Add structured content & update almost all tests 2025-06-27 15:40:52 -04:00
test_openapi_experimental.py Improve redirect handling to address 307's (#1387) 2025-08-08 11:55:30 -04:00
test_openapi_legacy.py Improve redirect handling to address 307's (#1387) 2025-08-08 11:55:30 -04:00
test_progress.py Remove empty parens 2025-06-04 15:37:55 -04:00
test_roots.py Add structured content & update almost all tests 2025-06-27 15:40:52 -04:00
test_sampling.py Fallback to a Completions API when Sampling is not available (#1145) 2025-08-21 07:49:29 -04:00
test_sse.py Remove trailing slash in unit tests (#1535) 2025-08-18 08:10:46 -04:00
test_stdio.py stdio client updates 2025-08-25 22:37:24 -05:00
test_streamable_http.py Improve redirect handling to address 307's (#1387) 2025-08-08 11:55:30 -04:00