From 725694100ae134a9ff699d5467e6215c9ec3efa6 Mon Sep 17 00:00:00 2001 From: Anton Dziatkovskii Date: Tue, 4 Aug 2026 14:39:05 +0200 Subject: [PATCH] docs: fix the streamable client snippet to use (*Client).Connect (#1142) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What was broken `docs/protocol.md` → *Streamable Transport* → client side shows: ```go client, err := mcp.Connect(ctx, transport, &mcp.ClientOptions{...}) ``` There is no top-level `mcp.Connect`. The package has `(*Client).Connect`, whose third parameter is `*ClientSessionOptions`, not `*ClientOptions`. So the one snippet a reader reaches for when wiring up the client side of streamable HTTP does not build. It is also the only outlier in the docs: `quick_start.md`, `client.md`, `server.md`, `troubleshooting.md` and `protocol.md` itself (lines 470, 538) all already use `client.Connect(ctx, transport, nil)`. ### How I checked Pasted the snippet verbatim into a fresh module requiring the released SDK (`github.com/modelcontextprotocol/go-sdk v1.7.0`): ``` $ go build ./... ./broken.go:15:21: undefined: mcp.Connect ``` Then ran the proposed replacement end to end against a real streamable server (`mcp.NewStreamableHTTPHandler` behind `httptest.NewServer`), connecting and calling a tool over the session: ``` BUILD OK tool result: {"greeting":"Hi you"} ``` ### What it is now ```go transport := &mcp.StreamableClientTransport{ Endpoint: "http://localhost:8080/mcp", } client := mcp.NewClient(&mcp.Implementation{Name: "client", Version: "v1.0.0"}, nil) session, err := client.Connect(ctx, transport, nil) ``` Change is in `internal/docs/protocol.src.md`; `docs/protocol.md` regenerated with `go generate ./internal/docs`, both committed together. Docs-only, no code paths touched. --- Assisted-by: Claude Opus 5 — this PR was drafted and verified by Anton's AI cofounder running on his account; the commands and outputs above are from real runs, not reconstructions. Co-authored-by: Anton Dzyatkovsky --- docs/protocol.md | 3 ++- internal/docs/protocol.src.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/protocol.md b/docs/protocol.md index 35bf93b..edc1c11 100644 --- a/docs/protocol.md +++ b/docs/protocol.md @@ -256,7 +256,8 @@ connect to the server: transport := &mcp.StreamableClientTransport{ Endpoint: "http://localhost:8080/mcp", } -client, err := mcp.Connect(ctx, transport, &mcp.ClientOptions{...}) +client := mcp.NewClient(&mcp.Implementation{Name: "client", Version: "v1.0.0"}, nil) +session, err := client.Connect(ctx, transport, nil) ``` The `StreamableClientTransport` handles the HTTP requests and communicates with diff --git a/internal/docs/protocol.src.md b/internal/docs/protocol.src.md index dee819b..e26fcd7 100644 --- a/internal/docs/protocol.src.md +++ b/internal/docs/protocol.src.md @@ -181,7 +181,8 @@ connect to the server: transport := &mcp.StreamableClientTransport{ Endpoint: "http://localhost:8080/mcp", } -client, err := mcp.Connect(ctx, transport, &mcp.ClientOptions{...}) +client := mcp.NewClient(&mcp.Implementation{Name: "client", Version: "v1.0.0"}, nil) +session, err := client.Connect(ctx, transport, nil) ``` The `StreamableClientTransport` handles the HTTP requests and communicates with