mcp: a wrapped stdio server connection never learns the negotiated protocol version
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
- #1556 di @tang-ontheway — chiusa senza merge
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- go
- Ambito
- backend-api-design
Direzione di ricerca
Read ServerSession.updateState and the unexported serverConnection interface, then compare how LoggingTransport forwards the negotiated protocol version with the client-side fix in #1107. Reproduce using the supplied IOTransport wrapper example and check the batch and cancelled-request cases described in the issue. Done when a wrapped stdio-style connection preserves the negotiated protocol behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Checklist
- I searched the existing issues, and this has not been reported before.
- This is a real problem that I ran into myself, using the latest release of the SDK.
- I ran into it in a production system, not in a toy example, a benchmark, or an automated or AI-driven scan of the code.
- I (a human) examined the relevant SDK code, and wrote or reviewed every line of this report. It is not unreviewed AI output.
- This report is brief and concise, and sticks to the facts needed to understand the problem.
What happened?
ServerSession.updateState hands the negotiated protocol version to the connection only through the unexported serverConnection interface. LoggingTransport forwards it (#1328), but a Connection wrapper outside the package cannot implement an unexported method. So a stdio-style server connection (StdioTransport, IOTransport, InMemoryTransport) wrapped by user code behaves as if no version had been negotiated:
- On v1.8.0 and main, it answers a JSON-RPC batch on a 2025-11-25 session. Without the wrapper, the server rejects the batch and closes the connection.
- On main, it answers a request the client cancelled on a 2026-07-28 session. Without the wrapper, the response is dropped (#1267).
Expected: wrapping a Connection to observe or decorate messages (metrics, tracing, auditing) does not change protocol behavior. #1109 had the same cause on the client side and was fixed by deriving the version from the outgoing message (#1107) instead of the hook. Something similar could work here, or the hook could be exported so that wrappers can forward it. I can send a fix once you choose a direction.
AI assistance: prepared with Claude; I reviewed it.
How to reproduce
package main
import (
"bufio"
"context"
"fmt"
"io"
"github.com/modelcontextprotocol/go-sdk/mcp"
)
// wrapped stands in for a user-defined Connection decorator (metrics,
// tracing, auditing) that forwards the Connection methods.
type wrapped struct{ mcp.Transport }
func (w wrapped) Connect(ctx context.Context) (mcp.Connection, error) {
c, err := w.Transport.Connect(ctx)
return struct{ mcp.Connection }{c}, err
}
func run(wrap bool) {
ctx := context.Background()
clientR, serverW := io.Pipe()
serverR, clientW := io.Pipe()
var t mcp.Transport = &mcp.IOTransport{Reader: serverR, Writer: serverW}
if wrap {
t = wrapped{t}
}
server := mcp.NewServer(&mcp.Implementation{Name: "s", Version: "v"}, nil)
ss, err := server.Connect(ctx, t, nil)
if err != nil {
panic(err)
}
defer ss.Close()
lines := bufio.NewScanner(clientR)
fmt.Fprintln(clientW, `{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"c","version":"v"}}}`)
lines.Scan()
fmt.Fprintln(clientW, `{"jsonrpc":"2.0","method":"notifications/initialized","params":{}}`)
fmt.Fprintln(clientW, `[{"jsonrpc":"2.0","id":2,"method":"ping"}]`)
if lines.Scan() {
fmt.Printf("wrapped=%v: %s\n", wrap, lines.Text())
} else {
fmt.Printf("wrapped=%v: connection closed\n", wrap)
}
}
func main() {
run(false)
run(true)
}
Output with v1.8.0 and with main at 0e849cb:
wrapped=false: connection closed
wrapped=true: [{"jsonrpc":"2.0","id":2,"result":{}}]
Where did you hit this?
Found while writing a Connection wrapper in Frame (the plugin framework under Flame), which wraps its stdio client connection to keep the original tools/call result JSON; that client-side wrapper is not affected today.
Go MCP SDK version
v1.8.0 (also main at 0e849cb)
Go version
go version go1.27.3 darwin/arm64
Logs
No response
- Lingua principale
- Go
- Stelle
- 5.4k
- Fork
- 623
- Merge medio
- 22h 10m
- PR unite (30g)
- 30
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelcontextprotocol/go-sdk
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
modelcontextprotocol/go-sdk#1557 ·
I maintainer di solito rispondono entro 1 giorno
-
Streamable HTTP (2026-07-28): tools/call with an out-of-range number in arguments fails because extractName decodes Arguments into anyForse di nuovo libera @beiryu l’ha presa 10 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
modelcontextprotocol/go-sdk#1534 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensionsForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaneeds investigation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
modelcontextprotocol/go-sdk#745 · 13 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 18/100
modelcontextprotocol/go-sdk#1555 ·
I maintainer di solito rispondono entro 1 giorno
-
mcp: 2026-07-28 client runs elicitation and sampling handlers for standalone server requestsForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
modelcontextprotocol/go-sdk#1552 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di modelcontextprotocol/go-sdk
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
apache/dubbo-admin#1659 ·
I maintainer di solito rispondono entro 8 giorni
-
taskmanager: a failed v1alpha1 backup leaves the partial backup behindForse già presa @arshil42 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100