Skip to main content
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 using ctx.list_roots().

Configuration

To expose roots to MCP servers, provide a roots 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

Each Root object has the following fields:

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