From d7848c9e90d92070f76477bccf88acacd7732d47 Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Fri, 9 May 2025 10:28:43 -0400 Subject: [PATCH] internal/mcp: progress notifications Change-Id: I3dad9326a88c14d08d62395f603862f71f887a75 Reviewed-on: https://go-review.googlesource.com/c/tools/+/671475 TryBot-Bypass: Jonathan Amsterdam Reviewed-by: Robert Findley --- design/design.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/design/design.md b/design/design.md index c4b6637..f579b23 100644 --- a/design/design.md +++ b/design/design.md @@ -437,7 +437,24 @@ The server observes a client cancellation as cancelled context. ### Progress handling - +A caller can request progress notifications by setting the `ProgressToken` field on any request. +```go +type ProgressToken any + +type XXXParams struct { // where XXX is each type of call + ... + ProgressToken ProgressToken +} +``` +Handlers can notify their peer about progress by calling the `NotifyProgress` +method. The notification is only sent if the peer requested it. +```go +func (*ClientSession) NotifyProgress(context.Context, *ProgressNotification) +func (*ServerSession) NotifyProgress(context.Context, *ProgressNotification) +``` +We don't support progress notifications for `Client.ListRoots`, because we expect +that operation to be instantaneous relative to network latency. + ### Ping / Keepalive @@ -488,7 +505,7 @@ To perform sampling, a server calls `CreateMessage`. ``` type ClientOptions struct { ... - CreateMessageHandler func(context.Context, *CreateMessageParams) (*CreateMessageResult, error) + CreateMessageHandler func(context.Context, *ClientSession, *CreateMessageParams) (*CreateMessageResult, error) } func (*Server) CreateMessage(context.Context, *CreateMessageParams) (*CreateMessageResult, error)