Documents / Issues / issue-29f4b96efdaa
An MCP client cannot tell which store it is writing to
docir mcp serve names no store in its instructions, store_status or write results, so in a repository with no .docir/ a client writes the project's documents into the global ~/.docir unwarned.
Class: misleading · Severity: major
Flow: arch-90c90751344f · Step: a client agent's first write over docir mcp serve
Finding¶
Nothing an MCP client saw named the store the server serves. In a git repository with no
.docir/, every write went to the global ~/.docir, which the CLI warns about on every
command and the MCP server never mentioned. A client agent following the instructions wrote
the project's decisions where the project's team and git history never see them.
Measured¶
Acceptance testing of 0.30.4 over docir mcp serve --transport http, twice in a git
repository without a store and twice outside one:
- the handshake
instructionswere byte-identical for a project store and the global store; docir_store_statusreturned counts and versions, no path and no origin;docir_addreturned a store-relativepathandis_error: false, nostore;- only
docir_doctorsaid it (home_origin: global, findingglobal-fallback), and its description says to read it when an answer looks wrong — which a misplaced write never does.
The fix for the CLI (An uninitialised repository silently falls back to the global `~/.docir` store) was a store field on the write payload and a
stderr warning. Both were added in the CLI's emit layer, after the dispatcher answered, so
the MCP transport — a client of the same dispatcher (MCP as a second transport over the dispatcher) — got neither, and
an MCP client reads no stderr.
Resolution¶
The facts belong to the process that resolved the home, which is the MCP server, not the
dispatcher behind it: with the daemon, the dispatcher runs in a process spawned with
DOCIR_HOME set, so its own origin is always env. So ServedStore in
entry_points/mcp/server.py is read off the server's Settings once and added to results
after the one Request each tool makes:
- the instructions open by naming the store and its
home_origin(flag,env,project,global— the conceptconfig/settings.pydefines anddocir doctorreports); docir_store_statuscarrieshomeandhome_origin;- every write tool's result carries
store, filled the way the CLI'swith_storefills it.
In the global-fallback case the CLI's own sentence, now Settings.global_fallback_warning
and printed by the CLI through the same method, leads the instructions and rides on
docir_store_status and every write result as warning. The write is not an error: the
global store is a legitimate default. tests/entry_points/test_mcp_names_its_store.py
resolves each store from a real working directory, and all seven of its tests fail on 0.30.4.