Skip to content

Add wildcard '*' to the Accept header in response to API requests. #683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/mcp/server/streamable_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(
Expand Down
Loading