From a76bae3a11c008d59488083185d05a74b86f429c Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Wed, 27 Aug 2025 12:00:37 -0700 Subject: [PATCH] address review comments Signed-off-by: Takeshi Yoneda --- mcp/streamable.go | 2 +- mcp/streamable_test.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mcp/streamable.go b/mcp/streamable.go index a92ab49..7d9faf0 100644 --- a/mcp/streamable.go +++ b/mcp/streamable.go @@ -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) && req.Method != http.MethodDelete { + } else if (!jsonOK || !streamOK) && req.Method != http.MethodDelete { // TODO: consolidate with handling of http method below. http.Error(w, "Accept must contain both 'application/json' and 'text/event-stream'", http.StatusBadRequest) return } diff --git a/mcp/streamable_test.go b/mcp/streamable_test.go index d08a0c7..c99ca78 100644 --- a/mcp/streamable_test.go +++ b/mcp/streamable_test.go @@ -690,6 +690,9 @@ func TestStreamableServerTransport(t *testing.T) { { method: "DELETE", wantStatusCode: http.StatusNoContent, + // Delete request expects 204 No Content with empty body. So override + // the default "accept: application/json, text/event-stream" header. + headers: map[string][]string{"Accept": nil}, }, }, }, @@ -949,9 +952,7 @@ func (s streamableRequest) do(ctx context.Context, serverURL, sessionID string, req.Header.Set("Mcp-Session-Id", sessionID) } req.Header.Set("Content-Type", "application/json") - if s.method != http.MethodDelete { // DELETE expects "No Content" response. - req.Header.Set("Accept", "application/json, text/event-stream") - } + req.Header.Set("Accept", "application/json, text/event-stream") maps.Copy(req.Header, s.headers) resp, err := http.DefaultClient.Do(req)