sydney reported that the Library wrote Pi's MCP servers to
~/.pi/agent/mcp-adapter.json while Pi 1.0 loads ~/.pi/agent/mcp.json.
Pi's own source (npm @earendil-works/pi-coding-agent):
- 0.99.0 to 1.1.0 have built-in MCP: dist/extensions/mcp/config.js
loadMcpConfig reads <agentDir>/mcp.json (and a trusted project's
.pi/mcp.json). An extension registering /mcp (pi-mcp-adapter) replaces
it; "extensions": ["-builtin:mcp"] turns it off.
- 0.87.1 and earlier have no MCP; pi-mcp-adapter 3.x/4.x reads
mcp-adapter.json only, adapter 5.0.0+ also reads Pi's mcp.json on a Pi
with registerMcpServer.
- core/package-manager.js resolve() loads only settings.json "packages",
"extensions" entries and <agentDir>/extensions/. npm/node_modules, git/
and the global npm root are install places, not loaded on their own.
magpie counted any pi-mcp-adapter folder (npm/node_modules, git, global
root) as loaded, so an adapter left behind with "packages": [] made it
write mcp-adapter.json, which nothing reads, and move mcp.json away
(heliar-k's #1097 is the same case). It also fell back to the adapter file
when Pi's version was unknown.
Now:
- piDetect follows Pi's loader: a package is loaded only when listed (an
object entry with "extensions": [] loads none), "-"/"!" entries turn one
off, and <agentDir>/extensions/<name> loads; the other folders only give
the version.
- An unknown Pi version is taken as one with built-in MCP.
- With no adapter loaded, servers in mcp-adapter.json are moved into
mcp.json (both backed up first); nothing in either file is dropped.
- With adapter 5+ loaded on a Pi with built-in MCP, mcp.json is left
where it is (the adapter reads it) and new servers go to the adapter's
file; with adapter 3/4, or on Pi before 0.99, the old move is kept.
Tests: TestPiMCPUnloadedAdapter, TestPiDetectLoaded and
TestPiMCPAdapter5KeepsPiFile fail on the old pimcp.go and pass now;
older tests that relied on an unlisted adapter now list it.
Run: gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui
./internal/library/; go test -tags nogui ./internal/library/
./internal/agent/ under a temp HOME. Real Pi in a sandbox HOME:
- Pi 1.0.4, reporter's layout (adapter 5.2.0 in npm/node_modules,
"packages": []): `magpie library mcp add` wrote mcp.json and `pi mcp
list` shows both the user's server and the new one connected. The old
binary wrote mcp-adapter.json and Pi listed no servers. `magpie library
sync` with pi off PATH (version unknown) moved that home's
mcp-adapter.json back into mcp.json, with backups, and Pi connected both.
- Pi 1.0.4 with `pi install npm:pi-mcp-adapter@5.2.0`: mcp.json is kept,
the new server goes to mcp-adapter.json, and `pi-mcp-adapter doctor`
connects both.
- Pi 0.87.1: still mcp-adapter.json, as before.
Not run: Windows or WSL Pi, project-level .pi/settings.json, a real
interactive Pi session.
Reported by sydney on Discord; same cause as #1097 (heliar-k).