Documentation / @agentick/mcp / RootsAPI
Interface: RootsAPI
Defined in: protocol/types.ts:565
Sugar surface for roots/list exposed on MCPHandlerContext.roots. Always present — returns empty list (and treats assertWithin/isWithin permissively) when the client did not advertise the roots capability.
Methods
assertWithin()
assertWithin(
path):Promise<void>
Defined in: protocol/types.ts:580
Throws if path is outside all declared roots. No-op when no roots are declared.
Parameters
path
string
Returns
Promise<void>
isWithin()
isWithin(
path):Promise<boolean>
Defined in: protocol/types.ts:574
Returns true if path (a POSIX path or file:// URI) is within any declared root. Returns true when no roots are declared (permissive default — no constraints).
Parameters
path
string
Returns
Promise<boolean>
list()
list():
Promise<Root[]>
Defined in: protocol/types.ts:567
Returns the connected client's roots, fetched once and cached.
Returns
Promise<Root[]>
resolveRelative()
resolveRelative(
relativePath,opts?):Promise<string>
Defined in: protocol/types.ts:593
Joins a relative path against the first declared root, or against a root identified by name when supplied. Throws if no roots are declared, or if the named root cannot be found.
Parameters
relativePath
string
opts?
name?
string
Returns
Promise<string>
rootContaining()
rootContaining(
path):Promise<Root|null>
Defined in: protocol/types.ts:586
Returns the matching root for path, or null if none contains it. When multiple roots match, returns the most specific (longest-prefix).
Parameters
path
string
Returns
Promise<Root | null>
subscribe()
subscribe(
listener): () =>void
Defined in: protocol/types.ts:600
Subscribe to changes — fires when the client emits notifications/roots/list_changed and the cache is refreshed. Returns an unsubscribe function.
Parameters
listener
(roots) => void
Returns
():
void
Returns
void