What is MCP sampling?
MCP sampling is a Model Context Protocol client feature letting a server without its own API key request text, audio or image generation from the client's language model, with model access, selection and permissions staying with the client. It is deprecated as of revision 2026-07-28.
Unlike MCP elicitation, where the server asks the user for input, here it asks the client's model to generate. The server cannot impose a model; it states cost, speed and intelligence priorities from 0 to 1 plus optional model hints while the client chooses.
- Topic
- Agents and protocols
- Also known as
- Sampling
- Origin
- Model Context Protocol specification, 2024
How MCP sampling works
- The client declares the sampling capability, plus tool use support if needed.
- Mid-request, the server sends a sampling request with messages, model preferences and generation settings.
- The client can show the request for the user to edit, then picks a suitable model and generates.
- The output can pass user review before returning to the server.
In more detail
Isolated inference context and the systemPrompt security boundary
Unlike normal chat turns, a 'sampling/createMessage' call runs as an isolated inference request defined by the server's 'messages', optional 'systemPrompt', 'maxTokens' and 'temperature'; it does not automatically carry the host's main conversation history unless explicitly included. Because a malicious server can supply an adversarial 'systemPrompt' or trigger tool loops, hosts must never silently expose private conversation state or bypass safety system instructions.
Reasons for deprecation and architectural consequences
MCP sampling was deprecated in revision 2026-07-28 partly because inversion of control blurred billing, rate-limiting, security accountability and guardrail ownership between clients and third-party servers. In addition, allowing servers to drive nested agentic loops inside a client created complex UX and token-amplification risks that are far cleaner to manage when servers call an LLM gateway directly with their own service credentials.
Service identity and trace correlation when moving to a direct LLM API
When migrating from MCP sampling to direct LLM API integration, the server transitions from riding on the user's host credentials to holding its own service identity. Organisations must therefore issue scoped service tokens for the server, enforce per-server token quotas at the AI gateway and propagate correlation IDs ('traceparent') so user-initiated actions remain auditable end-to-end.
Commonly confused terms
| Term | How it differs |
|---|---|
| MCP prompt | An MCP prompt is a reusable template exposed by a server for the user to select and inject into the host's main conversation; MCP sampling was a reverse call allowing a server to trigger an isolated LLM generation inside the client. |
| Agent tool calling | Standard LLM tool calling flows from host/model to server (the model invokes a server tool); MCP sampling inverted control so a server could request LLM inference back from the client. |
Why MCP sampling matters for on-premises AI
Sampling let servers build agentic behaviour without their own model access, leaving model control with the client. The specification advises always keeping a human in the loop able to deny requests, letting users review prompts and outputs, plus rate limiting and iteration limits for tool loops. Revision 2026-07-28 deprecates the feature: it stays for at least twelve months and existing implementations should integrate directly with language model provider APIs.
A consultancy's summarising server got summaries from the client's model via sampling; after the protocol update it connects directly to an in-house model server, with model access controlled through a central gateway.
Common questions
Can the server choose the model in MCP sampling?
Not directly. It states cost, speed and intelligence priorities with optional model hints; the client picks the model.
Should MCP sampling still be used?
It is deprecated as of revision 2026-07-28. New implementations should integrate directly with language model provider APIs.
Related terms
Sources
- Model Context Protocol, Specification 2026-07-28: Sampling
- Model Context Protocol, Specification 2026-07-28: Architecture
In the glossary: Glossary, M to Q