
This page is part of our MCP specification reference, a plain-English guide to the Model Context Protocol spec (version 2026-07-28), within The MCP Guide. Building a server? See MCP development.
Status in the 2026-07-28 spec: deprecated (still functional; eligible for removal in the first spec released on or after 28 July 2027)
Sampling is an MCP feature that lets a server ask the client's AI model to generate text for it. Instead of holding its own model API key, the server sends a prompt to the AI app, and the app runs it through whatever model the user is already using.
The 2026-07-28 MCP specification deprecated Sampling. It still works, but new projects should not adopt it. The spec's suggested replacement is simple: "integrate directly with LLM provider APIs." This page explains what Sampling did, why it is being retired, and how to move off it.
Key Takeaways
- Sampling let an MCP server request a model completion through the client, with no server API key.
- It was deprecated in the 2026-07-28 spec, together with Roots and Logging.
- Under the deprecation policy, it stays in the spec for at least twelve months.
- The recommended replacement is to call an AI model provider's API directly from your server.
- The
includeContextvaluesthisServerandallServersare also deprecated and will go no later than Sampling.
What Sampling was for
Some servers need a bit of AI inside their own logic. A server might want to summarize a document, classify a ticket, or decide the next step in a workflow. Sampling let the server borrow the client's model for that.
The Sampling page of the spec says it lets clients "maintain control over model access, selection, and permissions." Servers get AI capabilities "with no server API keys necessary." The spec also says there should always be "a human in the loop with the ability to deny sampling requests."
Sampling has been part of MCP since the first published version, 2024-11-05.
How it works in 2026-07-28
Sampling still functions during the deprecation window. Like elicitation, it now travels through Multi Round-Trip Requests. The server cannot send its own request to the client, so it returns an input_required result containing a sampling/createMessage request. The client gets the user's approval, runs the model, and retries the original call with the model's answer.
Here is the request, adapted from the spec example (we removed the deprecated includeContext field):
{
"method": "sampling/createMessage",
"params": {
"messages": [
{
"role": "user",
"content": { "type": "text", "text": "What is the capital of France?" }
}
],
"modelPreferences": {
"hints": [{ "name": "claude-3-sonnet" }],
"intelligencePriority": 0.8,
"speedPriority": 0.5
},
"systemPrompt": "You are a helpful assistant.",
"maxTokens": 100
}
}
A few details are worth knowing:
- Model choice stays with the client. The server can give hints and priorities for cost, speed and intelligence. The spec says "hints are advisory" and the client makes the final model choice.
maxTokensis required. The client must respect it but may ignoretemperatureand similar settings.- Tool use is possible. Since 2025-11-25, a server can pass
toolsandtoolChoiceso the model can call tools during sampling. The client must declaresampling.toolsfirst.
Why it was deprecated
The changelog lists the deprecation of Roots, Sampling and Logging under SEP-2577. The spec pages state the outcome and the migration path. They do not give a long rationale, so we will not invent one.
What we can say from the spec itself: Sampling depends on the server reaching back to the client mid-request. The 2026-07-28 release rebuilt MCP so that servers never start requests. Sampling survives only by being squeezed into the retry pattern. Calling a model provider directly is a plainer design that the protocol does not need to carry.
The deprecation timeline
The deprecated features registry lists Sampling as:
| Item | Detail |
|---|---|
| Deprecated in | 2026-07-28 |
| Migration path | Integrate directly with LLM provider APIs |
| Earliest removal | First spec revision released on or after 2027-07-28 |
The registry notes that earliest removal is when a feature becomes "eligible" for removal. The actual removal is a Core Maintainer decision and "may happen later." The general rules are in the feature lifecycle policy and our guide to MCP versioning and deprecation.
The includeContext values "thisServer" and "allServers" were soft-deprecated in 2025-11-25. They are now formally deprecated and will be removed no later than Sampling. Omit the field or use "none".
What changed across spec versions
| Version | Sampling change |
|---|---|
| 2024-11-05 | Included in the first spec as a server-to-client request |
| 2025-11-25 | Tool calling added via tools and toolChoice (changelog) |
| 2026-07-28 | Moved to MRTR delivery; whole feature deprecated |
How to migrate
- Find where you use it. Search your server code for
createMessageor your SDK's sampling helper. - Pick a model provider. Call it directly from your server with your own API key, stored as a secret.
- Budget for cost and rate limits. With Sampling, the user's AI app paid for the model call. Now your server does.
- Keep humans in the loop where it matters. If a sampled answer led to an action, consider asking the user with elicitation before acting.
- Stop advertising reliance on it. Remove sampling-only code paths once your server no longer needs clients to support it.
Common mistakes
- Starting a new server on Sampling. The spec says new implementations "SHOULD NOT adopt it."
- Copying spec examples that use
includeContext: "thisServer". That value is deprecated. - Assuming you get a specific model. Hints are advice. The client can map them to any model.
- Forgetting the cost shift. Direct model calls cost your business money and need limits against runaway usage.
Next step
Sampling was one of three features deprecated together. See what happened to the others in MCP Roots: status and what replaced them, or return to the MCP specification reference. If you need help moving a server off Sampling, our MCP development team can scope it.
Frequently asked questions
Is MCP sampling removed?
Not yet. As of October 2026, Sampling is deprecated but still part of the 2026-07-28 spec and still works. It becomes eligible for removal in the first spec revision released on or after 28 July 2027.
What should I use instead of MCP sampling?
The spec says to integrate directly with LLM provider APIs. In practice, your server calls a model provider with its own API key. That means your server pays for the calls and manages its own rate limits.
Do AI apps support sampling?
Support varies by client. For example, Anthropic's guide to building MCP servers for Claude lists Sampling among the features Claude "doesn't yet support" (checked 28 October 2026). Check each client's own docs, and do not build new features that depend on it.
Why did sampling need a human in the loop?
Because a server was spending the user's model access. The spec says there should always be a human able to deny sampling requests, and apps should let users review prompts and responses.
Is the includeContext field still allowed?
Only the value "none" is safe for new work. The values "thisServer" and "allServers" are deprecated and will be removed no later than Sampling itself.











