MCP client doesn't send Accept header required by Context7 (causes 406 Not Acceptable error) #4248

Open
opened 2026-02-16 17:43:09 -05:00 by yindo · 4 comments
Owner

Originally created by @kamusis on GitHub (Jan 5, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

The OpenCode MCP client fails to connect to Context7's MCP server because it doesn't send the required Accept: application/json, text/event-stream HTTP header. Context7 requires both content types to be accepted, and returns HTTP 406 "Not Acceptable" when this header is missing or incorrect.

Plugins

oh-my-opencode

OpenCode version

v1.1.2

Steps to reproduce

  1. Configure Context7 MCP server in ~/.config/opencode/opencode.json:
    {
    mcp: {
    context7: {
    type: remote,
    url: https://mcp.context7.com/mcp,
    headers: {
    CONTEXT7_API_KEY: your-api-key
    },
    enabled: true
    }
    }
    }
  2. Start OpenCode
  3. Observe error: "context7 Failed to get tools"

Screenshot and/or share link

Root Cause Investigation:
I tested the Context7 endpoint manually using curl:

Without Accept header (fails with 406)

curl -X POST https://mcp.context7.com/mcp
-H "Content-Type: application/json"
--data '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

Result: HTTP/1.1 406 Not Acceptable

With correct Accept header (works)

curl -X POST https://mcp.context7.com/mcp
-H "Content-Type: application/json"
-H "Accept: application/json, text/event-stream"
--data '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

Result: Returns tools successfully (resolve-library-id, query-docs)

Context7 returns: {"jsonrpc":"2.0","error":{"code":-32000,"message":"Not Acceptable: Client must accept both application/json and text/event-stream"},"id":null}
The server also sends these CORS headers indicating acceptable headers:
Access-Control-Allow-Headers: Content-Type, MCP-Session-Id, MCP-Protocol-Version, X-Context7-API-Key, Context7-API-Key, X-API-Key, Authorization
Environment:

  • OpenCode version: v1.1.2 (released Jan 5, 2026)
  • Operating System: Windows
  • MCP Server: Context7 (https://mcp.context7.com/mcp)
    Suggested Fix:
    Update the OpenCode MCP client to send Accept: application/json, text/event-stream header when making requests to remote MCP servers, or at minimum, allow configuring custom Accept headers in the MCP server configuration.

Operating System

Windows 11

Terminal

Windows Terminal

Originally created by @kamusis on GitHub (Jan 5, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description The OpenCode MCP client fails to connect to Context7's MCP server because it doesn't send the required Accept: application/json, text/event-stream HTTP header. Context7 requires both content types to be accepted, and returns HTTP 406 "Not Acceptable" when this header is missing or incorrect. ### Plugins oh-my-opencode ### OpenCode version v1.1.2 ### Steps to reproduce 1. Configure Context7 MCP server in ~/.config/opencode/opencode.json: { mcp: { context7: { type: remote, url: https://mcp.context7.com/mcp, headers: { CONTEXT7_API_KEY: your-api-key }, enabled: true } } } 2. Start OpenCode 3. Observe error: "context7 Failed to get tools" ### Screenshot and/or share link Root Cause Investigation: I tested the Context7 endpoint manually using curl: # Without Accept header (fails with 406) curl -X POST https://mcp.context7.com/mcp \ -H "Content-Type: application/json" \ --data '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' # Result: HTTP/1.1 406 Not Acceptable # With correct Accept header (works) curl -X POST https://mcp.context7.com/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ --data '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' # Result: Returns tools successfully (resolve-library-id, query-docs) Context7 returns: {"jsonrpc":"2.0","error":{"code":-32000,"message":"Not Acceptable: Client must accept both application/json and text/event-stream"},"id":null} The server also sends these CORS headers indicating acceptable headers: Access-Control-Allow-Headers: Content-Type, MCP-Session-Id, MCP-Protocol-Version, X-Context7-API-Key, Context7-API-Key, X-API-Key, Authorization Environment: - OpenCode version: v1.1.2 (released Jan 5, 2026) - Operating System: Windows - MCP Server: Context7 (https://mcp.context7.com/mcp) Suggested Fix: Update the OpenCode MCP client to send Accept: application/json, text/event-stream header when making requests to remote MCP servers, or at minimum, allow configuring custom Accept headers in the MCP server configuration. ### Operating System Windows 11 ### Terminal Windows Terminal
yindo added the windowsbug labels 2026-02-16 17:43:09 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 5, 2026):

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

  • #834: Remote MCP servers using Server-Sent Events (SSE) fail to start with 'UnknownError Server error' - This is the same root cause: missing Accept: application/json, text/event-stream headers

You may also want to review:

  • #5371: [FEATURE]: Support MCP servers that require POST-based or non-standard SSE handshake - Related to MCP transport improvements

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 5, 2026): This issue might be a duplicate of existing issues. Please check: - #834: Remote MCP servers using Server-Sent Events (SSE) fail to start with 'UnknownError Server error' - This is the same root cause: missing Accept: application/json, text/event-stream headers You may also want to review: - #5371: [FEATURE]: Support MCP servers that require POST-based or non-standard SSE handshake - Related to MCP transport improvements Feel free to ignore if none of these address your specific case.
Author
Owner

@Shivansh-Khunger commented on GitHub (Jan 8, 2026):

@kamusis are you still encountering this bug in the latest version ?

@Shivansh-Khunger commented on GitHub (Jan 8, 2026): @kamusis are you still encountering this bug in the latest version ?
Author
Owner

@kamusis commented on GitHub (Jan 9, 2026):

@kamusis are you still encountering this bug in the latest version ?

Just wanted to update this - that issue isn't happening anymore. Context7 is working smoothly now, no problems at all! 🎉"

@kamusis commented on GitHub (Jan 9, 2026): > [@kamusis](https://github.com/kamusis) are you still encountering this bug in the latest version ? Just wanted to update this - that issue isn't happening anymore. Context7 is working smoothly now, no problems at all! 🎉"
Author
Owner

@Shivansh-Khunger commented on GitHub (Jan 9, 2026):

@kamusis are you still encountering this bug in the latest version ?

Just wanted to update this - that issue isn't happening anymore. Context7 is working smoothly now, no problems at all! 🎉"

actually was gonna work on this issue, but saw context7 connected by default in dev mode 😅

@Shivansh-Khunger commented on GitHub (Jan 9, 2026): > > [@kamusis](https://github.com/kamusis) are you still encountering this bug in the latest version ? > > Just wanted to update this - that issue isn't happening anymore. Context7 is working smoothly now, no problems at all! 🎉" actually was gonna work on this issue, but saw context7 connected by default in dev mode 😅
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4248