← Back to Dashboard
1. Sampling & Roots2. Async Tasks (2025)3. Elicitation & HITL

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

Roots define the operational boundaries of an MCP Server within a filesystem or structure.

// 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.
Watch: 139x Rust Speedup
Sampling & Roots | Advanced Features — MCP Academy