From e2057d141124bd2e3c5f89b158c75152b95d8b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BB=BA=E5=B9=B3?= Date: Sun, 11 May 2025 11:36:55 +0800 Subject: [PATCH] Add wildcard '*' to the Accept header in response to API requests. --- src/mcp/server/streamable_http.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mcp/server/streamable_http.py b/src/mcp/server/streamable_http.py index ace74b33b..3f3cf4cba 100644 --- a/src/mcp/server/streamable_http.py +++ b/src/mcp/server/streamable_http.py @@ -51,6 +51,7 @@ # Content types CONTENT_TYPE_JSON = "application/json" CONTENT_TYPE_SSE = "text/event-stream" +CONTENT_TYPE_ALL = "*/*" # Special key for the standalone GET stream GET_STREAM_KEY = "_GET_stream" @@ -282,6 +283,9 @@ async def handle_request(self, scope: Scope, receive: Receive, send: Send) -> No def _check_accept_headers(self, request: Request) -> tuple[bool, bool]: """Check if the request accepts the required media types.""" accept_header = request.headers.get("accept", "") + if accept_header == CONTENT_TYPE_ALL: + return True, True + accept_types = [media_type.strip() for media_type in accept_header.split(",")] has_json = any(