Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion mcp/streamable.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (h *StreamableHTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque
http.Error(w, "Accept must contain 'text/event-stream' for GET requests", http.StatusBadRequest)
return
}
} else if !jsonOK || !streamOK {
} else if (!jsonOK || !streamOK) && req.Method != http.MethodDelete {
http.Error(w, "Accept must contain both 'application/json' and 'text/event-stream'", http.StatusBadRequest)
return
}
Expand Down
8 changes: 7 additions & 1 deletion mcp/streamable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,10 @@ func TestStreamableServerTransport(t *testing.T) {
},
wantSessionID: true,
},
{
method: "DELETE",
wantStatusCode: http.StatusNoContent,
},
},
},
{
Expand Down Expand Up @@ -945,7 +949,9 @@ func (s streamableRequest) do(ctx context.Context, serverURL, sessionID string,
req.Header.Set("Mcp-Session-Id", sessionID)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json, text/event-stream")
if s.method != http.MethodDelete { // DELETE expects "No Content" response.
req.Header.Set("Accept", "application/json, text/event-stream")
}
maps.Copy(req.Header, s.headers)

resp, err := http.DefaultClient.Do(req)
Expand Down