ADR 0020doc/{zh,en}/adr/0020-local-mcp-sessions.md
ADR 0020: Local MCP Clients Use Orquelo's Tools as One Configured Person
Status: accepted by the owner, 2026-12-01 (P08 CU18: "按本地运行免登陆做", run locally without a login).
Status: accepted by the owner, 2026-12-01 (P08 CU18: "按本地运行免登陆做", run locally without a login).
Context
Coding agents a person runs in a terminal (Claude Code, Codex, Cursor) should use the tools Orquelo grants that person, such as computer, the browser and Memory, under the same leases, approvals, app tiers, on-screen presence, Stop and audit as the bot (computer use research, section 5.8). Those all belong to a run with a principal. Orquelo has no CLI login yet (I06), and nothing lets a process on the machine reach a running Host.
Decision
- Trust the local OS user. The Host listens on a loopback port and writes its address and a random token to
local-mcp.jsonin its state directory, readable only by the user it runs as. Whoever can read that file can already read the Host's configuration, secrets and database, so the token grants nothing new. It is removed when the Host stops; a new one is made at every start. - One configured person. The top-level
local_mcp: {connection, user}, the shape of anadminsentry, names the person local MCP clients act as; an unknown connection is refused at load. Without it the Host refuses sessions with a clear error. - A session is a run.
orquelo mcp serve [-c CONFIG], started by the MCP client over stdio, sends the token; the Host creates a run of that person on the pseudo-connectionlocal-mcp(no transport, presentation or delivery, likeschedule), with the runtime of the person's connection, so the tools are that runtime's (SharedTools). The run serves the runtime bridge (pkg/runtimebridge, one client) instead of calling the runtime, and ends when the client leaves. - Questions go to the person. A session run's questions, approvals and notices without another target go to the person's direct chat on the
local_mcpconnection, as a scheduled run's go to its owner. Its final result is delivered nowhere: the client saw every result. - Remote clients with a person's API key. With the top-level
mcp: {listen, public_url}, the Host serves MCP over HTTP at/mcp(Streamable HTTP, JSON answers, no streams), off unless set; put it behind HTTPS. A client sendsAuthorization: Bearer <key>;initializeopens a session run of the key's person, the same run as a local session, named inMcp-Session-Id;DELETEor 30 idle minutes end it. Every request checks its key again, so a revoked key gets 401 at once and its session ends, releasing its leases. Keys (orq_and 32 random characters) belong to one person and are kept only as their SHA-256 inmcp_keys(ownerinternal/host/mcpkeys): the operator manages them withorquelo mcp key create|list|revoke --account CONNECTION:USER NAME, and a person in their own direct chat with/mcp key, which shows a new key there once (so that chat and its delivery record hold it in clear). - OAuth for clients that sign in. With
mcp.public_urlset, the Host is the OAuth 2.1 authorization server of/mcp(MCP authorization spec,internal/host/mcpauth): protected-resource and authorization-server metadata under/.well-known, dynamic client registration (/oauth/register, public clients),/oauth/authorizewith PKCE S256 only,/oauth/tokenforauthorization_codeandrefresh_token. The sign-in page asks for the person's account (connection and user id) and shows a one-time code (10 minutes, single use); the person sends/mcp approve CODEin a direct chat from that account or one linked to it, and the page goes on to the client. The grant acts as that account; access tokens last 1 h, refresh tokens rotate on each use, all kept as SHA-256./mcp key listshows OAuth clients too, and/mcp key revoke NAMEends one at once: the next/mcprequest gets 401 and its refresh tokeninvalid_grant. A 401 names the resource metadata inWWW-Authenticate. Withoutpublic_url,/mcptakes API keys only.
Consequences
- ◆No login on the Host's machine; another machine connects only over HTTP with a person's key.
- ◆On a machine several people share as one OS user, they all act as the configured person;
local_mcpis meant for a person's own machine. - ◆Kernel changes: one config field, a loopback listener, the
local-mcppseudo-connection in run execution, target resolution and the run's end.pkg/runtimebridgegains a one-client mode.