MCP sampling

MCP sampling lets an MCP server ask the client to run a language model request for it, so the server needs no model API key of its own.

How it works

The server sends the client a request with the messages it wants completed and its preferences for the model. The client chooses the model, can show the request to the user for approval, runs it and sends the answer back to the server.

Why it matters

Sampling lets a server do work that needs a model, such as summarising what it found, while the client stays in charge of model access and cost. The risk is that a server writes prompts and spends the client’s model budget, which is why the specification recommends a human check and why limits matter.

Where a gateway fits

Only some clients support sampling. Where it is in use, the model requests it creates should be visible in the same logs as the tool calls, which is easier when both pass through one MCP gateway.

Related terms

Further reading