mcp-use
Version:
Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents, Clients and Servers with support for ChatGPT Apps, Code Mode, OAuth, Notifications, Sampling, Observability and more.
56 lines • 1.77 kB
TypeScript
/**
* Roots Registration
*
* This module handles roots-related functionality for the MCP server.
* Roots represent the file system or project roots that clients have access to.
*/
/**
* Register a callback for when a client's roots change
*
* When a client sends a `notifications/roots/list_changed` notification,
* the server will automatically request the updated roots list and call
* this callback with the new roots.
*
* @param callback - Function called with the updated roots array
* @returns The server instance for method chaining
*
* @example
* ```typescript
* server.onRootsChanged(async (roots) => {
* console.log("Client roots updated:", roots);
* roots.forEach(root => {
* console.log(` - ${root.name || "unnamed"}: ${root.uri}`);
* });
* });
* ```
*/
export declare function onRootsChanged(this: any, callback: (roots: Array<{
uri: string;
name?: string;
}>) => void | Promise<void>): any;
/**
* Request the current roots list from a specific client session
*
* This sends a `roots/list` request to the client and returns
* the list of roots the client has configured.
*
* @param sessionId - The session ID of the client to query
* @returns Array of roots, or null if the session doesn't exist or request fails
*
* @example
* ```typescript
* const sessions = server.getActiveSessions();
* if (sessions.length > 0) {
* const roots = await server.listRoots(sessions[0]);
* if (roots) {
* console.log(`Client has ${roots.length} roots:`);
* roots.forEach(r => console.log(` - ${r.uri}`));
* }
* }
* ```
*/
export declare function listRoots(this: any, sessionId: string): Promise<Array<{
uri: string;
name?: string;
}> | null>;
//# sourceMappingURL=roots-registration.d.ts.map