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.
// On Server: Requesting current boundaries
const rootList = await server.requestRoots();
console.log(rootList.roots); // e.g. [{ uri: "file:///usr/src/app" }]