Model Context Protocol › Trust boundaries

Michael BrenndoerferDecember 1, 20265 min read
Language AI HandbookAll chapters
Part 49 of 67Long-Horizon Agents and Interoperability
Chapter 377Model Context Protocol › Trust boundaries
Reading section 10 of 14 · Trust boundaries · 5 minSection 10 of 14 · 5 min

Section 10 of 14 · 5 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

The protocol describes messages between participants. A host still limits which capabilities enter the model context, and the application or operating system restricts what a server can access. Keep returned content in its proper role. A prompt template, tool description or catalog record is data from a server. It cannot grant additional privileges or approve a subsequent action. Human approval and server authorization can work together without either taking the other's place.

Older deployments may still use roots and sampling. The modern specification deprecates roots and sampling. A roots declaration does not confine a process. Use operating-system or application-level restrictions to enforce access, and pass necessary resource identifiers or tool arguments explicitly. For modern interaction patterns that request user input, the host still decides what information to share.

When debugging an integration, start by distinguishing four questions.

  1. Does the client support the revision the server speaks?
  2. Does the server implement the operation and advertise the applicable capability?
  3. Does the server accept the caller and permit that operation on this data?
  4. Does the host policy allow the model to propose or submit the action?

A schema says what arguments fit, so check the advertised schema against the handler and exercise malformed calls separately from expected business failures. Validate the authorization behavior for a permitted and a denied caller. Restrict returned data to what the task needs. Logs for approvals and decisions can be useful without storing raw sensitive inputs unnecessarily.

Which tools enter the interface

A server can implement several legitimate operations while the task needs one. In the following inventory the server implements lookup, export and a feature unrelated to reading. For the illustrated reader identity, the server lists lookup and export. The reading host offers only lookup in this interface. The offered set is the intersection of the permitted list and the host's task list.

PythonIn [17]
CollapseExpand
implemented_tools = {"lookup", "export", "index_status"}
listed_for_reader = {"lookup", "export"}
reading_interface_policy = {"lookup"}
offered_for_reading = listed_for_reader & reading_interface_policy
assert offered_for_reading == {"lookup"}
tool_stage_counts = {
    "Implemented": len(implemented_tools),
    "Listed to reader": len(listed_for_reader),
    "Offered by host": len(offered_for_reading),
}
VisualizationOut [18]
CollapseExpand
Three horizontal labeled bars show 3 implemented operations, 2 listed operations for the reader, and 1 operation offered by the reading host.
The fictional reading interface exposes one of the two operations listed to the reader. The server still checks permission on the selected call.

The host applies the task filter before creating model-facing tool descriptions. An approval screen can then confirm an individual call. Both restrictions matter if the caller changes or the catalog is updated after discovery. In a multi-user host, a shared connection cache also needs a key compatible with the discovery response's scope, so a cached private view cannot accidentally leak to another identity.

Bounding returned content

A read-only call can still return more data than the model or interface needs. Set a separate response budget for the representation passed into the model context. In this example the application builds a serialized JSON object from one fictional record and sends a small summary when the full object exceeds a local UTF-8 byte cap. The cap is deliberately about application context assembly. Model token and transport limits need their own checks.

PythonIn [19]
CollapseExpand
context_byte_cap = 120
full_context_record = {
    **found["structuredContent"],
    "notes": "Fictional catalog annotation for the seminar reading list. " * 4,
}
compact_context_record = {**found["structuredContent"], "notes_omitted": True}


def encode_context(record):
    return json.dumps(record, ensure_ascii=False, separators=(",", ":")).encode(
        "utf-8"
    )


full_context_bytes = encode_context(full_context_record)
compact_context_bytes = encode_context(compact_context_record)
chosen_context_bytes = full_context_bytes
if len(chosen_context_bytes) > context_byte_cap:
    chosen_context_bytes = compact_context_bytes
if len(chosen_context_bytes) > context_byte_cap:
    chosen_context_bytes = b""
assert len(full_context_bytes) > context_byte_cap >= len(chosen_context_bytes)
assert json.loads(chosen_context_bytes) == compact_context_record
context_sizes = {
    "Complete record": len(full_context_bytes),
    "Submitted summary": len(chosen_context_bytes),
}
print("Context sizes in bytes:", context_sizes)
ConsoleOut [19]
CollapseExpand
Context sizes in bytes: {'Complete record': 295, 'Submitted summary': 69}
VisualizationOut [20]
CollapseExpand
The full record bar extends beyond the 120-byte cap. The submitted summary bar is shorter and fits to the left of that cap. Both bars display byte counts.
The host keeps the entry identifier and title in a compact JSON object when the full fictional catalog record exceeds its context byte cap.

The compact object marks that notes were omitted, which gives the caller enough information to request more detail through the application if it is needed. In this fixture the second check emits empty context when even a summary exceeds the cap. Serializing the summary before checking its size keeps the application from passing an incomplete JSON value. Authorization applies before context assembly, so a smaller representation still needs to come from a record the caller may access.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy