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.
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" }]