addRoot method
Add a server-side root entry to the local cache.
NOTE: Per MCP spec, roots are a client-owned concept — the server
asks the client for its roots via requestClientRoots. This method
only manages an OPTIONAL server-side cache and does NOT emit
notifications/roots/list_changed (which would be in the wrong
direction — spec defines that notification as client → server).
Use requestClientRoots to fetch the client's authoritative roots.
Implementation
void addRoot(Root root) {
if (_roots.any((r) => r.uri == root.uri)) {
throw McpError('Root with URI "${root.uri}" already exists');
}
_roots.add(root);
}