App Finishers

Fix guide · updated 2026-11-19

MCP 406 Not Acceptable: "Client must accept both application/json and text/event-stream"

{"jsonrpc":"2.0","error":{"code":-32000,"message":"Not Acceptable: Client must accept both application/json and text/event-stream"},"id":null}

You call an MCP server directly, from curl, Postman, a script or an automation tool, and it answers HTTP 406 with Not Acceptable: Client must accept both application/json and text/event-stream. The server is fine: your request is missing one header. We tested it against the official TypeScript SDK (1.29) and read the code of the current SDKs (TypeScript 1.32.2, Python 1.30.0 and 2.3.0, November 2026). Here's the header to send, and how to read the reply you get once it works.

Why the server says no

The MCP spec says a client must send an Accept header that lists both application/json and text/event-stream. The server is allowed to answer with a plain JSON body or with an event stream, its choice, so the client has to promise it can read both. The SDKs enforce that rule.

Most HTTP tools send Accept: */* unless you change it: curl, Postman, JavaScript's fetch, Python's requests. Whether a server takes */* depends on what it's built with:

In our test (TypeScript SDK 1.29, a server built like the SDK's stateless example), the same initialize request got a 406 with no Accept header, with */*, with application/json, with text/event-stream, and with HTTPie's default application/json, */*;q=0.5. Only application/json, text/event-stream got a 200.

Two variants of the same error. A GET opens the server's event stream, so it only needs one type, and the message is Not Acceptable: Client must accept text/event-stream. A Python server with JSON replies turned on (json_response=True) only asks for application/json, and says Not Acceptable: Client must accept application/json. The TypeScript SDK asks for both types even with JSON replies on.

The fix: send both types

With curl:

curl https://your-server.example.com/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"my-script","version":"1"}}}'

In Postman or Insomnia, add a header named Accept with the value application/json, text/event-stream; your header replaces the default */*. In an automation tool (n8n's HTTP Request node, Make, a webhook step), add the same header in the request's header settings. Keep Content-Type: application/json too: without it the server answers 415.

If you're writing more than a quick test, use an MCP client library instead. The official SDKs' clients send both types and read both kinds of reply.

Then: the reply is an event stream, not JSON

Once the header is right, many servers answer like this:

event: message
data: {"result":{"protocolVersion":"2025-11-25", … },"jsonrpc":"2.0","id":1}

A JSON parser chokes on it. In JavaScript you get SyntaxError: Unexpected token 'e', "event: mes"... is not valid JSON, in Python requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0). Read the JSON from the line that starts with data: instead, and fall back to plain JSON when the server sends that. In JavaScript:

const res = await fetch('https://your-server.example.com/mcp', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', 'Accept': 'application/json, text/event-stream' },
  body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'initialize',
    params: { protocolVersion: '2025-11-25', capabilities: {}, clientInfo: { name: 'my-script', version: '1' } } }),
});
const text = await res.text();
const data = res.headers.get('content-type')?.startsWith('text/event-stream')
  ? JSON.parse(text.split('\n').find(line => line.startsWith('data: ')).slice(6))
  : JSON.parse(text);

In Python, with requests:

import json, requests
r = requests.post("https://your-server.example.com/mcp",
    headers={"Content-Type": "application/json", "Accept": "application/json, text/event-stream"},
    json={"jsonrpc": "2.0", "id": 1, "method": "initialize",
          "params": {"protocolVersion": "2025-11-25", "capabilities": {}, "clientInfo": {"name": "my-script", "version": "1"}}})
if r.headers.get("Content-Type", "").startswith("text/event-stream"):
    data = json.loads(next(l for l in r.text.splitlines() if l.startswith("data: "))[6:])
else:
    data = r.json()

We ran both against our test server: each printed the server's name. If the initialize reply has an Mcp-Session-Id header, send it back on every later request; the check script in our "Session not found" guide shows the whole sequence.

Give your AI tool this prompt:

My code calls an MCP server over HTTP and gets 406 "Not Acceptable: Client must accept both application/json and text/event-stream". Add the header Accept: application/json, text/event-stream (and Content-Type: application/json) to every request it sends to the MCP endpoint. Then handle both reply formats: if the response's Content-Type is text/event-stream, parse the JSON from the line that starts with "data: "; otherwise parse the body as JSON. If the initialize response has an Mcp-Session-Id header, send it back on every later request. Don't change anything else.

If it's your server

A tool that can't set headers won't get past a server built on the TypeScript SDK or the Python SDK 1.x: neither has a setting to accept */*. The Python SDK 2.x accepts it. Uptime monitors hit the same wall, because most of them send a plain GET: give them a separate health route instead of the MCP address.

Not quite your error?

Still stuck?

Run your curl with -v. The lines that start with > are what you actually send: check the > Accept: line. If it's right and you still get a 406, something between you and the server is replacing the header, often a proxy or an API gateway. Call the server's own address to compare.