Module 6 · Lesson 2 · 14 min read

MCP architecture: host, client and server

MCP Architecture: Host, Client and Server

Introduction

To understand MCP in depth we need to know who does what. This lesson details the responsibilities of the host, the client and the server, the "one client per server" rule, and traces the journey of the user's question from the moment it is written until the tool's result reaches the model.

Learning objectives

  • Describe the responsibilities of the host, the client and the server precisely
  • Explain the relationship between the client and the server and why each server is isolated from the others
  • Trace the sequence of messages when a tool is called from the user's question
  • Distinguish between local and remote servers

Three roles with three responsibilities

JSON-RPCJSON-RPCHostThe AI applicationLanguage modelLLMMCP client 1ClientMCP client 2ClientMCP server: knowledgeTools · Resources · PromptsMCP server: filesResourcesTransportstdio or Streamable HTTP
MCP structure: the host (the AI application) runs a client for each server, and the server exposes tools, resources and templates over JSON-RPC 2.0.

Host

The host is the application the person deals with: a chat application, a development environment, or an agent running in the background. It has the final say, and its responsibilities are:

  • Running the language model and managing the conversation.
  • Creating a client for every server it wants to connect to.
  • Gathering tools and resources from the servers and deciding what is shown to the model.
  • Applying security policies and asking for user consent before sensitive operations.

Client

The client is a component inside the host, tied to a single server only. It sends requests in JSON-RPC 2.0 format, puts the protocol version in _meta for each request according to the 2026-07-28 specification, and receives the replies and passes them to the host. If the host wants to talk to three servers, it creates three clients.

Server

The server is a focused program that offers specific capabilities through tools, resources and prompts. It does not see the whole conversation and does not see the other servers; it sees only the requests that reach it. And it must provide the server/discover method so the client can learn about it and its capabilities.

Local and remote servers

KindHow it worksThe usual transportExample
LocalThe host runs it as a subprocess on the same machinestdioA server that reads the files in the project folder
RemoteIt runs on a web server that the client reaches over the networkStreamable HTTPThe university's ticketing system server

We go deeper into transports in a later lesson; what matters now is that the architecture is the same in both cases: a host, clients and servers.

A question's journey: from the user to the tool

ClientServerserver/discover (optional)tools/list ← the list of tools and their schemastools/call {name, arguments}result {resultType, content, isError}Protocol error: JSON-RPC error (such as -32602)
The message sequence in the 2026-07-28 specification: every request carries the protocol version in _meta, and there is no initialize handshake.

A student writes in the university assistant: "When is the CS101 lecture?" This is the sequence of what happens:

  1. The host has already asked each server for its list of tools through tools/list (and it can learn about the server first through server/discover).
  2. The host presents the available tools to the model together with the student's question.
  3. The model decides to call the get_course_schedule tool with the argument course_code: "CS101".
  4. The host checks the policies, and asks for the user's consent if the tool is sensitive.
  5. The courses server's client sends a tools/call request carrying the version in _meta.
  6. The server runs the tool and returns a result containing content, which may also contain structuredContent.
  7. The host passes the result to the model, which writes the answer for the student.

Notice that the model never connects to the server directly; it proposes, and the host decides and executes through the client.

A practical example: a host with two clients

The following simulation (Python with no libraries, with the model replaced by a fixed rule) embodies three architectural rules: a client for each server, consent before sensitive tools, and the model never connecting to the server directly:

python
class Server:
    def __init__(self, tools, sensitive=()):
        self.tools, self.sensitive = tools, set(sensitive)

    def handle(self, request):
        name = request["params"]["name"]
        args = request["params"]["arguments"]
        text = self.tools[name](**args)
        return {"content": [{"type": "text", "text": text}], "isError": False}

class Client:  # one client tied to one server
    def __init__(self, server):
        self.server, self.next_id = server, 1

    def call_tool(self, name, arguments):
        request = {"jsonrpc": "2.0", "id": self.next_id, "method": "tools/call",
                   "params": {"name": name, "arguments": arguments,
                              "_meta": {"io.modelcontextprotocol/protocolVersion": "2026-07-28"}}}
        self.next_id += 1
        return self.server.handle(request)

class Host:
    def __init__(self, servers, ask_user):
        self.clients = {n: Client(s) for n, s in servers.items()}
        self.ask_user = ask_user

    def run_tool(self, server_name, tool, args):
        server = self.clients[server_name].server
        if tool in server.sensitive and not self.ask_user(tool, args):
            return "The user refused to run the tool"
        result = self.clients[server_name].call_tool(tool, args)
        return result["content"][0]["text"]

servers = {
    "courses": Server({"get_course_schedule": lambda course_code: f"{course_code}: Sunday 10:00"}),
    "mail": Server({"send_email": lambda to, body: f"Sent to {to}"}, sensitive=["send_email"]),
}
host = Host(servers, ask_user=lambda tool, args: False)  # the user refuses here
print(host.run_tool("courses", "get_course_schedule", {"course_code": "CS101"}))
print(host.run_tool("mail", "send_email", {"to": "dr@example.edu", "body": "Hello"}))
print("Number of clients:", len(host.clients))

Summary

The host is the application that manages the model, the conversation, security and user consent, and it creates a client for each server. The client is tied to a single server and sends JSON-RPC requests carrying the version in _meta. The server is focused and isolated from the others, and it must provide server/discover. And the model does not connect to the servers directly; it proposes and the host executes through the client.

Terms

TermEnglishDefinition
HostHostThe application that manages the model, the clients and the security policies
ClientClientA component in the host that is tied to a single server and exchanges messages with it
ServerServerA focused program that offers tools, resources and prompts
Local serverLocal ServerA server that the host runs as a subprocess on the same machine
Remote serverRemote ServerA server reached over the network
User consentUser ConsentExplicit permission from the user before a sensitive operation

Review questions

  1. Why is each client tied to only one server?
  2. What host responsibilities cannot be delegated to the server?
  3. In your own words, put in order the steps of calling a tool from the moment the user asks.
  4. What is the difference between a local and a remote server in terms of running and transport?

References