internal/mcp: fix roots design

Minor changes to the roots part of the design.

Change-Id: I8125aecc5da297594f74d8d7dc5ef3d94dfa8519
Reviewed-on: https://go-review.googlesource.com/c/tools/+/671356
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Bypass: Jonathan Amsterdam <jba@google.com>
This commit is contained in:
Jonathan Amsterdam 2025-05-09 20:21:15 -04:00
commit 92ee792363

View file

@ -575,16 +575,14 @@ type XXXParams struct { // where XXX is each type of call
``` ```
Handlers can notify their peer about progress by calling the `NotifyProgress` Handlers can notify their peer about progress by calling the `NotifyProgress`
method. The notification is only sent if the peer requested it. method. The notification is only sent if the peer requested it by providing
a progress token.
```go ```go
func (*ClientSession) NotifyProgress(context.Context, *ProgressNotification) func (*ClientSession) NotifyProgress(context.Context, *ProgressNotification)
func (*ServerSession) 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 ### Ping / KeepAlive
Both `ClientSession` and `ServerSession` expose a `Ping` method to call "ping" Both `ClientSession` and `ServerSession` expose a `Ping` method to call "ping"
@ -625,16 +623,15 @@ Clients support the MCP Roots feature out of the box, including roots-changed no
Roots can be added and removed from a `Client` with `AddRoots` and `RemoveRoots`: Roots can be added and removed from a `Client` with `AddRoots` and `RemoveRoots`:
```go ```go
// AddRoots adds the roots to the client's list of roots. // AddRoots adds the given roots to the client,
// If the list changes, the client notifies the server. // replacing any with the same URIs,
// If a root does not begin with a valid URI schema such as "https://" or "file://", // and notifies any connected servers.
// it is intepreted as a directory path on the local filesystem. func (*Client) AddRoots(roots ...Root)
func (*Client) AddRoots(roots ...string)
// RemoveRoots removes the given roots from the client's list, and notifies // RemoveRoots removes the roots with the given URIs.
// the server if the list has changed. // and notifies any connected servers if the list has changed.
// It is not an error to remove a nonexistent root. // It is not an error to remove a nonexistent root.
func (*Client) RemoveRoots(roots ...string) func (*Client) RemoveRoots(uris ...string)
``` ```
Servers can call `ListRoots` to get the roots. If a server installs a Servers can call `ListRoots` to get the roots. If a server installs a