You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As described in #272, there is really no reason for transports to be
closed structs with constructors, since their state must be established
by a call to Connect. Making them open structs simplifies their APIs,
and means that all transports can be extended in the future: we don't
have to create empty Options structs just for the purpose of future
compatibility.
For now, the related constructors and options structs are simply
deprecated (with go:fix directives where possible). A future CL will
remove them prior to the v1.0.0 release.
For #272
@@ -128,6 +122,8 @@ The HTTP transport APIs are even more asymmetrical. Since connections are initia
128
122
129
123
Importantly, since they serve many connections, the HTTP handlers must accept a callback to get an MCP server for each new session. As described below, MCP servers can optionally connect to multiple clients. This allows customization of per-session servers: if the MCP server is stateless, the user can return the same MCP server for each connection. On the other hand, if any per-session customization is required, it is possible by returning a different `Server` instance for each connection.
130
124
125
+
Both the SSE and Streamable HTTP server transports are http.Handlers which serve messages to their associated connection. Consequently, they can be connected at most once.
126
+
131
127
```go
132
128
// SSEHTTPHandler is an http.Handler that serves SSE-based MCP sessions as defined by
133
129
// the 2024-11-05 version of the MCP protocol.
@@ -153,26 +149,10 @@ By default, the SSE handler creates messages endpoints with the `?sessionId=...`
153
149
```go
154
150
// A SSEServerTransport is a logical SSE session created through a hanging GET
155
151
// request.
156
-
//
157
-
// When connected, it returns the following [Connection] implementation:
158
-
// - Writes are SSE 'message' events to the GET response.
159
-
// - Reads are received from POSTs to the session endpoint, via
160
-
// [SSEServerTransport.ServeHTTP].
161
-
// - Close terminates the hanging GET.
162
-
type SSEServerTransport struct { /* ... */ }
163
-
164
-
// NewSSEServerTransport creates a new SSE transport for the given messages
165
-
// endpoint, and hanging GET response.
166
-
//
167
-
// Use [SSEServerTransport.Connect] to initiate the flow of messages.
168
-
//
169
-
// The transport is itself an [http.Handler]. It is the caller's responsibility
170
-
// to ensure that the resulting transport serves HTTP requests on the given
171
-
// session endpoint.
172
-
//
173
-
// Most callers should instead use an [SSEHandler], which transparently handles
174
-
// the delegation to SSEServerTransports.
175
-
funcNewSSEServerTransport(endpoint string, w http.ResponseWriter) *SSEServerTransport
152
+
type SSEServerTransport struct {
153
+
Endpoint string
154
+
Response http.ResponseWriter
155
+
}
176
156
177
157
// ServeHTTP handles POST requests to the transport endpoint.
0 commit comments