MCP 'Roots' and Sampling primitives are the most underrated security & UX features in the Model Context Protocol
Almost every MCP server tutorial stops after wiring tools/list and tools/call. That leaves two of the most powerful primitives in the Model Context Protocol sitting unused:
1. roots/list (Zero-Config Filesystem Jailing)
Instead of hardcoding --allowed-dir /Users/dev/project in JSON config files, the MCP client (Claude Desktop, Cursor, Windsurf) dynamically advertises workspace Roots via roots/list.
A well-behaved MCP server enforces every file read/write against those dynamic roots—eliminating accidental ../../.ssh/id_rsa path traversals across workspaces.
2. sampling/createMessage (Zero-API-Key Sub-LLM Compression)
Suppose an MCP server fetches a 400KB Kubernetes pod log. Normally, either:
- It dumps all 400KB into the host agent's context window (burning tokens), OR
- The MCP server asks the user to configure another
OPENAI_API_KEYjust to summarize logs.
With sampling/createMessage, the MCP server sends a reverse JSON-RPC request back to the host IDE asking the user's already-authenticated model to extract the 5 error lines before returning a crisp 300-token tool output.
Use the full protocol—not just the tool wrapper.