Skip to content

Remote MCP: StreamableHTTPClientTransport missing Accept: text/event-stream header (406 from SSE-over-POST servers) #15103

Closed

Description

@dmmulroy

Summary

Remote MCP servers that use SSE-over-POST (streamable HTTP with SSE response format) fail to connect because opencode's StreamableHTTPClientTransport doesn't send Accept: text/event-stream in the request headers.

Reproduction

  1. Configure a remote MCP server that requires Accept: application/json, text/event-stream:
{
  "mcp": {
    "braintrust": {
      "type": "remote",
      "url": "https://api.braintrust.dev/mcp",
      "headers": { "Authorization": "Bearer ..." }
    }
  }
}
  1. Restart opencode
  2. MCP shows as failed ... Loading

Root Cause

The server returns 406 Not Acceptable when StreamableHTTPClientTransport POSTs without Accept: text/event-stream. The fallback to SSEClientTransport also fails because the server returns 405 Method Not Allowed on GET (it doesn't support legacy EventSource SSE).

# StreamableHTTP (POST, Accept: application/json only) → 406
# Legacy SSE (GET, EventSource) → 405

The server works when both accept types are sent:

curl -X POST https://api.braintrust.dev/mcp \
  -H "Accept: application/json, text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"initialize",...}'
# → 200 OK, SSE response

Expected Behavior

StreamableHTTPClientTransport should include Accept: text/event-stream alongside application/json per the MCP spec, allowing SSE-over-POST servers to respond correctly.

Workaround

Use mcp-remote as a local proxy:

{
  "braintrust": {
    "type": "local",
    "command": ["npx", "-y", "mcp-remote", "https://api.braintrust.dev/mcp",
                "--header", "Authorization: Bearer ...", "--transport", "http-only"]
  }
}

Related Issues

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 25, 2026
  2. github-actions commented on Feb 25, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of an existing issue. Please check:

    It looks like you've already identified this connection in the "Related Issues" section. Consider adding your findings (the specific Braintrust reproduction case and the SSE-over-POST failure mode) as a comment on #6972 to consolidate the discussion there.

  3. dmmulroy commented on Feb 25, 2026

    @dmmulroy
    ContributorAuthor

    Closing — misdiagnosis. The MCP SDK (@modelcontextprotocol/sdk) correctly sets Accept: application/json, text/event-stream in StreamableHTTPClientTransport.send(). The header is set after merging requestInit.headers, so user-provided headers can't override it.

    The actual root cause was {env:BRAINTRUST_API_KEY} silently resolving to "" (env var not exported in shell), causing auth failures. Transport failures were logged at debug level only, making the real error invisible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions