Skip to content

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

@lucianolixin

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions