← Back to Dashboard
1. Sampling & Roots2. Async Tasks (2025)3. Elicitation & HITL4. Structured Content & Tool Annotations5. Completions & Metadata

Sampling & Roots

📚 Advanced Features10 min100 XP

Reversing the Flow (Sampling)

Normally, the Client asks the Server for data. Sampling reverses this: the Server can ask the Client's LLM to generate text or structure data on its behalf!

This allows self-contained agentic workflows inside your MCP server. Because requesting LLM completions implies cost, MCP mandates Human-in-the-Loop (HITL) approval via the Client UI.

Establishing Roots (Deprecated in MCP 1.5)

Roots define the operational boundaries of an MCP Server within a filesystem or structure. Note: As of MCP 1.5, Roots, Sampling, and Logging are deprecated from the core protocol to enable a Stateless Core. They are now handled directly by the Host application.

// On Server: Requesting current boundaries
const rootList = await server.requestRoots();
console.log(rootList.roots); // e.g. [{ uri: "file:///usr/src/app" }]
💡 Key Insight: The server reads these Roots and strictly respects them. The Host UI allows the user to dynamically add or remove folders from the Root list to manage security dynamically.
🧪 Knowledge Check
Press 1-4 to select1 of 3
What does MCP 'Sampling' refer to?
Measuring server RAM usage.
The Server asking the connected Client's LLM to generate completions.
Downloading subsets of databases.
Audio processing algorithms.
Sampling & Roots Tutorial | Advanced Features — MCP Academy