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"