Grokking the Model Context Protocol (MCP)
Vote

0% completed

​

Hosts, Clients, and Servers

The Three Participants

What the Host Does

What a Client Does

What a Server Does

Local and Remote Servers

Roles, Not Products

Key Takeaways

Practice Questions

An employee opens a chat assistant on a laptop. The assistant is connected to two things: Costbook, and a folder of receipts on the same laptop. How many MCP clients are running?

The answer is two, and the chat assistant is neither of them. MCP has three participants with exact names, and much of the confusion about the protocol comes from mixing those names. This lesson defines each participant, lists its responsibilities, and explains what it can and cannot see.

The Three Participants

A host is the AI application that a person uses. It contains the model, shows the conversation, and decides which servers it will work with. A chat assistant is a host, and so is a code editor with an assistant built in. The previous lesson called it "the AI application".

An MCP client is a part inside the host that communicates with exactly one server. The host creates one client for each server. The employee in the opening connected two servers, so the host created two clients.

An MCP server is a program that offers tools and data to clients. The Costbook team writes the server for Costbook. A different author wrote the server that reads the receipts folder.

One host with two clients, and one server for each client.
One host with two clients, and one server for each client.

Notice that each client has one line to one server, and that the model has no line to any server. Every message passes through the host.

In everyday speech, people often call the whole application a client, as in "this editor is an MCP client". That usage is common. The exact terms matter when you reason about what each part can see, so this course uses them strictly. The MCP documentation gives Visual Studio Code and Claude Desktop as examples of hosts.

What the Host Does

The host coordinates the work, and it is the only participant that can protect the user. The specification gives the host these responsibilities:

  • It creates the clients and decides which servers may be connected.
  • It calls the model and gives the model the tool descriptions from every server.
  • It asks the user for consent and enforces the answer.
  • It keeps the conversation and combines the results from several servers.

Consider the request from the previous lesson: "Add the taxi receipt from Tuesday, 42 dollars, to my Berlin trip report." The model first asks for the receipt file, and the host sends that request to the client for the files server. The model then asks to create the expense. The host shows the employee what is about to happen, waits for approval, and sends the request to the client for the Costbook server.

What a Client Does

A client speaks the protocol for one server. It turns a request from the host into an MCP message, sends the message, and returns the result to the host. Because each client knows one server only, a message for Costbook can never reach the files server by mistake.

A client does not open a session with its server. The specification describes MCP as a stateless protocol, which means that every request carries everything the server needs to answer it. Engineers rarely write a client by hand, because the official software development kits include one.

What a Server Does

A server does one focused job and knows nothing outside it. The Costbook server describes Costbook's tools and runs them. It contains no model, and it does not know which other servers the host uses.

The specification states this as a design principle: a server should not be able to read the whole conversation, and it should not be able to see into other servers. For the taxi receipt, the Costbook server receives one message that asks it to create an expense of 42 dollars on a named report. It never receives the employee's sentence or the contents of the receipts folder, unless the host places them in a request.

HostClientServer
<span style="white-space:nowrap">Contains the model</span>YesNoNo
<span style="white-space:nowrap">Sees the whole conversation</span>YesNoNo
<span style="white-space:nowrap">Knows the other servers</span>YesNoNo
<span style="white-space:nowrap">Asks the user for approval</span>YesNoNo
<span style="white-space:nowrap">Runs the tool</span>NoNoYes

This separation has a practical benefit. The Costbook team can build its server without knowing anything about the hosts that will use it, and a host can add a server without changing any other server.

Local and Remote Servers

A local server runs on the user's own machine, and a remote server runs as a service on a network. The files server is local. The host starts it as a process on the laptop, and the two exchange messages through that process's standard input and output. The Costbook server is remote. It runs on Costbook's own infrastructure, and clients reach it over HTTP.

A local server serves one host on the same machine. A remote server serves the hosts of many users.
A local server serves one host on the same machine. A remote server serves the hosts of many users.

Look at the right side of the diagram. The Costbook server receives requests from the hosts of many customers, so it must establish which user sent each request before it does anything. Now look at the left side. The files server runs with the employee's own permissions, so it can read every file that the employee can read.

Local serverRemote server
<span style="white-space:nowrap">Where it runs</span>The user's machineA service on a network
<span style="white-space:nowrap">How messages travel</span>Standard input and output of a processHTTP
<span style="white-space:nowrap">Clients served</span>Typically oneTypically many
<span style="white-space:nowrap">Who starts it</span>The hostThe team that owns the product
<span style="white-space:nowrap">Typical use</span>Files and programs on the machineA product with many users

Costbook is sold to many companies, and none of its data is on an employee's laptop. A remote server is therefore the natural choice for it.

Roles, Not Products

The three names describe roles in one relationship, not kinds of products. A program is a server because it answers MCP requests from a client. The same program can also act as a client of another server, for example when a company places one server in front of several others and forwards requests to them. When a design is unclear, look at each pair of programs and ask which one sends the request and which one answers.

Key Takeaways

  • A host is the AI application. It contains the model, keeps the conversation, and asks the user for consent.
  • A client is a part inside the host that communicates with exactly one server. A host with five servers has five clients.
  • A server offers tools and data. It contains no model, and it cannot see the conversation or the other servers.
  • A local server runs on the user's machine and typically serves one client. A remote server runs on a network and typically serves many.
  • Every message between the model and a server passes through the host, which is why the host can enforce approval.

A server can offer more than tools. The next lesson, Tools, Resources, and Prompts, explains the three kinds of things a server offers and who decides when each one is used.

Practice Questions

1. A code editor with an assistant is connected to five MCP servers. How many hosts and how many clients are there?

<details><summary>Show answer</summary>

One host and five clients. The editor is the host. It creates one client for each server, and each client communicates with exactly one server.

</details>

2. The Costbook team wants its server to open the receipts folder and confirm that a receipt exists. Why can the server not do this?

<details><summary>Show answer</summary>

A server cannot see into another server. The receipts folder belongs to the files server on the employee's laptop. The Costbook server receives only what the host places in a request, so the host must read the receipt through the files server and pass the needed content to Costbook.

</details>

3. One server reads a developer's code repository on disk. Another serves a payment product with 10,000 customers. Which should be local, and which remote?

<details><summary>Show answer</summary>

The repository server should be local, and the payment server should be remote. The repository is on the developer's machine, and a local server can read it with the developer's permissions. The payment product serves many users from one place, so it runs as a network service and identifies the user on each request.

</details>

4. A teammate proposes that the Costbook server should ask the host's model to summarize an expense report before returning it. What is wrong with this design?

<details><summary>Show answer</summary>

The model belongs to the host, not to the server. The server returns the report, and the host's model can summarize it for the user. If the server needs a model for its own work, it must call a model provider itself.

</details>

Reading Progress

0%


Vote for new content

On This Page

The Three Participants

What the Host Does

What a Client Does

What a Server Does

Local and Remote Servers

Roles, Not Products

Key Takeaways

Practice Questions