Skip to content

MCP Server won't work with wildcard in "Accept" header and therefore is non‑compliant with HTTP spec #1641

@rh-fr

Description

@rh-fr

Question

Use Case

My client sends a request to MCP Server with Accept header */* (Same for application/*, text/event-stream). Server rejects this request because it expected strictly application/json or application/json and text/event-stream if json_response=False.

Expected

According to the HTTP/1.1 spec (RFC 7231, section 5.3.2), the Accept header allows wildcard so values */* and application/* should be valid, therefore server should accept them

from mcp.server.fastmcp import FastMCP
from starlette.applications import Starlette

...

mcp_server: FastMCP = FastMCP(streamable_http_path="/", stateless_http=True, json_response=True)

...

app: Starlette = mcp_server.streamable_http_app()

Start server: uvicorn mcp-server:app --host 127.0.0.1 --port 8000 --log-level trace

Example of Call

### Request
POST / HTTP/1.1.
Host: localhost:8000.
Accept-Encoding: gzip, deflate, br, zstd.
Connection: keep-alive.
User-Agent: python-httpx/0.28.1.
Content-Type: application/json.
Accept: */*.
Content-Length: 159.
.

{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"mcp-client","version":"1.0.0"}}}


### Response
HTTP/1.1 406 Not Acceptable.
date: Tue, 18 Nov 2025 16:16:17 GMT.
server: uvicorn.
content-type: application/json.
content-length: 125.
.

T 127.0.0.1:8000 -> 127.0.0.1:61346 [AP] #107
{"jsonrpc":"2.0","id":"server-error","error":{"code":-32600,"message":"Not Acceptable: Client must accept application/json"}}

Additional Context

  • mcp 1.18.0
  • Python 3.11.13
  • uvicorn 0.38.0
  • starlette 0.49.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions