How does the sampling flow work step by step in MCP?
MCP Advanced: Sampling, Server-to-Client LLM Requests, Cost Shifting Explained
Audio flashcard · 0:30Nortren·
How does the sampling flow work step by step in MCP?
0:30
The sampling flow follows six steps. First, the server completes its work, such as fetching data from external sources. Second, the server creates a prompt asking for text generation. Third, the server sends a sampling request to the client through the MCP session. Fourth, the client calls Claude with the provided prompt using its own API credentials. Fifth, the client returns the generated text to the server. Sixth, the server uses the generated text in its final response. The server never touches the language model API directly throughout this entire process.
modelcontextprotocol.io