Lesson 2 of 9 · Concepts
Hosts, Clients and Servers
MCP's architecture: the host app, one client per server and servers offering tools, resources and prompts. See the JSON-RPC messages and capability discovery.
- 5 min read
- Intermediate
- Reviewed
- Explain the roles of hosts, clients and servers in MCP
- Read an MCP request in JSON-RPC 2.0 format
- Describe the metadata every request carries in the current protocol
- Explain how a client discovers what a server offers
Three roles
| Role | Is… | Example |
|---|---|---|
| Host | The AI application, with the model and the user interface | A chat app, a code editor, an agent |
| Client | A connector inside the host, one per server | The host's link to your notes server |
| Server | A program offering tools, resources and prompts | A notes server, a GitHub server |
The host stays in charge. It decides which servers to connect, which tools the model may see, and asks the user for approval before tools run. Servers never see the whole conversation, only the requests sent to them.
The messages
Clients and servers talk in JSON-RPC 2.0: each request has an id, a method such as tools/list or tools/call, and params; each response carries the same id and either a result or an error.
import json
PROTOCOL_VERSION = "2026-07-28"
CLIENT_INFO = {"name": "my-ai-app", "version": "1.0"}
def make_request(request_id, method, params=None):
"""Build an MCP request. Every request carries its own protocol version and
client details in _meta, so the server needs no memory of earlier requests."""
params = dict(params or {})
params["_meta"] = {
"io.modelcontextprotocol/protocolVersion": PROTOCOL_VERSION,
"io.modelcontextprotocol/clientCapabilities": {},
"io.modelcontextprotocol/clientInfo": CLIENT_INFO,
}
return {"jsonrpc": "2.0", "id": request_id, "method": method, "params": params}
# A host app with one client per server it connects to
host = {
"host": "My AI app",
"clients": [
{"server": "notes (local, stdio)"},
{"server": "github (remote, Streamable HTTP)"},
{"server": "calendar (remote, Streamable HTTP)"},
],
}
print(f"{host['host']} runs {len(host['clients'])} MCP clients:")
for c in host["clients"]:
print(" client ->", c["server"])
print("\nWhat one client sends to ask a server what it offers:")
print(json.dumps(make_request(1, "server/discover"), indent=2))Every request stands alone
In the current protocol version (2026-07-28), MCP is stateless: each request carries everything the server needs in its _meta field, including the protocol version and the client's capabilities. A server doesn't need to remember earlier requests, so any copy of a server behind a load balancer can answer any request.
To learn what a server offers, a client sends server/discover. Here is a real response from the notes server you'll build later in this course:
{"jsonrpc":"2.0","id":1,"result":{
"capabilities":{"prompts":{"listChanged":true},"resources":{"listChanged":true,"subscribe":true},"tools":{"listChanged":true}},
"instructions":"Personal notes stored as Markdown files.",
"supportedVersions":["2026-07-28"],
"resultType":"complete",
"_meta":{"io.modelcontextprotocol/serverInfo":{"name":"Notes","version":""}}}}The server says which features it has (tools, resources, prompts), which protocol versions it supports, and gives short instructions the host can pass to the model. The client then calls tools/list, resources/list or prompts/list for the details.
Common mistakes
Build the JSON-RPC request a client sends to call one of a server's tools.
import json
def make_request(request_id, method, params=None):
params = dict(params or {})
params["_meta"] = {
"io.modelcontextprotocol/protocolVersion": "2026-07-28",
"io.modelcontextprotocol/clientCapabilities": {},
}
return {"jsonrpc": "2.0", "id": request_id, "method": method, "params": params}
# Build request number 7: call the tool "search_notes" with the argument query = "Lisbon".
# (tools/call takes params {"name": ..., "arguments": {...}})
request = make_request(7, "tools/list")
print(request["method"], request["params"]["name"], request["params"]["arguments"])
A host app connects to four MCP servers. How many MCP clients does it run?
Summary
- The host is the AI app; it runs one client per server it connects to.
- Messages are JSON-RPC 2.0 requests and responses with matching IDs.
- In the current version, every request is self-contained, carrying its protocol version and client capabilities in
_meta. - Clients learn what a server offers with server/discover, then list its tools, resources and prompts.
Next: what tools, resources and prompts are, and who controls each.
Finished reading? Tick it off to track your progress.