Skip to content

fix: send complete Accept header in SSE client - #848

Open
SomSamantray wants to merge 4 commits into
elevenlabs:mainfrom
SomSamantray:fix/671-sse-accept-header
Open

fix: send complete Accept header in SSE client#848
SomSamantray wants to merge 4 commits into
elevenlabs:mainfrom
SomSamantray:fix/671-sse-accept-header

Conversation

@SomSamantray

@SomSamantray SomSamantray commented Aug 15, 2026

Copy link
Copy Markdown

Summary

SSE connections from connect_sse and aconnect_sse now send Accept: application/json, text/event-stream instead of Accept: text/event-stream. Servers that validate the Accept header (e.g. Composio MCP, issue #671) previously rejected the request with 406. text/event-stream is retained, so strict SSE servers keep working.

The hand-edited Fern-generated module is protected from regeneration via .fernignore, and regression tests cover the sync and async paths, header preservation, and the response content-type guard.

Fixes #671

Test plan

  • pytest tests/test_http_sse.py - 6 new tests pass.
  • Full suite: 190 passed. Remaining failures are pre-existing API-key/network tests requiring ELEVENLABS_API_KEY (CI provides it).
  • ruff and mypy clean on changed files.

Session-settled decisions carried from planning: the combined Accept header value (user-approved); no Compound Engineering branding on this PR (user-directed).


Note

Low Risk
Narrow HTTP client header change with existing content-type validation; residual risk of strict servers preferring JSON is documented separately (#847).

Overview
Fixes 406 rejections from gateways that require Accept to include application/json (e.g. Composio MCP, #671) by changing connect_sse and aconnect_sse to send Accept: application/json, text/event-stream instead of only text/event-stream.

src/elevenlabs/core/http_sse/ is added to .fernignore so this hand-edited module is not overwritten on Fern regen. tests/test_http_sse.py adds six regression tests (sync/async Accept value, custom header preservation, and SSEError when the response is not text/event-stream).

Reviewed by Cursor Bugbot for commit ab802db. Bugbot is set up for automated code reviews on this repo. Configure here.

connect_sse and aconnect_sse hardcoded Accept: text/event-stream,
which 406s servers that require application/json in the Accept
header (e.g. Composio MCP, issue elevenlabs#671). Send both media types,
retaining text/event-stream for strict SSE servers.
Mirror the sync coverage for aconnect_sse: SSEError on non-SSE
content-type and preservation of caller-supplied headers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP Client Sends Incomplete Accept Header for SSE Connections

1 participant