Serving: keys, rooms and a log
How a local service lets agents read without letting them roam: a token per client, scopes as rooms, approval one request at a time, tools an agent can run unasked, and a record of everything that was given.
- Offer a local store to agents through a standard protocol, on one machine only.
- Give each agent its own key and limit what the key opens.
- Make every request pass the same five steps in the same order.
- Name and label tools so that a careful agent will run them without asking its owner each time.
6.1The problem: one store, several readers, different trust
A model of a person is useful only if agents can read it, and dangerous if any program can. A single shared key gives every reader everything. The arrangement here is that of a house: each visitor has a key of their own, a key opens some rooms and not others, and some visitors must knock every time.
6.2The protocol, bought
- Model Context Protocol (MCP)
- An open protocol by which a program offers tools to an agent: a list of tools, each with a name, a description and the inputs it takes, and a way to call one. An agent that speaks it can use a server it has never seen.
Athena is such a server, over HTTP, bound to the address 127.0.0.1: reachable from this machine and from nowhere else. That address is a constant in the source, not a setting. The protocol, the transport and the check of the bearer token are the official SDK's; what was written here is the list of tools and what stands behind them.
6.3Keys and rooms
| Scope | Opens |
|---|---|
now | the last three hours: programs, windows, sites, files |
history | the same, further back, and search over it |
profile | the kept model: projects, people, the owner's own notes, what a model inferred |
writing | passages the owner typed |
screen_text | text that was on the owner's screen |
A client is a name, a token and a list of scopes. The token is shown once, when it is granted; only its hash is stored, so reading the settings file does not yield a working key. Revoking a client stops its token at the next request.
A client also has one of two modes. In browse it may call anything its scopes allow. In ask, every single request waits for the owner to approve it. An approval is for that exact request, is used up by one answer, and lapses in ten minutes; asking again does not get round it.
6.4The one door
Every call, from any client, goes through one function, in this order:
- Token. No valid token: the server answers 401 and nothing else happens.
- Approval, for a client in ask mode. Until the owner says yes, the client learns only that it must wait.
- Scope. A tool the client's scopes do not cover returns a refusal that names the missing scope, and nothing more.
- The answer, in its envelope: a fixed notice, the time, whether recording is paused, and the items with their provenance (Chapter 4).
- The log. One line per request, allowed or refused: who, which tool, with what inputs, how many items of each kind were given, their record ids, and how many pieces were withheld.
The log holds record ids and counts, not the text served. It is a record of what was given without being a second copy of it.
6.5Tools an agent will run unasked
A careful agent does not run an unknown tool without asking its owner. The assistant this service was built beside sorts a server's tools by a simple rule: a tool runs unasked only if the server labels it read-only and its name begins with a reading word such as get, search or lookup. Anything else is put to the owner each time.
So all the tools here are labelled read-only (seven when this was checked; two for mail and calendar were added later, Chapter 8) and named accordingly: whoami, get_recent_activity, search_activity, lookup_person_or_project, get_writing_samples, get_profile, get_day_summary. Run through that assistant's own connection code, all seven were sorted as "runs at once", and it read the last hour. Verified, 23 November 2026.
READ = dict(read_only_hint=True, destructive_hint=False, idempotent_hint=True, open_world_hint=False)
@mcp.tool(title="What the owner was just doing", annotations=ToolAnnotations(title="What the owner was just doing", **READ),
description="What the owner has been working on in the last `minutes` (default 60): ...")
def get_recent_activity(minutes: int = 60) -> str:
return run("get_recent_activity", minutes=minutes)
The descriptions are written once, by hand. Nothing captured ever appears in one, because an agent reads a tool's description as guidance.
That assistant connects to new servers from its chat, and refuses any address that is not https or does not lead to a public server. Both refusals are right for a stranger's server and both exclude a service on the same machine. Connecting needed one entry in the assistant's own list of known services, marked as local so that it is known only to the person whose folder holds a token for it. A local service and a careful client have to be introduced by their owner; neither should find the other by itself.
- Serve on this machine only, through an open protocol, with the transport and token check bought.
- One key per client, hashed; scopes as rooms; an ask mode for visitors.
- Token, approval, scope, answer, log: one function, one order.
- Label tools read-only and name them as reads, and write their descriptions by hand.
- The log keeps the inputs of every request. Give a case in which the inputs themselves are private. What would you keep in their place?
- An approval is tied to the exact inputs of a request. Why not approve "this client, for ten minutes"?
- Another program on the same machine can reach the server's port. What stops it reading the model? What does not?
- Extend the code: add a scope that allows search but only over the last day. Where is the one place it must be enforced?