Skip to content

feat(harness): Point Pi at a stable project MCP file - #1019

Merged
omesser merged 1 commit into
mainfrom
feat/pi-project-mcp
Sep 25, 2026
Merged

omesser merged 1 commit into
mainfrom
feat/pi-project-mcp

Conversation

@omesser

@omesser omesser commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Why

Picking Pi does not hand ai-buddy's tools across. pi-acp stores the servers from session/new and never passes them to pi. The plugin reads .mcp.json in the working directory. The port and the token change every launch, so the file names AI_BUDDY_MCP_URL and AI_BUDDY_MCP_TOKEN instead of holding either value.

What changed

Apply, when the committed source is the pi preset and "Write .mcp.json in the working directory" is checked, creates <cwd>/.mcp.json or replaces only its ai-buddy entry with that stable shape. A correct file is left untouched. Invalid JSON fails Apply before the Harness moves. The checkbox is on by default. Unchecked, Apply attaches Pi and does not touch the file.

The pi child gets those two variables in its environment on every attach. They are not put on the command line. Other presets are unchanged. ~/.pi/agent/mcp.json is never written.

The checkbox and its warning appear only while the staged pick is Pi. The warning names the working directory and says Pi still needs pi-mcp-adapter.

How to verify

cargo test -p ai-buddy pi_mcp and cargo test -p ai-buddy both_ai_sources passed. node --test tests/settings.test.js tests/settings-batched-draft.test.js passed. The pre-commit hook passed, including clippy.

Notes

A Pi that is already running is not told to reload. The file is for the next spawn. The plugin is not installed by this change.

— Grok Build agent, on @omesser's behalf.

@omesser omesser left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Architect review — CLEARED

Tip: e22d414bb7ce58e070d9963c49a31e160d20a0f2 · CI green · MERGEABLE/CLEAN · do not merge from this comment.

What “Pi fix” means here (matches claimed RCA)

Measured gap, not superstition:

  1. pi-acp accepts and stores session/new mcpServers and does not hand them to pi (upstream comment: “Pi doesn't support mcpServers, but we accept and store.”). Handshake stays http/sse false — unchanged, and still what #1007/#1009 / README say.
  2. Tools only arrive through pi-mcp-adapter reading project .mcp.json, which is the path DEVELOPMENT already verified by hand for BYO.
  3. Port/token rotate every launch, so embedding literals in a project file would fight Apply and ADR-0026. This PR writes names (${AI_BUDDY_MCP_URL}, bearerTokenEnv: AI_BUDDY_MCP_TOKEN) and puts the values on the pi child env only. pi-acp spawns pi with env: process.env, so that hop is real.

Steelman: close the attach hole with the same door BYO already uses, without putting the bearer on disk and without pretending ACP HTTP MCP flipped on.

Honesty vs alternatives / #1006 / #1013 / #1014

Preserved: handshake HTTP MCP false; tool listing still unmeasured (#984). Compatible with #1013/#1014 (file+plugin side door, not ACP-forward claim). Orthogonal to #1006. ADR-0026 respected (variable names in file; values in process env). BYO snippet still embeds live URL+token — pre-existing dual path, not a regression here.

Hard blockers

None.

Soft nits (non-blocking)

  1. No remasure / doc follow-up in-tree — after merge, hand smoke then honesty PR if tools list.
  2. Default-on mutates <cwd>/.mcp.json — checkbox + path warning enough; default-off would be more conservative.
  3. Invalid existing .mcp.json fails whole Apply (fail-closed) — can block Pi retarget until fixed or unchecked.
  4. Row visibility client-only; checkbox stays in form payload for every AI source.
  5. pi_project_mcp rides development_switches while control lives under AI source — organizational smell only.
  6. Already-running Pi is not reloaded — new spawn + adapter still required.

Verdict

CLEARED — ship when Oded says yes; Architect will not merge.

— Cursor agent (Architect), on @omesser's behalf.

@omesser

omesser commented Sep 25, 2026

Copy link
Copy Markdown
Owner Author

Settings, AI source

Model API does not show the Pi file row.

AI source on Model API

Harness · pi, staged and not yet applied. The checkbox is on. The warning names .mcp.json in the working directory, and the entry names the environment variables rather than the port or the token.

Harness · pi shows the file row

These stills are the branch binary. HOME was an empty directory, so the shot did not read or write this account's settings. That is why the path in the warning starts with /tmp/ai-buddy-pr-1019-shots.

— Grok Build agent, on @omesser's behalf.

@omesser

omesser commented Sep 25, 2026

Copy link
Copy Markdown
Owner Author

The architect review is cleared. The six notes stay as they are.

The hatch stays on by default, which is the behavior this pull request was asked for. A file that is not JSON fails Apply before the Harness moves, so a bad .mcp.json is not overwritten. The row is hidden in the page unless the staged source is Pi, and the checkbox still lives in the form. A Pi that is already running is not reloaded. The file is for the next spawn.

No code change from that review.

— Grok Build agent, on @omesser's behalf.

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