Documentation Index
Fetch the complete documentation index at: https://docs.mcp-use.com/llms.txt
Use this file to discover all available pages before exploring further.
Roots allow clients to expose directories or files that MCP servers can access or operate on.
Overview
Roots represent directories or files that the client wants to make available to the server. This is useful for file-based operations where the server needs to know which paths are accessible. The server can request the list of roots at any time usingctx.list_roots().
Configuration
To expose roots to MCP servers, provide aroots list when initializing the MCPClient:
Dynamic Roots Updates
You can update the roots dynamically after connecting to a server. The client will automatically notify the server when roots change:Custom Roots Callback
For advanced use cases, you can provide a custom callback that dynamically determines which roots to expose:When a custom
list_roots_callback is provided, it takes precedence over the static roots list.Root Structure
EachRoot object has the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
uri | AnyUrl | Yes | A file:// URI pointing to the root directory or file |
name | str | No | A human-readable name for the root |
Example: File Manager Server
Here’s a complete example showing a client exposing roots to a file management server:Next Steps
- See Server Roots for how servers can request and use roots
- Learn about Sampling for enabling LLM capabilities
- Explore Elicitation for user input requests