Sampling Primitive: The Server Asks the Client's LLM to Generate
~12 min read
The client side always has an LLM — Sampling lets the server ask that LLM to generate completions mid-workflow, while the client still controls permissions and safety.
Sampling Primitive: The Server Asks the Client's LLM to Generate is a Pro topic
Sign in, then upgrade to Pro or Power to unlock this topic and the full AI Engineering curriculum.
Key points
- •Sampling is server-initiated: unlike Tools/Resources/Prompts (server offers TO client), the server REQUESTS something FROM the client here
- •It works because the client side always has an LLM available — the server borrows it rather than needing its own
- •The client still controls permissions and safety — the server requests, it doesn't command
- •The book's example: an MCP server with travel tools asks the client's LLM to pick the optimal flight from a list
- •This lets a server stay 'dumb' (no embedded reasoning) while still tapping into sophisticated LLM judgment when needed