MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / AddRoots

Method AddRoots

mcp/client.go:414–421  ·  view source on GitHub ↗

AddRoots adds the given roots to the client, replacing any with the same URIs, and notifies any connected servers.

(roots ...*Root)

Source from the content-addressed store, hash-verified

412// replacing any with the same URIs,
413// and notifies any connected servers.
414func (c *Client) AddRoots(roots ...*Root) {
415 // Only notify if something could change.
416 if len(roots) == 0 {
417 return
418 }
419 changeAndNotify(c, notificationRootsListChanged, &RootsListChangedParams{},
420 func() bool { c.roots.add(roots...); return true })
421}
422
423// RemoveRoots removes the roots with the given URIs,
424// and notifies any connected servers if the list has changed.

Callers 4

TestEndToEndFunction · 0.95
Example_rootsFunction · 0.95

Calls 2

changeAndNotifyFunction · 0.85
addMethod · 0.80

Tested by 4

TestEndToEndFunction · 0.76
Example_rootsFunction · 0.76