Sampling
One of the most powerful features of MCP is sampling. What does that mean, first of all? Well, let’s take a look at the definition of the word and deduce from there. Merriam-Webster defines sampling as follows:
“the action or process of taking samples of something for analysis”
Okay, so we need a sample, and we end up analyzing said sample, understood. With this definition in mind, let’s talk about it in the context of MCP. In MCP, sampling means the server is sending a sampling request, a sample for analysis, to the client. Why does the server do that? It’s simple; the server needs the client’s help with some things. Because the client is the one with the LLM (even though a server can have an LLM sometimes), the server delegates tasks to the client, where an LLM can help.
Makes sense so far, right? But I bet you’re asking why a server would do that.
In this chapter, we’ll do the following:
- 
    ...
 
                                             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
     
         
                 
                 
                 
                 
                 
                 
                 
                 
                