What is MCP sampling? Model requests through a client

By

MCP sampling lets a server request a model response through its client. Learn the flow, client support limits, and why new servers should use provider APIs.

MCP sampling lets an MCP server ask its client to generate a model response. The application hosting the client controls which model handles the request and what the server receives.

Sampling is deprecated in the current MCP specification. New servers should integrate with model provider APIs directly. See Stateless MCP for the broader protocol changes.

How MCP sampling works

A tool can need a model response while doing its work. With sampling, it asks the client through sampling/createMessage rather than calling a provider itself. The client must advertise support.

A server requests model generation through its clientDuring a tool call, the server asks the client for a model response. The host controls the model request and returns an approved result to the server.sampling requestapproved resultMCP serverClient and hostModel

The sampling specification recommends letting users review requests and responses. That review matters when a server asks to send source code to a model.

In coding tools

The MCP guides for Claude Code, Codex, Cursor, and Grok Build do not document sampling support. An MCP connection alone gives you no reason to expect this feature.

Details checked against each vendor’s documentation in November 2026.

A concrete example

Consider the filesystem server in What is MCP?. Its read_text_file tool returns file contents. The coding agent can then summarize those contents in its normal conversation.

A server requesting its own model-generated summary through sampling/createMessage would add a separate model interaction. Check that distinction when an older server lists sampling as a requirement.

When to use it

The term is useful when reading older server implementations or debugging compatibility. For new server development, follow the official migration guidance and call a provider API directly.

Pitfalls

MCP sampling and temperature describe different things. Temperature changes token selection during generation; MCP sampling describes who requests a generation and how it reaches the model.

A nested request can add model usage and expose data to another processing step. Review what the server requests and where it goes.

For an MCP app workflow with explicit user approval, see Cloudflare Domains Toolkit and its purchase approval tutorial. Asking a person through elicitation is another protocol feature.

  • Tool calling: Tool calling is when a model names a function and its arguments, and the app runs it. How Claude Code, Codex, Cursor and Grok Build take that step.
  • MCP elicitation: MCP elicitation lets a server ask you for information during a workflow. Learn how coding clients present requests, and why the server must check your answer.
  • Temperature: Temperature changes how a language model samples its next token. Learn what it affects, when to adjust it, and why lower values do not ensure correct code.

All AI glossary entries →

Want me to talk about your product? You can sponsor this site.