Architecture in practice: connecting a server to a host
Architecture in practice: connecting a server to a host
If you watch the video: the workshop (kQmXtrmQ5Zg) explains hosts, clients and servers well. Two parts are legacy under revision 2026-07-28: the client "opening a connection" with an initialize handshake and keeping session state, and sampling and roots described as active client features (they are now deprecated). In the current revision each request stands alone and carries its own version and capabilities.
Where you are: Module 0, lesson 3. You have the pinned lab from L02. Here you connect one real server to one real host and look at what each side is responsible for.
What you will be able to do
- Assign each responsibility in an MCP integration (consent, tool display, input validation, isolation) to the host, the client or the server.
- Connect the L11 lab server to Claude Code over Streamable HTTP and confirm it is connected.
- Observe the host asking for approval before a state-changing tool runs, and explain why a server's annotations cannot replace that.
- Explain why one server cannot read the conversation or another server's data.
Who does what (current, 2026-07-28)
The architecture page defines the roles by responsibility:
- Host: creates and manages clients; "controls client connection permissions"; "enforces security policies and consent requirements"; "handles user authorization decisions"; coordinates the model; aggregates context.
- Client: created by the host; "communicates with exactly one server"; "attaches protocol version and capabilities to every request"; "maintains security boundaries between servers".
- Server: exposes resources, tools and prompts; requests client input (elicitation) by returning an
InputRequiredResultinside a reply; "must respect security constraints"; runs locally or remotely.
Two design principles matter most in practice:
- Isolation. "Servers should not be able to read the whole conversation, nor 'see into' other servers." The full history stays with the host, and each server receives only the context it needs. If you connect a GitHub server and a database server, the database server never sees what GitHub returned unless the host passes it along.
- Stateless requests. MCP is stateless: every request carries its own version and capabilities. A client is not "a connection that remembers"; it is the component that attaches the right metadata to each request for its one server. (Legacy 2025-11-25 clients opened a session with
initialize; see L06.)
Consent lives in the host
The tools page says tools are model-controlled: the model decides when to call one. It then adds: "there SHOULD always be a human in the loop with the ability to deny tool invocations", and applications SHOULD show which tools are exposed, show when a tool is invoked, and ask for confirmation. Clients SHOULD also "show tool inputs to the user before calling the server".
The protocol does not prescribe the UI; that part is host-specific. Your server cannot force a confirmation dialog. What it can do is describe its tools honestly, validate every input, and keep dangerous operations out of the tool list (the L11 lab exposes three tools and deliberately leaves the admin DELETE out).
Annotations such as readOnlyHint or destructiveHint help a host decide how to present a tool, but the spec is explicit: "clients MUST consider tool annotations to be untrusted unless they come from trusted servers." A malicious server can label a destructive tool "read-only". Consent decisions belong to the host and the user.
Worked example: one server, one host
The L11 lab server (mcp_server.py, official Python SDK mcp 2.3.0) wraps a demo inventory API with three tools: search_items, get_item (both annotated read-only) and reserve_stock (changes state). It binds 127.0.0.1 and checks Host and Origin headers.
Start it from the lab-l11 folder:
./run.sh serve # API on 127.0.0.1:8001, MCP endpoint http://127.0.0.1:8000/mcp
Register it in Claude Code (host-specific command, from the Claude Code MCP docs):
claude mcp add --transport http demo-inventory http://127.0.0.1:8000/mcp
claude mcp list
The default scope is local: the server is stored in ~/.claude.json, private to you, for this project only. A project scope writes .mcp.json to the repository so the team shares it; for those servers, Claude Code "prompts for approval in interactive sessions before using project-scoped servers from .mcp.json files". That is a host defending the user against a repository that silently adds a server.
What happens when you start a session:
- Claude Code's client sends requests to
http://127.0.0.1:8000/mcp. Claude Code negotiates 2026-07-28 by default (you can force the old handshake withMCP_PROTOCOL_NEGOTIATION=legacy; the lab server accepts both). - The client calls
tools/listand gets three tool definitions, each with a name, description,inputSchemaand annotations. - The host decides how to present them to the model and the user. In Claude Code, MCP tools appear with names of the form
mcp__<server>__<tool>, for examplemcp__demo-inventory__reserve_stock. - When the model chooses
reserve_stock, Claude Code shows an MCP tool permission prompt (in its default manual permission mode) with the arguments. Only after you approve does the client sendtools/call.
You can pre-approve the read-only tools with Claude Code permission rules, for example an allow rule mcp__demo-inventory__get_item, and leave reserve_stock to prompt. Note that this is a decision you make in the host, based on what you know about the server; the server's read_only_hint=True is only a hint.
Other hosts expose this differently (a settings page, a JSON config file, a per-tool toggle). Read your host's documentation; do not assume Claude Code's behaviour elsewhere.
What the server still owns
Consent in the host does not remove server duties. The tools page says servers MUST validate all tool inputs, implement access controls, rate-limit invocations and sanitise outputs. The lab shows the first two: get_item rejects ../admin through a schema pattern before any HTTP call, and reserve_stock caps quantity at 10. A user can approve a call that is still invalid; the server must refuse it.
Practice task
Connect the lab server to your host and watch the consent flow.
- In
lab-l11, run./run.sh serveand leave it running. - Run
claude mcp add --transport http demo-inventory http://127.0.0.1:8000/mcp, thenclaude mcp list. - Start
claudein any folder and run/mcpto check the server status. - Ask: "Using demo-inventory, show me in-stock electronics." Then ask: "Reserve 2 units of ELC-0001."
- Approve the reservation once. Then ask for 50 units and approve again.
- When you finish, remove the entry with
claude mcp remove demo-inventoryand stop the server with Ctrl+C.
If you use a different host, add the same URL using its documented method and note how it asks for approval. If your host only speaks 2025-11-25, it still works: the lab server answers the legacy handshake on the same endpoint.
Check your result: claude mcp list shows demo-inventory with the URL you gave; /mcp reports it connected; the search returns the two in-stock electronics (ELC-0001 and ELC-0002); a permission prompt naming reserve_stock and its arguments appears before the reservation runs; and the 50-unit request comes back as a tool error from the server (quantity must be 1 to 10) even though you approved it. (If the model declines to send 50 because it read the schema's maximum, that is fine too: the limit is visible to it in inputSchema.)
Check your understanding
-
Your server marks
delete_projectwithdestructiveHint: false. A host trusts it and runs it without asking. Whose fault is the outcome, by the spec? The spec puts the duty on the client: annotations MUST be treated as untrusted unless the server is trusted, and there SHOULD be a human able to deny invocations. The server author was also wrong to mislabel the tool. Annotations are presentation hints, not a security control. -
You connect a "notes" server and a "payments" server to the same host. Can the notes server read the last payment the user made in this conversation? Not through MCP. Each client talks to exactly one server, the full conversation stays with the host, and servers cannot see into other servers. The only way the notes server sees payment data is if the host (or the model, through a tool argument) passes it in. That is why tool inputs should be shown to the user.
-
The user approved
reserve_stockwithquantity: 500. Should the server execute it? No. Host consent says the user wants the call; it does not make the input valid. Servers MUST validate all tool inputs. The lab's schema limitsquantityto 1 to 10 and returnsisError: truewith a short message, which the model can read and correct.
Sources
- Architecture: https://modelcontextprotocol.io/specification/2026-07-28/architecture
- Tools (user interaction model, annotations, security): https://modelcontextprotocol.io/specification/2026-07-28/server/tools
- Streamable HTTP (Origin validation, localhost binding): https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http
- Claude Code MCP docs (adding servers, scopes, project approval, client runtimes): https://code.claude.com/docs/en/mcp
- Claude Code permissions (MCP tool prompts and
mcp__rules): https://code.claude.com/docs/en/permissions - Lab:
lab-l11/README.mdandlab-l11/VERIFY-OUTPUT.txt(verified 2026-11-26)
