Perch: the per-bot .mcp.json stays in the world root; pi reads it via PI_BOT_MCP_CONFIG - #380
Merged
Merged
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Open-anywhere B2 wrote the bot's closed-world
.mcp.jsoninto the operator's chosen cwd because pi-lab's mcp-client only readcwd/.mcp.json.writeBotMcpreplaces the whole file, so a Perch session opened in a real project directory destroyed that project's own.mcp.jsonon every turn:r4-tehcy/.mcp.jsonlost five servers on 2026-09-12 17:55 andcrow/.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
buildBotWorldwrites the file undersessionDiragain (world.mcpConfigPath) and the bridge setsPI_BOT_MCP_CONFIG=<sessionDir>/.mcp.jsonat 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.jsonis neither rewritten nor inherited by the bot. The name carries thePI_BOT_prefix the bridge already strips fromdef.spawn_env.Tests: B2 flipped to the world-root location plus a regression that a chosen directory's
.mcp.jsonsurvives 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.