mcp: allow correct 'Accept' header values

Allow other header values for the 'Accept' header that imply
application/json and text/event-stream for requests to the Streamable
HTTP Transport.

Fixes #290

Unit tests here seemed like unnecessary complexity and wouldn't fit
cleanly with the style of the `streamable_test.go` tests. Happy to add
those if desired though.
This commit is contained in:
Riley Norton 2025-08-13 14:12:13 -07:00 • committed by GitHub
commit a834f3cf9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -98,9 +98,12 @@ func (h *StreamableHTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque
var jsonOK, streamOK bool
for _, c := range accept {
switch strings.TrimSpace(c) {
case "application/json":
case "application/json", "application/*":
jsonOK = true
case "text/event-stream", "text/*":
streamOK = true
case "*/*":
jsonOK = true
case "text/event-stream":
streamOK = true
}
}