[BUG]
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Bug Report
Environment
@anthropic-ai/claude-agent-sdk: 0.2.52 (latest)@modelcontextprotocol/sdk: 1.27.1 (latest)- Node: 22+, Bun 1.3+
- OS: macOS
Description
When using the Claude Agent SDK with MCP servers configured as type: "http" (Streamable HTTP transport), all MCP server connections
fail with HTTP 406 Not Acceptable. The servers respond:
{
"jsonrpc": "2.0",
"error": {
"code": -32000,
"message": "Not Acceptable: Client must accept both application/json and text/event-stream"
}
}
This indicates the SDK's HTTP MCP client is not sending the required Accept: application/json, text/event-stream header
when connecting to Streamable HTTP MCP servers, as mandated by the MCP Streamable HTTP transport spec
↳ https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#sending-messages-to-the-server.
Reproduction
MCP server config passed to the SDK:
{
"mcpServers": {
"my-server": {
"type": "http",
"url": "https://example.com/mcp",
"headers": {
"Authorization": "Bearer <token>"
}
}
}
}
SDK usage
import { query, type Options } from '@anthropic-ai/claude-agent-sdk';
const options: Options = {
mcpServers: config.mcpServers,
strictMcpConfig: true,
// ...
};
const result = query({ prompt, options });
Result: All HTTP MCP servers fail to connect. No tools are registered.
Verification
Manually curling the same endpoint without the Accept header reproduces the 406:
curl -s -X POST "https://example.com/mcp" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d
'{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version
":"1.0.0"}},"id":1}'
→ HTTP 406: "Client must accept both application/json and text/event-stream"
Adding the Accept header fixes it immediately:
curl -s -X POST "https://example.com/mcp" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Authorization: Bearer $TOKEN" \
-d
'{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version
":"1.0.0"}},"id":1}'
→ HTTP 200: {"result":{"protocolVersion":"2024-11-05","capabilities":{...}}}
Impact
- All type: "http" MCP servers fail on the latest SDK
- Tested with 4 independent MCP servers — all return 406
- These same servers work correctly on older SDK versions
strictMcpConfig: trueandfalseboth exhibit the issue (the connection itself fails before config validation matters)
Workaround
None currently — the HTTP transport is handled inside the SDK's CLI subprocess and the Accept header cannot be overridden via headers config.
What Should Happen?
Expected Behavior
The SDK's HTTP MCP client should send Accept: application/json, text/event-stream on all requests to Streamable HTTP MCP servers, per the MCP specification.
Error Messages/Logs
{
"jsonrpc": "2.0",
"error": {
"code": -32000,
"message": "Not Acceptable: Client must accept both application/json and text/event-stream"
}
}
Steps to Reproduce
Steps to Reproduce
- Install the latest Claude Agent SDK and MCP SDK:
npm install @anthropic-ai/claude-agent-sdk@0.2.52 @modelcontextprotocol/sdk@1.27.1
- Configure an HTTP MCP server:
{
"mcpServers": {
"my-server": {
"type": "http",
"url": "https://my-streamable-http-mcp-server.com/mcp",
"headers": {
"Authorization": "Bearer <token>"
}
}
}
}
- Pass the config to the SDK:
import { query, type Options } from '@anthropic-ai/claude-agent-sdk';
const options: Options = {
mcpServers: config.mcpServers,
strictMcpConfig: true,
// ...
};
const result = query({ prompt, options });
- Result: MCP server fails to connect. No tools are registered.
- Verify the server is healthy by curling it manually — without the Accept header it returns 406:
curl -s -X POST "https://my-streamable-http-mcp-server.com/mcp" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d
'{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version
":"1.0.0"}},"id":1}'
→ HTTP 406: "Client must accept both application/json and text/event-stream"
- Adding the Accept header fixes it:
curl -s -X POST "https://my-streamable-http-mcp-server.com/mcp" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Authorization: Bearer $TOKEN" \
-d
'{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version
":"1.0.0"}},"id":1}'
→ HTTP 200: {"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{"listChanged":true}},...}}
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
0.2.7
Claude Code Version
2.1.31
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗