From 431e1810d7c9445dc0ba9f982feff87f4771231e Mon Sep 17 00:00:00 2001 From: "lorenzo.neumann" <36760115+ln-12@users.noreply.github.com> Date: Mon, 1 Sep 2025 12:58:46 +0200 Subject: [PATCH] mcp/streamable: reuse transport if sessionID is given in stateless mode This change fixes logging not working in stateless mode as the transport (and therefore the configured log level) is not used across requests. Fixes #387 --- mcp/streamable.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcp/streamable.go b/mcp/streamable.go index f56eabd9..0f608fa5 100644 --- a/mcp/streamable.go +++ b/mcp/streamable.go @@ -308,7 +308,7 @@ func (h *StreamableHTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque http.Error(w, "failed connection", http.StatusInternalServerError) return } - if h.opts.Stateless { + if sessionID == "" && h.opts.Stateless { // Stateless mode: close the session when the request exits. defer ss.Close() // close the fake session after handling the request } else {