CSE Roadmap

Core tier · about 5 hours · 14 parts

Part 5 of 14 · 2 min read

A server with no memory still needs a shopping basket: it gets one as a handle

Think of a coat-check ticket: the person at the counter does not need to remember your face, only that whoever presents this exact ticket gets this exact coat back.

In plain words: when the protocol itself has no session, a server that still needs to keep a shopping basket, a reading list or an open transaction does it differently. It returns an explicit handle from a creation tool, then takes that same handle as an argument on every call afterwards. The state lives in the server, keyed by the handle, rather than in any connection.

A worked example. The example's library server has create_reading_list (which returns a list_id), add_to_list(list_id, isbn) and get_list(list_id). A list created on one connection is successfully read back from an entirely different connection. Nothing about the state depended on which connection asked; only the handle mattered. Asking for an unknown handle, lst_999, returns a tool error with a concrete next step: Unknown or expired list_id 'lst_999'. Create a new one with create_reading_list.

The key lines. From code/mini-mcp/evaluate.py:

# from code/mini-mcp/evaluate.py
def handles() -> dict:
    srv = library()
    c = Client(Connection(srv, ConnState()), mode="modern")
    c.connect()
    lid = c.call_tool("create_reading_list")["structuredContent"]["list_id"]
    c.call_tool("add_to_list", {"list_id": lid, "isbn": "978-1-0001-0004-2"})
    ok = c.call_tool("get_list", {"list_id": lid})["structuredContent"]["titles"]
    c2 = Client(Connection(srv, ConnState()), mode="modern")          # a different connection: the handle still works

Read it as: c and c2 are two separate Client objects wrapping two separate Connection objects, built against the same underlying server. The comment states the point directly: the handle, not the connection, is what carries the state. That is exactly what a stateless protocol requires of anything that needs to persist.

Handle

An explicit identifier (such as a list_id) returned by a creation tool and passed as an ordinary argument on later calls, used to carry state across calls in a protocol that keeps none of its own.

Example: a handle is a name, not a permission by itself. An authenticated server still has to check that this particular caller may use this particular handle, the same row-scope question module 1 raised for a ticket id or a payment id.