@@ -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
0 commit comments