Skip to content

Commit 80abbe6

Browse files
authored
docs: document support for resumability and redelivery (#606)
Add missing documentation on resumability and redelivery in the streamable transport. Indirectly, also update stale transcluded examples. Example changes weren't causing CI failure as we only trigger the docs check on changes to the raw docs.
1 parent 1a907bc commit 80abbe6

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

docs/client.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ func Example_roots() {
5353

5454
// Connect the server and client...
5555
t1, t2 := mcp.NewInMemoryTransports()
56-
if _, err := s.Connect(ctx, t1, nil); err != nil {
56+
serverSession, err := s.Connect(ctx, t1, nil)
57+
if err != nil {
5758
log.Fatal(err)
5859
}
60+
defer serverSession.Close()
5961

6062
clientSession, err := c.Connect(ctx, t2, nil)
6163
if err != nil {

docs/protocol.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ To create a streamable MCP server, you create a `StreamableHTTPHandler` and
148148
pass it an `mcp.Server`:
149149

150150
```go
151+
// TODO: Until we have a way to clean up abandoned sessions, this test will leak goroutines (see #499)
151152
func ExampleStreamableHTTPHandler() {
152153
// Create a new streamable handler, using the same MCP server for every request.
153154
//
@@ -185,6 +186,19 @@ client, err := mcp.Connect(ctx, transport, &mcp.ClientOptions{...})
185186
The `StreamableClientTransport` handles the HTTP requests and communicates with
186187
the server using the streamable transport protocol.
187188

189+
#### Resumability and Redelivery
190+
191+
By default, the streamable server does not support [resumability or
192+
redelivery](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#resumability-and-redelivery)
193+
of messages, because doing so requires either a persistent storage solution or
194+
unbounded memory usage (see also
195+
[#580](https://github.com/modelcontextprotocol/go-sdk/issues/580)).
196+
197+
To enable resumability, set `StreamableHTTPOptions.EventStore` to a non-nil
198+
value. The SDK provides a `MemoryEventStore` for testing or simple use cases;
199+
for production use it is generally advisable to use a more sophisticated
200+
implementation.
201+
188202
#### Stateless Mode
189203

190204
The streamable server supports a _stateless mode_ by setting

docs/troubleshooting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func ExampleLoggingTransport() {
3333
if err != nil {
3434
log.Fatal(err)
3535
}
36-
defer serverSession.Wait()
36+
defer serverSession.Close()
3737

3838
client := mcp.NewClient(&mcp.Implementation{Name: "client", Version: "v0.0.1"}, nil)
3939
var b bytes.Buffer
@@ -71,7 +71,7 @@ func ExampleStreamableHTTPHandler_middleware() {
7171
server := mcp.NewServer(&mcp.Implementation{Name: "server", Version: "v0.1.0"}, nil)
7272
handler := mcp.NewStreamableHTTPHandler(func(r *http.Request) *mcp.Server {
7373
return server
74-
}, nil)
74+
}, &mcp.StreamableHTTPOptions{Stateless: true})
7575
loggingHandler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
7676
// Example debugging; you could also capture the response.
7777
body, err := io.ReadAll(req.Body)

internal/docs/protocol.src.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,19 @@ client, err := mcp.Connect(ctx, transport, &mcp.ClientOptions{...})
112112
The `StreamableClientTransport` handles the HTTP requests and communicates with
113113
the server using the streamable transport protocol.
114114

115+
#### Resumability and Redelivery
116+
117+
By default, the streamable server does not support [resumability or
118+
redelivery](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#resumability-and-redelivery)
119+
of messages, because doing so requires either a persistent storage solution or
120+
unbounded memory usage (see also
121+
[#580](https://github.com/modelcontextprotocol/go-sdk/issues/580)).
122+
123+
To enable resumability, set `StreamableHTTPOptions.EventStore` to a non-nil
124+
value. The SDK provides a `MemoryEventStore` for testing or simple use cases;
125+
for production use it is generally advisable to use a more sophisticated
126+
implementation.
127+
115128
#### Stateless Mode
116129

117130
The streamable server supports a _stateless mode_ by setting

0 commit comments

Comments
 (0)