mcp: support SSE polling and server disconnects (SEP-1699) (#663)
This CL implements support for SEP-1699, adding the following new API: - Event.Retry corresponds to the 'retry' field of a server sent event. This is used to signal client retry behavior. - RequestExtra.CloseStream is set by the streamable transport to allow closing a stream. The streamable server transport is updated to set CloseStream for calls, allowing server operations or middleware to close the underlying stream. If the configured 'reconnectAfter' delay is set, a 'retry' message is sent prior to terminating the stream. The streamable client transport is updated to read the configured delay. Fixes #630
This commit is contained in:
parent
1bec3c60a0
commit
623780125c
1 changed files with 340 additions and 64 deletions
|
|
@ -468,6 +468,14 @@ type ServerRequest[P Params] struct {
|
|||
type RequestExtra struct {
|
||||
TokenInfo *auth.TokenInfo // bearer token info (e.g. from OAuth) if any
|
||||
Header http.Header // header from HTTP request, if any
|
||||
|
||||
// CloseStream closes the current request stream, if the current transport
|
||||
// supports replaying requests.
|
||||
//
|
||||
// If reconnectAfter is nonzero, it signals to the client to reconnect after
|
||||
// the given duration. Otherwise, clients may determine their own
|
||||
// reconnection policy.
|
||||
CloseStream func(reconnectAfter time.Duration)
|
||||
}
|
||||
|
||||
func (*ClientRequest[P]) isRequest() {}
|
||||
|
|
|
|||
Loading…
Reference in a new issue