Skip to content

docs: fix the streamable client snippet to use (*Client).Connect - #1142

Merged
guglielmo-san merged 1 commit into
modelcontextprotocol:mainfrom
tonydzi:docs-streamable-client-connect
Aug 4, 2026
Merged

docs: fix the streamable client snippet to use (*Client).Connect#1142
guglielmo-san merged 1 commit into
modelcontextprotocol:mainfrom
tonydzi:docs-streamable-client-connect

Conversation

@tonydzi

@tonydzi tonydzi commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

What was broken

docs/protocol.mdStreamable Transport → client side shows:

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

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.

The client-side snippet in the "Streamable Transport" section calls
mcp.Connect, which does not exist: the package has no top-level Connect
function, only (*Client).Connect. Copying the snippet fails to build with
"undefined: mcp.Connect" (checked against v1.7.0), and the third argument
was *ClientOptions where Connect takes *ClientSessionOptions.

Use the same shape as every other client snippet in the docs: construct
the client with NewClient, then call client.Connect and keep the returned
session.

Edited internal/docs/protocol.src.md and regenerated docs/protocol.md with
go generate ./internal/docs.

Assisted-by: Claude Opus 5 (Anthropic)
@guglielmo-san
guglielmo-san merged commit 7256941 into modelcontextprotocol:main Aug 4, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants