From dd9034b9c507cb941eb303df13c1973d69f9876d Mon Sep 17 00:00:00 2001 From: Yufeng He <40085740+he-yufeng@users.noreply.github.com> Date: Thu, 21 May 2026 02:14:26 +0800 Subject: [PATCH] fix: request identity encoding for streamable HTTP --- src/mcp/client/streamable_http.py | 1 + tests/shared/test_streamable_http.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/mcp/client/streamable_http.py b/src/mcp/client/streamable_http.py index 9a119c633..db681c966 100644 --- a/src/mcp/client/streamable_http.py +++ b/src/mcp/client/streamable_http.py @@ -90,6 +90,7 @@ def _prepare_headers(self) -> dict[str, str]: """ headers: dict[str, str] = { "accept": "application/json, text/event-stream", + "accept-encoding": "identity", "content-type": "application/json", } # Add session headers if available diff --git a/tests/shared/test_streamable_http.py b/tests/shared/test_streamable_http.py index 3d5770fb6..05dbce2d8 100644 --- a/tests/shared/test_streamable_http.py +++ b/tests/shared/test_streamable_http.py @@ -2283,6 +2283,8 @@ async def test_streamable_http_client_mcp_headers_override_defaults( assert "content-type" in headers_data assert headers_data["content-type"] == "application/json" + assert headers_data.get("accept-encoding") == "identity" + @pytest.mark.anyio async def test_streamable_http_client_preserves_custom_with_mcp_headers( @@ -2318,3 +2320,5 @@ async def test_streamable_http_client_preserves_custom_with_mcp_headers( assert "content-type" in headers_data assert headers_data["content-type"] == "application/json" + + assert headers_data.get("accept-encoding") == "identity"