Skip to content

Commit 1dd5e97

Browse files
committed
mcp/streamable: update bool name to persistent
1 parent 1dd9c32 commit 1dd5e97

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

mcp/streamable.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ func (t *StreamableClientTransport) Connect(ctx context.Context) (Connection, er
739739
// Section 2.2: The client MAY issue an HTTP GET to the MCP endpoint.
740740
// This can be used to open an SSE stream, allowing the server to
741741
// communicate to the client, without the client first sending data via HTTP POST.
742-
go conn.handleSSE(nil, false)
742+
go conn.handleSSE(nil, true)
743743

744744
return conn, nil
745745
}
@@ -865,7 +865,7 @@ func (s *streamableClientConn) postMessage(ctx context.Context, sessionID string
865865
switch ct := resp.Header.Get("Content-Type"); ct {
866866
case "text/event-stream":
867867
// Section 2.1: The SSE stream is initiated after a POST.
868-
go s.handleSSE(resp, true)
868+
go s.handleSSE(resp, false)
869869
case "application/json":
870870
body, err := io.ReadAll(resp.Body)
871871
resp.Body.Close()
@@ -886,8 +886,8 @@ func (s *streamableClientConn) postMessage(ctx context.Context, sessionID string
886886
}
887887

888888
// handleSSE manages the lifecycle of an SSE connection. It can be either
889-
// temporary (for a POST response) or persistent (for the main GET listener).
890-
func (s *streamableClientConn) handleSSE(initialResp *http.Response, temporary bool) {
889+
// persistent (for the main GET listener) or temporary (for a POST response).
890+
func (s *streamableClientConn) handleSSE(initialResp *http.Response, persistent bool) {
891891
resp := initialResp
892892
var lastEventID string
893893
for {
@@ -900,7 +900,7 @@ func (s *streamableClientConn) handleSSE(initialResp *http.Response, temporary b
900900
}
901901
// If the stream has ended, then do not reconnect if the stream is
902902
// temporary (POST initiated SSE).
903-
if lastEventID == "" && temporary {
903+
if lastEventID == "" && !persistent {
904904
return
905905
}
906906

mcp/streamable_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ func TestClientReplay(t *testing.T) {
212212
}
213213

214214
// TestServerInitiatedSSE verifies that the persistent SSE connection remains
215-
// open and can receive multiple, non-consecutive, server-initiated events.
215+
// open and can receive server-initiated events.
216216
func TestServerInitiatedSSE(t *testing.T) {
217217
notifications := make(chan string)
218-
server := NewServer(testImpl, &ServerOptions{})
218+
server := NewServer(testImpl, nil)
219219

220220
httpServer := httptest.NewServer(NewStreamableHTTPHandler(func(*http.Request) *Server { return server }, nil))
221221
defer httpServer.Close()

0 commit comments

Comments
 (0)