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

mcp: Client.Connect never falls back to initialize when a stdio server ignores server/discover

Aperta
#1,332 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@crossxr ci sta già lavorando.

Dal 2/10/2026.

  • #1334 di @crossxr — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go
Ambito
api

Direzione di ricerca

Start at Client.Connect and the ClientSessionOptions handling for the server/discover probe, then reproduce the timeout with the silent Python stdio server described in the issue. Review the API decision around DiscoverTimeout or a transport-specific default; done means a silent handshake-era server reaches initialize instead of waiting for the caller context to expire.

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

Descrizione

Describe the bug

For protocol ≥ 2026-07-28, Client.Connect sends server/discover first and falls back to initialize on an error, or on a non-modern error from the server. Some handshake-era stdio servers silently ignore requests they don't recognize before initialize, and the stdio transport spec permits that. With such a server, server/discover never gets a reply, so Connect blocks until the caller's context ends and then fails. It never reaches the initialize fallback.

Setting ClientSessionOptions{ProtocolVersion: "2025-11-25"} connects immediately, but then the client can't use 2026-07-28 with any server.

To Reproduce

A stdio server that only answers initialize and tools/list and drops everything else:

import sys, json
for line in sys.stdin:
    m = json.loads(line)
    if m.get("method") == "initialize":
        r = {"protocolVersion": "2025-11-25", "capabilities": {"tools": {}}, "serverInfo": {"name": "silent", "version": "1"}}
    elif m.get("method") == "tools/list":
        r = {"tools": []}
    else:
        continue
    print(json.dumps({"jsonrpc": "2.0", "id": m["id"], "result": r}), flush=True)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_, err := client.Connect(ctx, &mcp.CommandTransport{Command: exec.Command("python3", "silent.py")}, nil)
// v1.8.0 and main at 53effc0: returns after 5s with context deadline exceeded

Expected behavior

This needs an API decision, so raising it before any PR. One option: bound the discover probe and treat "no reply in time" as a handshake-era server on transports where silence is possible, e.g. ClientSessionOptions.DiscoverTimeout, or a short default for CommandTransport.

Additional context

Found while moving PromptKit's MCP client onto go-sdk v1.8.0 (AltairaLabs/PromptKit#2141). We work around it by restarting the stdio server and connecting with the handshake-era protocol version when discover times out: client.go. Our interop matrix runs the silent server above as a fixture: silent_stdio.py.

Lingua principale
Go
Stelle
5.2k
Fork
583
Merge medio
2g 1h
PR unite (30g)
55

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.