Sub topic 2
Host, client and server: who does what
Prerequisites
This chapter assumes you can use a command line, read JSON, and have used an AI coding assistant. You don't need to have written an MCP server yet.
The three roles
The Model Context Protocol (MCP) splits the work between three parties. Mixing them up is the most common source of confusion when you read documentation or debug a setup.
- Host: the application the user runs, such as a coding assistant or an editor. It owns the conversation with the model, shows the user the interface, and decides what is allowed.
- Client: a component inside the host. Each client keeps one connection to one server and speaks the protocol on the host's behalf.
- Server: a separate program that exposes capabilities, such as tools or data, to the client. It can be a local process or a remote service.
The host is a single application. It creates one client per configured server, so a host with three servers contains three clients.
What each role is responsible for
| Role | Responsibilities | Does not do |
|---|---|---|
| Host | Starts clients, talks to the model, asks the user for approval, applies security policy | Implement the tools themselves |
| Client | Opens the connection, negotiates capabilities, sends requests, receives responses | Talk to the model or decide policy |
| Server | Describes and runs tools, resources and prompts | See the conversation or other servers |
Two consequences follow from this split.
- The model never talks to a server directly. The model produces text, including a request to call a tool. The host reads that request and passes it to the right client. The client sends it to the server.
- Servers are isolated from each other. Each server sees only its own connection. It does not see the full conversation or what other servers return, unless the host passes that information along in a request.
Why the client layer exists
It may seem that the host could talk to servers itself. The separate client gives you a one-to-one session boundary. Each session has its own state, its own negotiated capabilities, and its own failure. If the filesystem server crashes, the database connection stays up, because they are different clients.
It also keeps the host code simple. The host handles the same client interface whether the server runs as a local process or over the network.
A concrete example
Suppose you add the reference filesystem server to your assistant. The configuration looks like this:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"]
}
}
}Map the roles onto it:
- The host is your coding assistant. It reads this file at startup.
- The client is created by the host for the entry named
filesystem. It launches thenpxcommand as a child process and connects to it. - The server is the process started by that command. It can read and write files, but only inside
/path/to/project.
When you ask "What does main.py do?", the model asks for a file read. The host approves it, based on your settings. The client forwards the request, and the server returns the file contents. The host then gives those contents to the model.
Common mistakes
- Calling the server "the client". Many guides say "MCP client" when they mean the whole assistant. In the protocol, the client is the connector inside the host. Watch for which sense a document uses.
- Expecting servers to call the model. Servers answer requests. A server can ask the client for a model completion only if the client advertises that ability, and the host stays in control of it.
- Assuming one client serves all servers. There is one client per server connection. A broken server affects only its own client.
Check your understanding
Exercise
A host is configured with four servers in mcpServers. How many clients does it create, and which role decides whether a tool call needs user approval?
Show answer
It creates four clients, one per server connection. The host decides on approval, because it owns the user interface and the security policy. The client only carries messages, and the server only runs the tool.
Exercise
The database server crashes while the filesystem server keeps working. Which part of the architecture explains this?
Show answer
Each server has its own client and its own session. The failure ends only the database server's connection, so the filesystem client is unaffected.