Skip to content

MCP: cloudpin_switch_plan, the plan a person would run on a mismatch (#112) - #178

Merged
paureis merged 5 commits into
mainfrom
feat/112-switch-plan
Nov 5, 2026
Merged

paureis merged 5 commits into
mainfrom
feat/112-switch-plan

Conversation

@paureis

@paureis paureis commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Closes #112.

cloudpin_switch_plan, the fourth read-only MCP tool. On a mismatch it gives the commands that move each CLI to its pinned account, or what to do by hand, for the user to run. Nothing is run, and no tool switches accounts (#15).

  • Same plan as the CLI: the answer is what cloudpin switch --json prints without --yes, from one shared function, plus a note. A test compares the rest to runSwitch's output.
  • IDs: commands and pinned IDs stay whole, because they come from the pin file and have to run. What the active login reported is shortened in reason, as in cloudpin_doctor. No variable's value is printed: the one line that did (CLOUDSDK_ACTIVE_CONFIG_NAME) now names the variable only, in the terminal too.
  • Who runs it: a CLI's own switch command passes the hook and cloudpin_check by design, so an agent could run these commands unasked. The tool's description, the note, the server's instructions and the plugin skill all say to show the plan and not run it. That is advice, and docs/mcp.md says so; whether the hook should ask on those commands is a separate question for the maintainer.
  • Plugin skill: names when to call cloudpin_doctor and cloudpin_switch_plan.

Also in this PR

  • CHANGELOG lists the cloudpin exec fix from cloudpin switch: plan, confirm once, run, re-check (#14) #102 under Security. It was over its size limit, so 1.0.0 to 1.1.2 move to docs/changelog-1.0-1.1.md, as 0.x did.
  • THREAT_MODEL names two limits: an agent can run a CLI's own switch command, and Cursor's hook matcher is a text filter.

Evidence

  • test/mcp-switch-plan.test.ts, 29 tests, seen failing first. The nothing-runs test has a control: switch --yes does run the switch commands through the same fake CLIs.
  • npm run typecheck exit 0; npx vitest run passes (3007 before the docs commit).
  • Five mutations all fail tests: running the plan, an override's value in a line, login values unshortened, commands shortened, shortening inside a pinned ID.
  • Real accounts, read-only, through the built server over stdio: the active login pinned gives match with no commands; a made-up pin gives mismatch with manual lines naming that pin; ran empty, after null, accounts unchanged.

Not tested

A real run line on a real account (no second login here); it is covered with fake CLIs.

🤖 Generated with Claude Code

paureis and others added 5 commits November 4, 2026 18:54
…112)

A fourth read-only tool: what `cloudpin switch --json` prints without --yes, from
planSwitch, plus a note saying who the plan is for. Nothing is run.

switch.ts and the tool build the answer with one function, so the shapes can't drift.
Commands and pinned IDs stay whole, since they come from the pin file and have to run.
What the active login said is shortened in the text, as in cloudpin_doctor, and only
as a whole value, so a pinned ID that contains it stays runnable.

A CLI's own switch command passes the hook and cloudpin_check by design, so the
description, the note and the server's instructions all say to show a plan to the
user and never run it, including the lines that say "yourself".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
README, docs/mcp.md, docs/agent-sdk.md, SECURITY.md, the CLI help and the Cursor demo's
setup list name cloudpin_switch_plan or the new count (the demo still said two).
docs/mcp.md says what a plan holds and that "show it, don't run it" is advice. README
stays at its size. CHANGELOG's #112 line now covers both tools, shorter than it was, and
ROADMAP marks #112 done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…112)

On a mismatch the agent shows the user the plan and never runs it. When cloudpin seems
not to be guarding, it calls cloudpin_doctor and passes on what it finds and the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The one manual line that printed a variable's value, for a configuration name cloudpin
won't pass on. A plan now reaches an agent too, so the line names the variable only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…1.1 move out

CHANGELOG was over its size limit, so 1.0.0 to 1.1.2 move to
docs/changelog-1.0-1.1.md, as 0.x did. THREAT_MODEL names what the switch work
found: an agent can run a CLI's own switch command, and Cursor's matcher is a
text filter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paureis
paureis merged commit fa0f307 into main Nov 5, 2026
4 checks passed
@paureis
paureis deleted the feat/112-switch-plan branch November 5, 2026 00:02
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.

MCP: cloudpin_switch_plan and cloudpin_doctor tools (read-only)

1 participant