Skip to content

Perch: the per-bot .mcp.json stays in the world root; pi reads it via PI_BOT_MCP_CONFIG - #380

Merged
kh0pper merged 1 commit into
mainfrom
fix/perch-mcp-config-world-root
Sep 14, 2026
Merged

kh0pper merged 1 commit into
mainfrom
fix/perch-mcp-config-world-root

Conversation

@kh0pper

@kh0pper kh0pper commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Open-anywhere B2 wrote the bot's closed-world .mcp.json into the operator's chosen cwd because pi-lab's mcp-client only read cwd/.mcp.json. writeBotMcp replaces the whole file, so a Perch session opened in a real project directory destroyed that project's own .mcp.json on every turn: r4-tehcy/.mcp.json lost five servers on 2026-09-12 17:55 and crow/.mcp.json (the generated core config) was replaced on 2026-09-13 13:56. The B2 comment's "additive merge" claim was about pi's runtime layering, not the file.

Now buildBotWorld writes the file under sessionDir again (world.mcpConfigPath) and the bridge sets PI_BOT_MCP_CONFIG=<sessionDir>/.mcp.json at spawn. pi-lab (feat/bot-mcp-config-env, merged) loads the global file plus that file only when the variable is set, so a chosen directory is read-only to the MCP layer: its .mcp.json is neither rewritten nor inherited by the bot. The name carries the PI_BOT_ prefix the bridge already strips from def.spawn_env.

Tests: B2 flipped to the world-root location plus a regression that a chosen directory's .mcp.json survives byte-identical; pirpc seams (g) pins the env var against a differing cwd and a def override; the four spawn-surface goldens gain the one new key.

Deploy order: pi-lab main first (additive, already merged and pulled on crow), then this.

… PI_BOT_MCP_CONFIG

Open-anywhere B2 wrote the bot's closed-world .mcp.json into the operator's
chosen cwd because pi-lab's mcp-client only read cwd/.mcp.json. writeBotMcp
replaces the whole file, so a Perch session opened in a real project directory
destroyed that project's own .mcp.json on every turn: r4-tehcy/.mcp.json lost
five servers on 2026-09-12 17:55 and crow/.mcp.json (the generated core
config) was replaced on 2026-09-13 13:56. The B2 comment's 'additive merge'
claim was about pi's runtime layering, not the file.

Now buildBotWorld writes the file under sessionDir again (world.mcpConfigPath)
and the bridge sets PI_BOT_MCP_CONFIG=<sessionDir>/.mcp.json at spawn. pi-lab
(commit 4887d44, feat/bot-mcp-config-env) loads the global file plus that file
only when the variable is set, so a chosen directory is read-only to the MCP
layer: its .mcp.json is neither rewritten nor inherited by the bot. The name
carries the PI_BOT_ prefix the bridge already strips from def.spawn_env.

Tests: B2 flipped to the world-root location plus a regression that a chosen
directory's .mcp.json survives byte-identical; pirpc seams (g) pins the env var
against a differing cwd and a def override; the four spawn-surface goldens gain
the one new key. Deploy order: pi-lab main first (additive), then crow.
@kh0pper
kh0pper merged commit 07507bd into main Sep 14, 2026
3 checks passed
@kh0pper
kh0pper deleted the fix/perch-mcp-config-world-root branch September 14, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant