Initial Checks
Description
Streamable HTTP currently ignores q=0 values in the Accept header, so requests that explicitly mark a media type as unacceptable can still be accepted. This violates RFC 7231 semantics for content negotiation and can cause clients and servers to disagree about which response format is actually allowed.
Example Code
from starlette.requests import Request
def check_accept_headers(request: Request) -> tuple[bool, bool]:
accept_header = request.headers.get("accept", "")
accept_types = [media_type.strip().split(";")[0].strip().lower() for media_type in accept_header.split(",")]
has_wildcard = "*/*" in accept_types
has_json = has_wildcard or any(t in ("application/json", "application/*") for t in accept_types)
has_sse = has_wildcard or any(t in ("text/event-stream", "text/*") for t in accept_types)
return has_json, has_sse
# Example: client explicitly rejects JSON
request = Request({"type": "http", "method": "GET", "headers": [(b"accept", b"application/json;q=0, text/event-stream;q=1.0")]})
print(check_accept_headers(request))
# -> (True, True)
Python & MCP Python SDK
Python 3.12.10
MCP Python SDK: 1.28.1
Initial Checks
Description
Streamable HTTP currently ignores
q=0values in theAcceptheader, so requests that explicitly mark a media type as unacceptable can still be accepted. This violates RFC 7231 semantics for content negotiation and can cause clients and servers to disagree about which response format is actually allowed.Example Code
Python & MCP Python SDK