Repository navigation
feat(daemon): keep MCP server logins in sync across accounts and live sessions - #143
koushikraj-s wants to merge 23 commits into
Conversation
uwuclxdy
left a comment
There was a problem hiding this comment.
Thanks for splitting this out from #142 and for the live runs. I'd like the shared model as a choice rather than the only behavior: a toggle between keeping MCP logins per account and syncing them across every account and live session the way this PR does. Three asks inline.
b7fea2a to
6befdf6
Compare
|
Thanks, that makes sense. The shared model is now a choice: a |
uwuclxdy
left a comment
There was a problem hiding this comment.
The three asks landed: the sync MCP logins row, the store sync on every platform, and one per-server rule in fresher_token. One gap is left off macOS.
Claude Code's first save into a session's .credentials.json (an MCP sign-in is one) replaces clauth's symlink with a regular file, and from then on the sync neither reads nor writes that file. A login made inside a running Linux session then reaches no other account until that session switches. Writing those live files would race Claude Code's own refresh of the same file, so the sync should read them and keep writing stores only. The row's on-hint and the sync_mcp_logins rows in wiki/Configuration.md and wiki/Security.md then say what a running session gets off macOS.
6befdf6 to
12a20c6
Compare
|
Thanks! Rebased onto current mommy (now without #142's commits). The live-file part is in 040de46: every live session's |
uwuclxdy
left a comment
There was a problem hiding this comment.
I pushed two commits onto the branch: 5fe948a pins the live-file read with a sync pass over a running session's file and the global one, and 926f616 moves the sync MCP logins sentence in wiki/Auto-Switch.md back beside the logins it refers to, since the rebase put the background-session passage between them. This merges after the v0.18.1 tag.
…s member's stamp revokes it
…mcp_logins setting
…ff-macOS sessions
…om the copied-bearer fix
… copied-bearer sentences
5fe948a to
85425ab
Compare
|
Rebased onto the new #146 (1dab4c0) with the history kept: my fifteen commits in their original order, then your two commits (the wiki sentence move and the live-file test) unchanged and under your name. Two small commits on top finish the move. The first makes this branch use the live-session helpers and write witnesses that now live in #146 ( One heads-up if you read it commit by commit: rebasing onto #146 left the earlier commits carrying duplicates of the helpers that moved, and only the last two commits remove them. The branch tip builds and passes the targeted tests and clippy, but commits 2–17 don't build on their own. It also conflicts with current |
…tnesses' refusals
Summary
Stacked on #142. This branch contains #142's 4 commits plus 7 of its own. Please review it after #142; I'll rebase once #142 is merged. Related: #138.
MCP server logins (
mcpOAuth) are stored per Claude account, but MCP servers aren't tied to the Claude account. In a live run, a session was swapped twice in one second (→support, then the chain moved it →koushikraj). It landed on an account whose Atlassian entry held an already-rotated refresh token, so the server lost auth. Logins made inside one session also stay in that session's per-session item, which is the #138 divergence.This PR makes MCP logins shared:
mcpOAuthinto every account'scredentials.json,session-token.jsonandsession-token.static.json, not just the incoming one.expiresAtwins;mcpOAuth, and never creates an item;/mcpsign-in, so the item has no owner row. Such an item is adopted (authorize_live_write) before writing, but only inside a live session's ownruntime-<sid>dir. ForeignCLAUDE_CONFIG_DIRitems stay untouched (Bug: Keychain census deletes per-config-dir login items clauth did not seed (foreign CLAUDE_CONFIG_DIR sessions lose their login, unlogged) #81).sync_mcp_logins = falseturns off both the sync and the fan-out.Design points worth your view:
/mcp→ Disable → Enable. That reconnects with the synced login and needs no new sign-in.Verified live on macOS (Claude Code 2.1.310):
Checklist
sk-ant-*, no~/.claude/~/.clauthcontents)cargo fmt --all -- --check,cargo clippy --locked --all-targets --all-features -- -D warningsandcargo test --locked --all-featurespass locallyLocal run (macOS,
-j 2 --test-threads=2):cargo test --locked --all-features: 8368 passed, 1 failed, 11 ignored.no_item_leg_folds_in_a_carry_or_a_flock, which counts the call sites ofowned_keychain_leg. The sync adds a seventh. That call isn't inside a state-lock hold or a carry, so b7fea2a updates the count, and the test passes on re-run.AI