Skip to content

MCP remote type: Accept header missing for Streamable HTTP servers (HTTP 400) #25650

Closed

Description

@lucianolixin

Bug Description

When connecting to remote MCP servers that implement the Streamable HTTP transport (e.g., Zhipu/BigModel MCP servers at open.bigmodel.cn), OpenCode fails to connect. The server returns HTTP 400 with the error:

"Accept header must include both application/json and text/event-stream"

Steps to Reproduce

  1. Configure a remote MCP server that uses Streamable HTTP transport in opencode.json:
{
  "mcp": {
    "web-search-prime": {
      "type": "remote",
      "url": "https://open.bigmodel.cn/api/mcp/web_search_prime/mcp",
      "headers": {
        "Authorization": "Bearer <api_key>"
      }
    }
  }
}
  1. Start OpenCode
  2. The MCP server fails to connect — no tools from this server are available in the session

Expected Behavior

OpenCode's MCP client should send requests with the Accept header including both application/json and text/event-stream:

Accept: application/json, text/event-stream

This is required by the MCP Streamable HTTP transport spec for servers that support both response modes.

Actual Behavior

OpenCode sends requests without the required Accept header values, causing the server to reject the connection with HTTP 400.

Verification

Manual curl test confirms the issue:

# Without Accept header → 400
curl -s -o /dev/null -w "%{http_code}" -X POST \
  "https://open.bigmodel.cn/api/mcp/web_search_prime/mcp" \
  -H "Authorization: Bearer <key>" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0.0"}}}'
# → HTTP 400: "Accept header must include both application/json and text/event-stream"

# With correct Accept header → 200
curl -s -o /dev/null -w "%{http_code}" -X POST \
  "https://open.bigmodel.cn/api/mcp/web_search_prime/mcp" \
  -H "Authorization: Bearer <key>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0.0"}}}'
# → HTTP 200 (success)

Environment

  • OpenCode version: latest
  • OS: macOS (darwin)
  • MCP server: Zhipu BigModel web-search-prime / web-reader / zread (all three fail with same error)
  • Config type: "type": "remote"

Affected MCP Servers

Any MCP server using the Spring Boot MCP starter with ZWebFluxStreamableHttpServerTransportProvider enforces this Accept header requirement. This includes all Zhipu/BigModel MCP servers documented at https://docs.bigmodel.cn/cn/coding-plan/mcp/search-mcp-server

Workaround

None currently — the issue is in OpenCode's MCP HTTP client implementation.

Activity

  1. github-actions commented on May 3, 2026

    @github-actions
    Contributor

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

    Please review those issues to see if they cover your case, and consider adding a +1 or additional context there if so.

  2. kagura-chen commented on May 4, 2026

    @kagura-chen
    Contributor

    I'd like to work on this. The root cause is that the MCP SDK's initial GET request for SSE only sets Accept: text/event-stream, but some servers validate that all requests include both application/json and text/event-stream. The fix is to pass a custom fetch to StreamableHTTPClientTransport that ensures both values are always present in the Accept header.

  3. rekram1-node commented on Jun 22, 2026

    @rekram1-node
    Collaborator

    no it definitely sends them just tested w/ http proxy

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions