Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

mcp: SSEClientTransport ties the event stream to the context passed to Connect

Aperta
#1,331 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
api, networking

Direzione di ricerca

Start in mcp/sse.go at SSEClientTransport.Connect and inspect how the request uses the context passed to Client.Connect; compare this with StreamableClientTransport's connection lifetime. Reproduce the issue with a short-lived context, then verify that the SSE stream remains usable for session.ListTools until Close ends the connection.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

SSEClientTransport.Connect opens the long-lived event stream with http.NewRequestWithContext(ctx, "GET", c.Endpoint, nil), using the context given to Client.Connect (mcp/sse.go; present in v1.8.0 and on main at 53effc0). Callers usually bound the handshake with a timeout:

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
session, err := client.Connect(ctx, &mcp.SSEClientTransport{Endpoint: url}, nil)

The session works until cancel runs or the timeout fires. After that the stream is closed and every later call fails. StreamableClientTransport detaches its connection from the Connect context, so the same code works on one transport and silently breaks on the other.

To Reproduce

  1. Connect to an SSE server with a context that has a short timeout, as above.
  2. Let the timeout fire (or call cancel).
  3. Call session.ListTools: it fails because the event stream is gone.

Expected behavior

The stream's lifetime is tied to the connection, ended by Close, as with the streamable transport. If the current behavior is intended, document it on Client.Connect and SSEClientTransport. Happy to send a PR.

Additional context

Found while moving PromptKit's MCP client onto go-sdk v1.8.0 (AltairaLabs/PromptKit#2141). We work around it by passing Connect a context that outlives the handshake: dial.

Lingua principale
Go
Stelle
5.2k
Fork
568
Merge medio
1g 15h
PR unite (30g)
39

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modelcontextprotocol/go-sdk

Tutte le issue di modelcontextprotocol/go-sdk

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.