← Back to ToolBench
Client Features
Roots
Filesystem boundary awareness for servers
What it does
Roots let the client inform the server about which filesystem directories or URIs it should operate within. When a client provides roots via roots/list, the server knows the boundaries of the user's workspace. This prevents servers from accessing files outside the intended scope and enables file-aware features. Roots are informational: the server should respect them but the protocol does not enforce it.
How it works
Example implementation
const roots = await client.listRoots();
// roots = [{ uri: "file:///Users/dev/project", name: "My Project" }]
// Server uses roots to scope file operations
async function readFile(path: string) {
if (!roots.some(r => path.startsWith(r.uri))) throw new Error("Outside workspace");
return fs.readFile(path);
}