mcp: accept parameterized Content-Type types (#890)

Use a shared helper for Content-Type parsing in streamable transport
request validation and client response handling.

Follow up to https://github.com/modelcontextprotocol/go-sdk/pull/853,
where we did this for `Accept` headers.

This allows the streamable mcp server to validate the following header
`Content-Type: application/json;charset=utf-8`

Co-authored-by: Maciej Kisiel <mkisiel@google.com>
This commit is contained in:
Kalvin C 2026-04-23 05:51:47 -07:00 • committed by GitHub
commit 35f1b07e48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -264,6 +264,7 @@ func TestStreamableClientGETHandling(t *testing.T) {
contentType string
}{
{http.StatusOK, "", "text/event-stream"},
{http.StatusOK, "", "text/event-stream; charset=utf-8"},
{http.StatusMethodNotAllowed, "", "text/event-stream"},
//// The client error status code is not treated as an error in non-strict
//// mode.
@ -274,7 +275,7 @@ func TestStreamableClientGETHandling(t *testing.T) {
}
for _, test := range tests {
t.Run(fmt.Sprintf("status=%d", test.status), func(t *testing.T) {
t.Run(fmt.Sprintf("status=%d content_type=%q", test.status, test.contentType), func(t *testing.T) {
fake := &fakeStreamableServer{
t: t,
responses: fakeResponses{