Skip to content

Commit a76bae3

Browse files
mathetakefindleyr
authored andcommitted
address review comments
Signed-off-by: Takeshi Yoneda <[email protected]>
1 parent c24d985 commit a76bae3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

mcp/streamable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (h *StreamableHTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque
133133
http.Error(w, "Accept must contain 'text/event-stream' for GET requests", http.StatusBadRequest)
134134
return
135135
}
136-
} else if (!jsonOK || !streamOK) && req.Method != http.MethodDelete {
136+
} else if (!jsonOK || !streamOK) && req.Method != http.MethodDelete { // TODO: consolidate with handling of http method below.
137137
http.Error(w, "Accept must contain both 'application/json' and 'text/event-stream'", http.StatusBadRequest)
138138
return
139139
}

mcp/streamable_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,9 @@ func TestStreamableServerTransport(t *testing.T) {
690690
{
691691
method: "DELETE",
692692
wantStatusCode: http.StatusNoContent,
693+
// Delete request expects 204 No Content with empty body. So override
694+
// the default "accept: application/json, text/event-stream" header.
695+
headers: map[string][]string{"Accept": nil},
693696
},
694697
},
695698
},
@@ -949,9 +952,7 @@ func (s streamableRequest) do(ctx context.Context, serverURL, sessionID string,
949952
req.Header.Set("Mcp-Session-Id", sessionID)
950953
}
951954
req.Header.Set("Content-Type", "application/json")
952-
if s.method != http.MethodDelete { // DELETE expects "No Content" response.
953-
req.Header.Set("Accept", "application/json, text/event-stream")
954-
}
955+
req.Header.Set("Accept", "application/json, text/event-stream")
955956
maps.Copy(req.Header, s.headers)
956957

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

0 commit comments

Comments
 (0)