Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

library: an MCP server can be kept to this computer, never synced

yetone405425186593
diff --git a/docs/subsystems/library.md b/docs/subsystems/library.md
index 5dcae54d9..c8cbd005f 100644
--- a/docs/subsystems/library.md
+++ b/docs/subsystems/library.md
@@ -64,6 +64,7 @@ agents RTK, a CLI that cuts shell output down before the model reads it.
- magpie's own MCP server (`magpie-image`, and any `mcp …` run by a program named magpie) runs this computer's magpie (#1439). `InstallServer` gives it magpie by full path (`update.Program`: the AppImage, not its mount; Homebrew's opt link, not the Cellar), and that path is right only on this computer. When the library is read, and after every change, `heal` points such a server whose program isn't on this computer (another system's path, a magpie moved out of Downloads, a bare `magpie`) at this magpie, so the agents and `CheckServers` get it; a magpie program that is here (another build) and a server run by any other program stay as they are. A carried library (`Collect`, for a backup or a WebDAV or S3 sync) names it as plain `magpie`, so two computers carry the same bundle and a sync doesn't write one's path over the other's; `Put` then reads it as that computer's magpie. [`self_here.go`](../../internal/library/self_here.go)
- A carried library (`Collect`) has every file of each skill, its templates and other binaries included, up to `maxCarried` (16 MiB) a file and `maxCarriedAll` (32 MiB) in all, chosen smallest first across the skills (`readSkills`), so every skill's text goes before any big file. The total keeps a sealed backup under the 64 MiB a sync reads: the files are base64 twice in it. What is left out is named in `Left`, and `Put` keeps this computer's copy of such a file in the skill it puts (`keepLeft`). [`carry.go`](../../internal/library/carry.go)
- A skill can be turned off on this computer alone (`OffHere`, `SkillHere`; the row's power button, `magpie library skill off-here <name>` and `on-here`; hanslin1666 on Discord). No agent here gets it, whatever its `Agents` say (`gives`, which every reader of `Agents` for giving goes through: `syncSkills`, `desktop_skills.go`, `skill_changed.go`, `skill_edits.go`, `behind`, `Targets`). `Agents` stays what a sync carries, and the page leaves its chips as they are, faded. `Collect` never carries `OffHere`, so turning it off changes no part a sync uploads, and `Put` keeps this computer's `OffHere` for a skill it puts, so a sync from a computer that has it on, or gives it to more agents, never turns it on here. A library.json from before has no `offHere` and every skill stays on. Not covered: a project's skills; a library skill kept in `~/.agents/skills`, which agents read in place, until it is handed over (below); and a skill another computer removes, which takes the flag with it. [`skills.go`](../../internal/library/skills.go), [`carry.go`](../../internal/library/carry.go)
+- An MCP server can be kept to this computer (`Server.Local`; the editor's "This computer only" switch, `magpie library mcp add --local`, `magpie library mcp local <name> on|off`; huhuy72219405 on X). `Collect` never carries it (`carriedServers`), so a sync or a backup file never takes it to another computer, and turning a shared server local takes it out of what is carried: the other computers drop it at their next sync. `Put` (sync, join, Restore, Undo, a backup file) keeps every local server here, with its agents, and clears `Local` on what comes in (`putServers`). Another computer's server by the name of a local one doesn't take its place: it goes to `Library.Away`, given to no agent, not in the hub, not checked, and carried on as it came, so a push from here never takes it from the computers that have it. `settleAway` runs on every change: while the name is local here the away copy stays; once no server of that name is left here (removed or renamed) it comes in as a sync would bring it; once a shared server has the name (local turned off) this computer's is the one carried. The hub serves local servers like any other, since it runs on this computer. Subagents aren't carried, so one that names a local server keeps it here. The TUI keeps the flag on edit and marks the row. (`TestLocalServerNotCarried`, `TestPutKeepsLocalServer`, `TestPutSameNameAsLocal`, `TestRestoreKeepsLocalServer`, `TestLocalServerThroughSync`, `mcp-local-server.test.cjs`) [`mcp_local.go`](../../internal/library/mcp_local.go), [`carry.go`](../../internal/library/carry.go)
- A skill kept in `~/.agents/skills` is handed over to the library on the user's click (`HandOverSkills`, `POST /api/library/skills/hand-over` with `names`; the row's Manage in magpie in its source line, Manage {n} in magpie in the skills' heading, each asking first; `magpie library skill hand-over <name…>|--all`; tnt1223 on Discord). "Kept there" is `sharedEntry`: the entry in that folder that is the library skill's own folder, by its name or, for a library link into it under another folder's name, by that folder's (`SkillView.Shared`; `SharedElsewhere` when the entry only links to a folder kept elsewhere). Every reader of `sharedHas`/`sharedEntry` follows: `Always`, `syncSkills`' `inShared`, and the shared folder's own target (Goose, Kimi Code, Cindy), which is given no second link beside such an entry (`TestSharedUnderAnotherName`). Handed over, a folder in `~/.agents/skills` moves into the library's skills folder (`moveIn`: renamed, or copied, read back the same with `sameTree` and only then set aside with the backups; a failure leaves it where it was and the library's link as it was, `TestHandOverFailureKeepsOriginal`), and an entry that only links elsewhere is taken away while the library links past it to that folder. The user's own links to it in agents' folders, which would point at nothing, go too. Every agent here that read it (`readsSharedHere`, and the agent of each such link) is ticked, so each keeps it, now from the library, till it is unticked or turned off here. A skill found there and not in the library yet is brought in first. One that can't be handed over is left as it was, in `Result.Unmoved`, and the others are handed over all the same. `HandBackSkill` (`magpie library skill hand-back <name>`, CLI only; the sheet names it) moves the folder back and links the library to it, its ticks as they are. Not covered: another computer whose skill is still in its own `~/.agents/skills` gets the library's copy from a sync beside its own, until it is handed over there too; and the skills CLI's lock (`npx skills update`) may put the entry back (`TestHandOverSharedFolder`, `TestHandOverSharedLink`, `TestHandOverFound`, `TestHandOverWithGoose`, `TestLibrarySkillHandOver`, `skill-handover.test.cjs`). [`skill_handover.go`](../../internal/library/skill_handover.go)
- WorkBuddy's servers go in `$WORKBUDDY_CONFIG_DIR/mcp.json` (default `~/.workbuddy`; WorkBuddy AI, the international build, keeps its own in `~/.workbuddy-ai`, #1494), and CodeBuddy Code's go in the first of `.mcp.json`, `mcp.json` and `~/.codebuddy.json` that exists, as `resolveMcpFilePath` reads them (#1266). WorkBuddy connects a server only after the user has switched it on once in its own MCP settings. It keeps that approval in `mcp-approvals.json`, keyed by the command, args and env names or the URL's origin, so changing those asks again. magpie never writes the approval, and the servers page says so, by the build's name, when a server is given to WorkBuddy or WorkBuddy AI.
- Alma's servers go in `~/.config/alma/mcp.json` on every system (its home, not its data folder), as its own MCP settings write them: `command`/`args`/`env`, or `url`/`headers` with `transport: "sse"` only for SSE (#1292). Alma reads the file as it starts and when its MCP settings refresh, so a server given to it while it runs reaches it after one of those.
@@ -83,9 +84,10 @@ agents RTK, a CLI that cuts shell output down before the model reads it.
```sh
go test -tags nogui ./internal/library -run 'TestGit|TestInstallFromGitRepo|TestReadLooksAtEachFolderOnce|TestLinkChangedBetweenVisitsShows|TestUnreadablePartIsLookedAtAgain|TestCheckSkillsFindsNewOnes|TestNewBase|TestUpdateKeeps|TestCheckDue|TestCheckSkillsMarksItDone|TestTargets|TestWSLPiMCP|TestWSLMCPSiblings|TestServer|TestHub|TestImportServer|TestCheck|TestInstructions|TestInstructionsSetLinkedToAgentsFile|TestInstructionSets|TestTakesAlma|TestAlma|TestLinkedSet|TestLinkRefused|TestSkill|TestRemoveFoundSkill|TestInstallSet|TestInstallLists|TestEverySkillAgents|TestEveryServerAgents|TestSomeServersAgents|TestRemoveServers|TestRTK|TestEnvRefs|TestDshRefRoundTrip|TestDshImportKeepsJS|TestAgentMCPFiles|TestCodeBuddyMCPFile|TestZedMCP|TestOwnServerFromElsewhereRunsThisMagpie|TestUsersOwnServerStaysAsItIs|TestCarriedOwnServerIsEachComputersMagpie|TestCarry|TestPageReadDoesntReadUnchangedSkillsAgain|TestJustWrittenSkillIsReadAgain|TestUnreadableSkillIsntRememberedAsDifferent|TestGlanceLeavesOutTheAgentsSkills|TestPluginAgent|TestPluginMCPFormatsAreWritten|TestToolsOff|TestOffList|TestHooks|TestSubagent|TestCheckRenewsMagpiesSignIn|TestCheckWSLOnlyServerInItsDistro|TestCheckWindowsServerHere|TestCheckMixedServerEachSide|TestCheckSaysSignInRanOut|TestCheckNamesAgentsSignedInThemselves|TestSignInAsTheUsersOwnApp|TestOAuthAppChecked|TestOAuthAppSecretCarried|TestGoneAgentListedToTakeOut|TestUpdateFindsSkillsRemovedUpstream|TestGoneFromNeedsTheSourceRead'
-go test -tags nogui ./internal/library -run 'TestSkillOffHere'
+go test -tags nogui ./internal/library -run 'TestSkillOffHere|TestLocalServerNotCarried|TestPutKeepsLocalServer|TestPutSameNameAsLocal'
+go test -tags nogui ./internal/backup -run 'TestRestoreKeepsLocalServer'
go test -tags nogui ./internal/library -run 'TestHandOver|TestSharedUnderAnotherName|TestSharedAgentsSkills'
-go test -tags nogui ./internal/davsync -run 'TestSkillOffHereThroughSync'
+go test -tags nogui ./internal/davsync -run 'TestSkillOffHereThroughSync|TestLocalServerThroughSync'
go test -tags nogui ./internal/cli -run 'TestLibrarySkillRm|TestLibrarySkillHandOver'
go test -race ./internal/mcpauth
go test -tags nogui ./internal/library
@@ -93,7 +95,7 @@ go test -tags nogui ./internal/library -run 'TestWSLStopped'
go test -tags nogui ./internal/library -run 'TestRTKWSL'
node --test internal/gui/tests/library-rtk-wsl.test.cjs
node --test internal/gui/tests/library-wsl-asleep.test.cjs
-node --test internal/gui/tests/skill-off-here.test.cjs internal/gui/tests/skill-handover.test.cjs
+node --test internal/gui/tests/skill-off-here.test.cjs internal/gui/tests/mcp-local-server.test.cjs internal/gui/tests/skill-handover.test.cjs
node --test internal/gui/tests/library-items.test.cjs internal/gui/tests/library-mcp-hub.test.cjs internal/gui/tests/library-alma-profile.test.cjs internal/gui/tests/library-rtk-gain.test.cjs internal/gui/tests/library-rtk-nohook.test.cjs internal/gui/tests/library-servers-bulk.test.cjs internal/gui/tests/library-pick-remove.test.cjs internal/gui/tests/library-env-refs.test.cjs internal/gui/tests/library-zed-mcp.test.cjs internal/gui/tests/library-workbuddy-trust.test.cjs internal/gui/tests/skill-new-in-repo.test.cjs internal/gui/tests/skill-update-edited.test.cjs internal/gui/tests/skill-gone.test.cjs internal/gui/tests/skill-git-source.test.cjs internal/gui/tests/remove-found-skill.test.cjs internal/gui/tests/found-skill-pick-remove.test.cjs internal/gui/tests/library-loading.test.cjs internal/gui/tests/library-mcp-tools.test.cjs internal/gui/tests/library-mcp-tool-switch.test.cjs internal/gui/tests/library-hooks.test.cjs internal/gui/tests/library-subagents.test.cjs internal/gui/tests/library-mcp-health.test.cjs internal/gui/tests/library-mcp-health-wsl.test.cjs internal/gui/tests/mcp-signin-health.test.cjs internal/gui/tests/mcp-signin.test.cjs internal/gui/tests/mcp-editor-cancel.test.cjs internal/gui/tests/mcp-oauth-app.test.cjs internal/gui/tests/library-ime-scroll.test.cjs
```
diff --git a/docs/subsystems/sync-backup.md b/docs/subsystems/sync-backup.md
index 14d73499b..cf08c849f 100644
--- a/docs/subsystems/sync-backup.md
+++ b/docs/subsystems/sync-backup.md
@@ -188,6 +188,14 @@ it, and putting another computer's library keeps it, so the others keep the
skill on and a sync from them doesn't turn it on here
(`TestSkillOffHereThroughSync`, two computers through the fake S3).
+An MCP server kept to one computer (`Server.Local`, see
+[library](library.md)) is never in the library part, so it never reaches
+another computer by sync or backup file. Putting another computer's library
+keeps it, and a server of the same name from there goes to `Library.Away`,
+given to no agent here and carried on unchanged, so neither computer's sync
+removes or replaces the other's (`TestLocalServerThroughSync`, two computers
+through the fake S3; `TestRestoreKeepsLocalServer` for a backup file).
+
## Verification
```sh
diff --git a/internal/backup/local_server_test.go b/internal/backup/local_server_test.go
new file mode 100644
index 000000000..052555811
--- /dev/null
+++ b/internal/backup/local_server_test.go
@@ -0,0 +1,81 @@
+package backup
+
+import (
+ "testing"
+
+ "github.com/yetone/magpie/internal/library"
+)
+
+func libServer(t *testing.T, name string) *library.Server {
+ t.Helper()
+ v, err := library.Read(nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, s := range v.Servers {
+ if s.Name == name {
+ return s.Server
+ }
+ }
+ return nil
+}
+
+// A server kept to this computer (huhuy72219405 on X) is in no backup
+// file, and restoring one — made before it was added, or on another
+// computer with a server by its name — keeps it as it is here.
+func TestRestoreKeepsLocalServer(t *testing.T) {
+ home(t)
+ gh := library.Server{Name: "gh", Transport: "stdio", Command: "gh-mcp", Agents: []string{}}
+ if _, err := library.SaveServer("", gh); err != nil {
+ t.Fatal(err)
+ }
+ // the other computer's db, by the name of this one's own
+ if _, err := library.SaveServer("", library.Server{Name: "db", Transport: "stdio", Command: "their-db", Agents: []string{}}); err != nil {
+ t.Fatal(err)
+ }
+ b, err := Collect(true, "test")
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, _ := Seal(b, "pw")
+
+ home(t) // this computer, with a db of its own
+ if _, err := library.SaveServer("", library.Server{Name: "db", Transport: "stdio", Command: "/opt/my-db", Agents: []string{}, Local: true}); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := library.SaveServer("", library.Server{Name: "mine", Transport: "stdio", Command: "/opt/mine", Agents: []string{}, Local: true}); err != nil {
+ t.Fatal(err)
+ }
+ own, err := Collect(true, "test")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(own.Library.MCP) != 0 {
+ t.Fatalf("a backup made here carries the local servers: %+v", own.Library.MCP)
+ }
+ got, err := Open(data, "pw")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if r, err := Restore(got, Parts{Library: true}); err != nil || !r.Library {
+ t.Fatalf("restore: %+v %v", r, err)
+ }
+ if s := libServer(t, "db"); s == nil || !s.Local || s.Command != "/opt/my-db" {
+ t.Fatalf("db after the restore: %+v", s)
+ }
+ if s := libServer(t, "mine"); s == nil || !s.Local {
+ t.Fatalf("mine after the restore: %+v", s)
+ }
+ if libServer(t, "gh") == nil {
+ t.Fatal("the backup's gh didn't come in")
+ }
+ // this computer's own backup, restored: still there
+ sealed, _ := Seal(own, "pw")
+ got, _ = Open(sealed, "pw")
+ if _, err := Restore(got, Parts{Library: true}); err != nil {
+ t.Fatal(err)
+ }
+ if s := libServer(t, "mine"); s == nil || !s.Local || libServer(t, "gh") != nil {
+ t.Fatalf("after this computer's own backup: mine %+v", s)
+ }
+}
diff --git a/internal/cli/library_cli.go b/internal/cli/library_cli.go
index 41f7f6339..57fc39f68 100644
--- a/internal/cli/library_cli.go
+++ b/internal/cli/library_cli.go
@@ -19,8 +19,10 @@ const libraryUsage = `magpie library what the library gives
magpie library instructions print the shared instructions
magpie library instructions set <file|-> replace them with a file's text (- for stdin)
magpie library instructions agents <a,b…|none> the agents that get them
- magpie library mcp add <name> <url | command args…> [agents=a,b…]
+ magpie library mcp add <name> <url | command args…> [agents=a,b…] [--local]
magpie library mcp agents <name> <a,b…|none>
+ magpie library mcp local <name> on|off keep it to this computer: a sync or a backup never carries it, and one
+ coming in neither takes it away nor puts another computer's in its place
magpie library mcp rm <name>
magpie library mcp hub on|off give each agent one MCP server, magpie, in place of the library's (magpie runs them, once for every agent)
magpie library skill agents <name> <a,b…|none>
@@ -97,8 +99,11 @@ func libraryCmd(args []string) error {
switch {
case len(rest) >= 3 && rest[0] == "add":
var cmd, agents []string
+ local := false
for _, a := range rest[2:] {
- if v, ok := strings.CutPrefix(a, "agents="); ok {
+ if a == "--local" {
+ local = true
+ } else if v, ok := strings.CutPrefix(a, "agents="); ok {
if agents, err = libraryAgents(v, "mcp"); err != nil {
return err
}
@@ -113,6 +118,7 @@ func libraryCmd(args []string) error {
if agents != nil {
s.Agents = agents
}
+ s.Local = local
res, err = library.SaveServer("", s)
if len(s.Agents) == 0 {
unused = s.Name
@@ -122,6 +128,15 @@ func libraryCmd(args []string) error {
if as, err = libraryAgents(rest[2], "mcp"); err == nil {
res, err = library.ServerAgents(rest[1], as)
}
+ case len(rest) == 3 && rest[0] == "local" && (rest[2] == "on" || rest[2] == "off") && !strings.HasPrefix(rest[1], "-"):
+ if res, err = library.ServerLocal(rest[1], rest[2] == "on"); err == nil && len(res.Changed) == 0 && len(res.Problems) == 0 {
+ if rest[2] == "on" {
+ fmt.Println(green.Render("✓"), rest[1], "is kept to this computer: a sync or a backup never carries it")
+ } else {
+ fmt.Println(green.Render("✓"), rest[1], "goes with the library again at the next sync")
+ }
+ return nil
+ }
case len(rest) == 2 && rest[0] == "rm":
res, err = library.RemoveServer(rest[1])
case len(rest) == 2 && rest[0] == "hub" && (rest[1] == "on" || rest[1] == "off"):
@@ -427,6 +442,9 @@ func libraryStatus() error {
what = strings.TrimSpace(s.Command + " " + strings.Join(s.Args, " "))
}
fmt.Printf(" %s %s → %s\n", bold.Render(s.Name), muted.Render(what), on(s.Agents))
+ if s.Local {
+ fmt.Println(" ", muted.Render("this computer only: a sync never carries it · magpie library mcp local "+s.Name+" off"))
+ }
for a, e := range s.Problems {
fmt.Println(" ", amber.Render("!"), a, muted.Render(e))
}
diff --git a/internal/davsync/local_server_test.go b/internal/davsync/local_server_test.go
new file mode 100644
index 000000000..c509f232c
--- /dev/null
+++ b/internal/davsync/local_server_test.go
@@ -0,0 +1,115 @@
+package davsync
+
+import (
+ "context"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+
+ "github.com/yetone/magpie/internal/appdir"
+ "github.com/yetone/magpie/internal/library"
+ "github.com/yetone/magpie/internal/provider"
+)
+
+// A server kept to one computer (huhuy72219405 on X: "有些mcp属于本地的,
+// 同步之后其他设备不应该读取到") goes nowhere through a real sync: the
+// other computer never gets it, its own server by that name neither takes
+// its place nor is taken from it, and syncs either way leave both as they
+// are.
+func TestLocalServerThroughSync(t *testing.T) {
+ f, srv := newFakeS3(t)
+ cfg := f.config(srv)
+ cfg.Keys, cfg.Agents = false, false
+ a, b := newComputer(t), newComputer(t)
+ use := func(c computer) {
+ t.Helper()
+ c.use(t)
+ appdir.UseExecutable("")
+ provider.ForgetAccounts()
+ p := filepath.Join(string(c), ".claude/settings.json")
+ os.MkdirAll(filepath.Dir(p), 0o755)
+ if _, err := os.Stat(p); err != nil {
+ os.WriteFile(p, nil, 0o644)
+ }
+ }
+ t.Cleanup(provider.ForgetAccounts)
+ now := func() {
+ t.Helper()
+ if err := Now(context.Background()); err != nil {
+ t.Fatal(err)
+ }
+ }
+ ok := func(_ *library.Result, err error) {
+ t.Helper()
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
+ server := func(name string) *library.Server {
+ t.Helper()
+ v, err := library.Read(nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, s := range v.Servers {
+ if s.Name == name {
+ return s.Server
+ }
+ }
+ return nil
+ }
+ // Claude Code's servers, under CLAUDE_CONFIG_DIR as use sets it
+ claude := func(c computer) string {
+ raw, _ := os.ReadFile(filepath.Join(string(c), ".claude", ".claude.json"))
+ return string(raw)
+ }
+
+ // A has gh to share and db kept to itself, and syncs first
+ use(a)
+ ok(library.SaveServer("", library.Server{Name: "gh", Transport: "stdio", Command: "gh-mcp", Agents: []string{"claude"}}))
+ ok(library.SaveServer("", library.Server{Name: "db", Transport: "stdio", Command: "/opt/a-db", Agents: []string{"claude"}, Local: true}))
+ if err := Configure(cfg); err != nil {
+ t.Fatal(err)
+ }
+ now()
+
+ // B joins: gh, and no db
+ use(b)
+ if err := Configure(cfg); err != nil {
+ t.Fatal(err)
+ }
+ now()
+ if server("gh") == nil || server("db") != nil || strings.Contains(claude(b), "/opt/a-db") || !strings.Contains(claude(b), "gh-mcp") {
+ t.Fatalf("B after joining: gh %v, db %+v; claude %s", server("gh"), server("db"), claude(b))
+ }
+ // B has a db of its own, shared, and syncs
+ ok(library.SaveServer("", library.Server{Name: "db", Transport: "stdio", Command: "b-db", Agents: []string{"claude"}}))
+ now()
+
+ // A syncs: its db stays its own, B's isn't given to Claude Code here
+ use(a)
+ now()
+ if s := server("db"); s == nil || !s.Local || s.Command != "/opt/a-db" {
+ t.Fatalf("A's db after B's came: %+v", s)
+ }
+ if c := claude(a); !strings.Contains(c, "/opt/a-db") || strings.Contains(c, "b-db") {
+ t.Fatalf("A's Claude Code: %s", c)
+ }
+ // A changes gh, which syncs up with B's db carried on
+ ok(library.ServerAgents("gh", []string{}))
+ now()
+
+ // B syncs: A's change came, and B's db wasn't taken away by it
+ use(b)
+ now()
+ if s := server("gh"); s == nil || len(s.Agents) != 0 {
+ t.Fatalf("A's gh change didn't reach B: %+v", s)
+ }
+ if s := server("db"); s == nil || s.Command != "b-db" || s.Local {
+ t.Fatalf("B's db after A's sync: %+v", s)
+ }
+ if strings.Contains(claude(b), "/opt/a-db") {
+ t.Fatalf("A's local db reached B: %s", claude(b))
+ }
+}
diff --git a/internal/gui/assets/plugins/library/client.js b/internal/gui/assets/plugins/library/client.js
index b212cacb9..011be200c 100644
--- a/internal/gui/assets/plugins/library/client.js
+++ b/internal/gui/assets/plugins/library/client.js
@@ -1965,6 +1965,8 @@ magpie.plugin("library", (ctx) => {
const nm = el("div", "name mono", s.name);
if (s.signIn?.dead) nm.append(tag(t("Sign-in ran out"), "warn", t("Open it to sign in again")));
else if (s.signIn?.signedIn) nm.append(tag(t("Signed in"), "lib-signed", t("The agents given it use magpie's sign-in")));
+ // kept to this computer: sync carries it nowhere (huhuy72219405 on X)
+ if (s.local) nm.append(tag(t("This computer only"), "lib-local", t("Sync never carries it to your other computers")));
// its status beside the name, not in it: the name is still the name
who.classList.add("lib-srvwho");
who.append(nm, healthEl(s.name));
@@ -2573,6 +2575,7 @@ magpie.plugin("library", (ctx) => {
const d = prefill || (s ? structuredClone(s) : { name: "", transport: "stdio", command: "", args: [], env: {}, url: "", headers: {}, agents: all.map((a) => a.id) });
if (!d.env) d.env = {};
if (!d.headers) d.headers = {};
+ d.local = !!d.local;
const ed = el("div", "editor lib-editor");
const head = el("div", "ehead");
head.append(mark(s?.icon, d.transport === "stdio" ? GLYPH.cmd : GLYPH.web), el("b", "", s ? s.name : t("New MCP server")));
@@ -2633,6 +2636,12 @@ magpie.plugin("library", (ctx) => {
ed.append(slot);
const agentsBox = el("div");
ed.append(...field(t("Agents"), agentsBox));
+ // kept to this computer: a sync neither carries it to the others nor
+ // takes it away here (huhuy72219405 on X)
+ const hereBox = el("div", "lib-localbox");
+ const drawHere = () => hereBox.replaceChildren(toggle(d.local, t("This computer only"), (on) => { d.local = on; drawHere(); }));
+ drawHere();
+ ed.append(...field(t("This computer only"), hereBox, t("Sync never carries it to your other computers, and a sync from them neither removes it nor puts theirs in its place")));
ed.append(err);
function drawAgents() {
@@ -2694,7 +2703,7 @@ magpie.plugin("library", (ctx) => {
// send saves the form; s is then the server as saved, for a save after
// a sign-in's to be of it
const send = async () => {
- const body = { old: s ? s.name : "", server: { name: d.name, transport: d.transport, agents: d.agents, startupTimeout: d.startupTimeout || 0 } };
+ const body = { old: s ? s.name : "", server: { name: d.name, transport: d.transport, agents: d.agents, startupTimeout: d.startupTimeout || 0, local: !!d.local } };
if (d.transport === "stdio") Object.assign(body.server, { command: d.command, args: d.args, env: d.env });
else Object.assign(body.server, { url: d.url, headers: d.headers, oauth: d.transport === "http" && d.oauth?.clientId ? d.oauth : null });
take(await api("library/servers/save", body));
diff --git a/internal/gui/assets/plugins/library/i18n.js b/internal/gui/assets/plugins/library/i18n.js
index 70ad4a909..fc389487e 100644
--- a/internal/gui/assets/plugins/library/i18n.js
+++ b/internal/gui/assets/plugins/library/i18n.js
@@ -2,6 +2,9 @@
// kernel adds them to i18n.js's (magpie.strings).
magpie.strings({
zh: {
+ "This computer only": "只在这台电脑",
+ "Sync never carries it to your other computers": "同步不会把它带到你的其他电脑",
+ "Sync never carries it to your other computers, and a sync from them neither removes it nor puts theirs in its place": "同步不会把它带到你的其他电脑;其他电脑同步过来时,既不会删掉它,也不会用它们的同名服务器替换它",
"Move into the library": "移入资源库",
"Manage in magpie": "交给 magpie 管理",
"Manage {n} in magpie": "将 {n} 个交给 magpie 管理",
@@ -725,6 +728,9 @@ magpie.strings({
"{agents} can be changed once it runs.": "{agents} 要等它运行后才能修改。",
},
"zh-TW": {
+ "This computer only": "只在這台電腦",
+ "Sync never carries it to your other computers": "同步不會把它帶到你的其他電腦",
+ "Sync never carries it to your other computers, and a sync from them neither removes it nor puts theirs in its place": "同步不會把它帶到你的其他電腦;其他電腦同步過來時,既不會刪掉它,也不會用它們的同名伺服器取代它",
"Move into the library": "移入資源庫",
"Manage in magpie": "交給 magpie 管理",
"Manage {n} in magpie": "將 {n} 個交給 magpie 管理",
@@ -1448,6 +1454,9 @@ magpie.strings({
"{agents} can be changed once it runs.": "{agents} 要等它執行後才能修改。",
},
ja: {
+ "This computer only": "このコンピュータだけ",
+ "Sync never carries it to your other computers": "同期でほかのコンピュータには送られません",
+ "Sync never carries it to your other computers, and a sync from them neither removes it nor puts theirs in its place": "同期でほかのコンピュータには送られません。ほかのコンピュータからの同期で削除されたり、同じ名前のサーバーに置き換えられたりすることもありません",
"Move into the library": "ライブラリへ移す",
"Manage in magpie": "magpie で管理",
"Manage {n} in magpie": "{n} 件を magpie で管理",
@@ -2171,6 +2180,9 @@ magpie.strings({
"{agents} can be changed once it runs.": "{agents} は起動後に変更できます。",
},
de: {
+ "This computer only": "Nur dieser Computer",
+ "Sync never carries it to your other computers": "Die Synchronisierung bringt ihn nicht auf deine anderen Computer",
+ "Sync never carries it to your other computers, and a sync from them neither removes it nor puts theirs in its place": "Die Synchronisierung bringt ihn nicht auf deine anderen Computer, und eine Synchronisierung von dort entfernt ihn weder noch ersetzt sie ihn durch ihren gleichnamigen Server",
"Move into the library": "In die Bibliothek verschieben",
"Manage in magpie": "In magpie verwalten",
"Manage {n} in magpie": "{n} in magpie verwalten",
diff --git a/internal/gui/tests/mcp-local-server.test.cjs b/internal/gui/tests/mcp-local-server.test.cjs
new file mode 100644
index 000000000..1cb1c2317
--- /dev/null
+++ b/internal/gui/tests/mcp-local-server.test.cjs
@@ -0,0 +1,115 @@
+// Run with Node's test runner and Playwright on the module path; see README.md.
+// huhuy72219405 on X ("能不能把不同设备的mcp区分一下,有些mcp属于本地的,同步之后
+// 其他设备不应该读取到"): an MCP server can be kept to this computer. Its
+// editor has one switch, "This computer only", saved with the server as
+// local and shown again; the row says so with a tag. Every language,
+// Chromium and WebKit, 1100 and 390 wide; nothing scrolls sideways. No
+// backend: the API is faked here.
+const assert = require("node:assert/strict");
+const fs = require("node:fs/promises");
+const path = require("node:path");
+const { test } = require("node:test");
+const { chromium, webkit } = require("playwright");
+
+const assets = path.resolve(__dirname, "../assets");
+const { I18N } = require("./strings.cjs").strings(); // i18n.js's and the plugins'
+const tr = (lang, s, vars = {}) => ((lang === "en" ? s : I18N[lang][s]) || s).replace(/\{(\w+)\}/g, (_, k) => vars[k]);
+const HOME = "/Users/xv";
+const agents = [{ id: "claude", name: "Claude Code", icon: "", skills: `${HOME}/.claude/skills`, mcp: `${HOME}/.claude.json` }];
+
+function server(lang, calls) {
+ const lib = {
+ dir: `${HOME}/.magpie/library`, backups: `${HOME}/.magpie/backups`, home: HOME,
+ agents,
+ instructions: { agents: [], sets: [] }, foundServers: [], projects: [], foundSkills: [], skills: [],
+ servers: [{ name: "mine", transport: "stdio", command: "/opt/mine/mcp", agents: ["claude"] }],
+ };
+ return async (route) => {
+ const req = route.request(), url = new URL(req.url());
+ if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
+ if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
+ if (url.pathname === "/api/state") return route.fulfill({ json: { agents: [], profiles: [], settings: { lang, theme: "light" } } });
+ if (url.pathname === "/api/plugins") return route.fulfill({ json: { plugins: [] } });
+ if (url.pathname === "/api/library") return route.fulfill({ json: lib });
+ if (url.pathname === "/api/library/mcp/check") return route.fulfill({ json: { servers: {} } });
+ if (url.pathname === "/api/library/servers/save") {
+ const { old, server: s } = req.postDataJSON();
+ calls.push(`${s.name} ${s.local}`);
+ const i = lib.servers.findIndex((x) => x.name === old);
+ lib.servers[i] = { ...lib.servers[i], ...s };
+ if (!s.local) delete lib.servers[i].local;
+ return route.fulfill({ json: { ...lib, result: { changed: ["claude"] } } });
+ }
+ if (url.pathname === "/api/usage/quotas") return route.fulfill({ json: [] });
+ if (url.pathname === "/api/groups") return route.fulfill({ json: { groups: [] } });
+ if (url.pathname === "/api/providers") return route.fulfill({ json: { providers: [], gateway: { running: true } } });
+ if (url.pathname.startsWith("/api/")) return route.fulfill({ json: {} });
+ const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
+ const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
+ await route.fulfill({ body: await fs.readFile(file), contentType });
+ };
+}
+
+for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
+ test(engine + ": an MCP server kept to this computer", async (t) => {
+ assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
+ const errors = [];
+ t.after(async () => {
+ if (errors.length) console.log(errors);
+ await browser.close();
+ });
+ for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
+ for (const width of [1100, 390]) {
+ await t.test(`${lang} ${width}`, async () => {
+ const w = (s, v) => tr(lang, s, v);
+ if (lang !== "en") for (const s of ["This computer only", "Sync never carries it to your other computers", "Sync never carries it to your other computers, and a sync from them neither removes it nor puts theirs in its place"]) assert.ok(I18N[lang][s], `${lang}: ${s}`);
+ const calls = [];
+ const ctx = await browser.newContext({ viewport: { width, height: 800 } });
+ await ctx.addInitScript(() => { try { localStorage.setItem("magpie.libTab", "mcp"); } catch {} });
+ const page = await ctx.newPage();
+ page.setDefaultTimeout(5000);
+ page.on("pageerror", (e) => errors.push(e.message));
+ await page.route("**/*", server(lang, calls));
+ await page.goto("http://magpie.test/");
+ await page.locator('button[data-view="library"]').click();
+ const row = page.locator("#view-library .lib-server", { has: page.locator('.lib-health[data-server="mine"]') });
+ const ed = page.locator("#modal .lib-editor");
+ const sw = ed.getByRole("switch", { name: w("This computer only"), exact: true });
+ const tag = row.locator(".lib-tag.lib-local");
+ const open = async () => { await row.locator(".name").click(); await ed.waitFor(); };
+ const save = async () => { await ed.locator(":scope > .bar button.primary").click(); await ed.waitFor({ state: "detached" }); };
+
+ await row.waitFor();
+ assert.equal(await tag.count(), 0, "a shared server has no tag");
+ // off for a server shared as before; the hint says what it does
+ await open();
+ assert.equal(await sw.getAttribute("aria-checked"), "false");
+ await ed.locator(".hint", { hasText: w("Sync never carries it to your other computers, and a sync from them neither removes it nor puts theirs in its place") }).waitFor();
+ await sw.click();
+ assert.equal(await sw.getAttribute("aria-checked"), "true");
+ await save();
+ assert.deepEqual(calls, ["mine true"]);
+ // the row says so, and the editor shows it on again
+ await tag.waitFor();
+ assert.equal((await tag.textContent()).trim(), w("This computer only"));
+ await open();
+ assert.equal(await sw.getAttribute("aria-checked"), "true");
+ // off again, saved as shared
+ await sw.click();
+ await save();
+ assert.deepEqual(calls, ["mine true", "mine false"]);
+ await tag.waitFor({ state: "detached" });
+ // Cancel keeps it as it was
+ await open();
+ await sw.click();
+ await ed.locator(":scope > .bar button", { hasText: w("Cancel") }).click();
+ assert.deepEqual(calls, ["mine true", "mine false"]);
+ assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true, "no sideways scroll");
+ await ctx.close();
+ });
+ }
+ }
+ assert.deepEqual(errors, []);
+ });
+}
diff --git a/internal/library/carry.go b/internal/library/carry.go
index 045eb26f4..3ad4d7e85 100644
--- a/internal/library/carry.go
+++ b/internal/library/carry.go
@@ -83,7 +83,9 @@ func Collect() (*Bundle, error) {
if len(b.Extra) == 0 {
b.Extra = nil
}
- for _, s := range sorted(l.MCP, func(s *Server) string { return s.Name }) {
+ // a server kept to this computer stays out; another computer's by its
+ // name, which a sync brought, goes on as it came (mcp_local.go)
+ for _, s := range sorted(l.carriedServers(), func(s *Server) string { return s.Name }) {
c := *carried(s) // magpie's own by name, each computer's own binary
c.Agents = orNone(slices.Sorted(slices.Values(s.Agents)))
b.MCP = append(b.MCP, &c)
@@ -449,12 +451,7 @@ func Put(b *Bundle) (*Result, error) {
}
}
- l.MCP = nil
- for _, s := range b.MCP {
- c := *s
- c.Agents = slices.Sorted(slices.Values(orNone(s.Agents)))
- l.MCP = append(l.MCP, &c)
- }
+ l.putServers(b.MCP)
l.Icons = maps.Clone(b.Icons)
return nil
})
diff --git a/internal/library/library.go b/internal/library/library.go
index 718b17de3..7116fa11c 100644
--- a/internal/library/library.go
+++ b/internal/library/library.go
@@ -35,6 +35,11 @@ type Library struct {
// Applied is what magpie wrote into each agent, so that what it takes
// away is only ever its own.
Applied map[string]*Applied `json:"applied,omitempty"`
+ // Away are other computers' servers by the name of one kept to this
+ // computer here (Server.Local), as a sync last brought them: never
+ // given to an agent here, and carried on as they came, so a sync from
+ // here takes them from nobody (carry.go)
+ Away []*Server `json:"away,omitempty"`
// Icons are the icons of the servers added from the market, by what
// each runs, for the page to show them by
Icons map[string]string `json:"icons,omitempty"`
@@ -175,6 +180,7 @@ func (l *Library) save() error {
for _, s := range l.MCP {
s.Agents = orNone(s.Agents)
}
+ sort.Slice(l.Away, func(i, j int) bool { return l.Away[i].Name < l.Away[j].Name })
l.Instructions.Agents = orNone(l.Instructions.Agents)
b, err := json.MarshalIndent(l, "", " ")
if err != nil {
@@ -273,6 +279,7 @@ func changeLocked(f func(l *Library) error) (*Result, error) {
if err := f(l); err != nil {
return nil, err
}
+ l.settleAway()
l.heal() // a server f brought in, from another computer too
if err := l.save(); err != nil {
return nil, err
diff --git a/internal/library/mcp.go b/internal/library/mcp.go
index effbcdcbb..8c3f93b87 100644
--- a/internal/library/mcp.go
+++ b/internal/library/mcp.go
@@ -51,6 +51,11 @@ type Server struct {
// and list its tools: Codex's startup_timeout_sec (#3168), the only
// agent given it. 0 leaves it to the agent (Codex's own is 30s).
StartupTimeout int `json:"startupTimeout,omitempty"`
+ // Local keeps the server to this computer (huhuy72219405 on X: a
+ // server of a program or folder only this computer has). A backup or
+ // a sync never carries it, and one coming in neither takes it away nor
+ // puts another computer's of that name in its place (carry.go).
+ Local bool `json:"local,omitempty"`
// startupWrote is the startup_timeout_sec magpie last wrote in the
// entry being written, 0 for none: one the entry has otherwise is the
diff --git a/internal/library/mcp_local.go b/internal/library/mcp_local.go
new file mode 100644
index 000000000..c01d82548
--- /dev/null
+++ b/internal/library/mcp_local.go
@@ -0,0 +1,94 @@
+package library
+
+import (
+ "fmt"
+ "slices"
+)
+
+// A server can be kept to this computer (Server.Local; huhuy72219405 on
+// X: "有些mcp属于本地的,同步之后其他设备不应该读取到"). It is for a server
+// that runs a program, or reads a folder, only this computer has.
+//
+// - Collect leaves it out, so a backup or a sync carries it to no other
+// computer. Turning it on takes the server out of what is carried, so
+// the other computers let go of theirs at their next sync, as of any
+// server taken out; the flag itself is never carried.
+// - Put keeps it, whatever comes in: a bundle without it doesn't take it
+// away, and another computer's server by its name doesn't take its
+// place. That one is kept in Away, given to no agent here, and carried
+// on as it came, so a sync from here doesn't take it from the computers
+// that have it.
+// - Once no server here by that name is kept to this computer (it was
+// removed, renamed or shared again), settleAway lets go of Away's: the
+// server here shared again goes in its place, and with none here the
+// other computers' comes in, as a sync would bring it.
+
+// carriedServers are the servers a carried library has: the library's,
+// but those kept to this computer, and the other computers' by their
+// names.
+func (l *Library) carriedServers() []*Server {
+ out := []*Server{}
+ for _, s := range l.MCP {
+ if !s.Local {
+ out = append(out, s)
+ }
+ }
+ return append(out, l.Away...)
+}
+
+// putServers makes the library's servers those a carried library has,
+// but for the ones kept to this computer, which stay as they are.
+func (l *Library) putServers(in []*Server) {
+ own := map[string]bool{}
+ servers := []*Server{}
+ for _, s := range l.MCP {
+ if s.Local {
+ own[s.Name] = true
+ servers = append(servers, s)
+ }
+ }
+ l.Away = nil
+ for _, s := range in {
+ c := *s
+ c.Local = false // only this computer says what is its own
+ c.Agents = slices.Sorted(slices.Values(orNone(s.Agents)))
+ if own[c.Name] {
+ l.Away = append(l.Away, &c)
+ } else {
+ servers = append(servers, &c)
+ }
+ }
+ l.MCP = servers
+}
+
+// settleAway lets go of each server in Away whose name no server kept to
+// this computer has any more. One shared here by that name is the one
+// carried from now on; with none, the other computers' comes in.
+func (l *Library) settleAway() {
+ away := l.Away[:0:0]
+ for _, a := range l.Away {
+ switch s := l.server(a.Name); {
+ case s != nil && s.Local:
+ away = append(away, a)
+ case s == nil:
+ l.MCP = append(l.MCP, a)
+ }
+ }
+ l.Away = away
+ if len(l.Away) == 0 {
+ l.Away = nil
+ }
+}
+
+// ServerLocal keeps a server to this computer, or lets a sync carry it
+// again.
+func ServerLocal(name string, on bool) (*Result, error) {
+ return change(func(l *Library) error {
+ s := l.server(name)
+ if s == nil {
+ return fmt.Errorf("no server called %s", name)
+ }
+ s.Local = on
+ return nil
+ })
+}
diff --git a/internal/library/mcp_local_test.go b/internal/library/mcp_local_test.go
new file mode 100644
index 000000000..646266799
--- /dev/null
+++ b/internal/library/mcp_local_test.go
@@ -0,0 +1,149 @@
+package library
+
+import (
+ "path/filepath"
+ "slices"
+ "strings"
+ "testing"
+)
+
+func serverIn(t *testing.T, name string) *Server {
+ t.Helper()
+ v, err := Read(nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, s := range v.Servers {
+ if s.Name == name {
+ return s.Server
+ }
+ }
+ return nil
+}
+
+func carriedNames(b Bundle) []string {
+ var out []string
+ for _, s := range b.MCP {
+ out = append(out, s.Name)
+ }
+ return out
+}
+
+// A server kept to this computer (huhuy72219405 on X: "有些mcp属于本地的,
+// 同步之后其他设备不应该读取到") is never in what a sync or a backup
+// carries, and adding one changes nothing a sync uploads.
+func TestLocalServerNotCarried(t *testing.T) {
+ sandbox(t)
+ ok(t)(SaveServer("", Server{Name: "gh", Transport: "stdio", Command: "gh-mcp", Agents: []string{"claude"}}))
+ before := mustJSON(t, carry(t))
+ ok(t)(SaveServer("", Server{Name: "here", Transport: "stdio", Command: "/opt/mine/mcp", Agents: []string{"claude"}, Local: true}))
+ if s := serverIn(t, "here"); s == nil || !s.Local {
+ t.Fatalf("the local server as saved: %+v", s)
+ }
+ b := carry(t)
+ if got := carriedNames(b); !slices.Equal(got, []string{"gh"}) {
+ t.Fatalf("carried %v, want gh alone", got)
+ }
+ if after := mustJSON(t, b); after != before {
+ t.Fatalf("a local server changed what a sync carries:\n%s\n%s", before, after)
+ }
+ // a shared server turned local leaves what is carried; shared again, it is back
+ ok(t)(ServerLocal("gh", true))
+ if got := carriedNames(carry(t)); len(got) != 0 {
+ t.Fatalf("gh kept here is still carried: %v", got)
+ }
+ ok(t)(ServerLocal("gh", false))
+ if got := mustJSON(t, carry(t)); got != before {
+ t.Fatalf("gh shared again isn't carried as before:\n%s\n%s", before, got)
+ }
+}
+
+// A bundle coming in from another computer, without the server, keeps it
+// here, kept to this computer and in the agents it was given to; the
+// incoming servers go in beside it.
+func TestPutKeepsLocalServer(t *testing.T) {
+ sandbox(t)
+ ok(t)(SaveServer("", Server{Name: "fs", Transport: "stdio", Command: "fs-mcp", Agents: []string{"claude"}}))
+ other := carry(t) // another computer's library: fs alone
+
+ h := sandbox(t)
+ ok(t)(SaveServer("", Server{Name: "here", Transport: "stdio", Command: "/opt/mine/mcp", Agents: []string{"claude"}, Local: true}))
+ ok(t)(SaveServer("", Server{Name: "old", Transport: "stdio", Command: "old-mcp", Agents: []string{"claude"}}))
+ ok(t)(Put(&other))
+ if s := serverIn(t, "here"); s == nil || !s.Local || !slices.Equal(s.Agents, []string{"claude"}) {
+ t.Fatalf("the local server after a sync from another computer: %+v", s)
+ }
+ if serverIn(t, "fs") == nil || serverIn(t, "old") != nil {
+ t.Fatal("the incoming library wasn't taken in beside it")
+ }
+ c := read(t, filepath.Join(h, ".claude.json"))
+ if !strings.Contains(c, "/opt/mine/mcp") || !strings.Contains(c, "fs-mcp") || strings.Contains(c, "old-mcp") {
+ t.Fatalf("Claude Code's servers after the sync: %s", c)
+ }
+ // a bundle that says it is local (only this computer says that) is taken in as shared
+ in := carry(t)
+ for _, s := range in.MCP {
+ s.Local = true
+ }
+ ok(t)(Put(&in))
+ if s := serverIn(t, "fs"); s == nil || s.Local {
+ t.Fatalf("an incoming server's local flag was taken: %+v", s)
+ }
+}
+
+// Another computer's server by the name of one kept to this computer
+// doesn't take its place here: it is given to no agent here, and carried
+// on as it came, so a sync from here doesn't take it from the computers
+// that have it. Once the one here is shared again, or gone, the name is
+// one server again.
+func TestPutSameNameAsLocal(t *testing.T) {
+ sandbox(t)
+ ok(t)(SaveServer("", Server{Name: "db", Transport: "stdio", Command: "their-db", Agents: []string{"codex"}}))
+ theirs := carry(t)
+ want := mustJSON(t, theirs)
+
+ h := sandbox(t)
+ ok(t)(SaveServer("", Server{Name: "db", Transport: "stdio", Command: "/opt/my-db", Agents: []string{"claude"}, Local: true}))
+ ok(t)(Put(&theirs))
+ s := serverIn(t, "db")
+ if s == nil || !s.Local || s.Command != "/opt/my-db" || !slices.Equal(s.Agents, []string{"claude"}) {
+ t.Fatalf("this computer's db after theirs came in: %+v", s)
+ }
+ if c := read(t, filepath.Join(h, ".claude.json")); !strings.Contains(c, "/opt/my-db") || strings.Contains(c, "their-db") {
+ t.Fatalf("Claude Code's servers: %s", c)
+ }
+ if c := read(t, filepath.Join(h, ".codex/config.toml")); strings.Contains(c, "their-db") {
+ t.Fatalf("theirs was given to Codex here: %s", c)
+ }
+ if got := mustJSON(t, carry(t)); got != want {
+ t.Fatalf("theirs isn't carried on as it came:\n%s\n%s", want, got)
+ }
+ // edits here change nothing carried
+ ok(t)(ServerAgents("db", []string{"claude", "codex"}))
+ if got := mustJSON(t, carry(t)); got != want {
+ t.Fatalf("an edit of the local db changed what is carried:\n%s\n%s", want, got)
+ }
+ // a bundle without db lets theirs go; the local one stays
+ none := Bundle{MCP: []*Server{}, Skills: []*CarriedSkill{}}
+ ok(t)(Put(&none))
+ if s := serverIn(t, "db"); s == nil || s.Command != "/opt/my-db" {
+ t.Fatalf("this computer's db after a bundle without it: %+v", s)
+ }
+ if got := carriedNames(carry(t)); len(got) != 0 {
+ t.Fatalf("carried %v after theirs was taken out", got)
+ }
+
+ // theirs again; removed here, theirs comes in as a sync would bring it
+ ok(t)(Put(&theirs))
+ ok(t)(RemoveServer("db"))
+ if s := serverIn(t, "db"); s == nil || s.Local || s.Command != "their-db" {
+ t.Fatalf("after the local db was removed: %+v", s)
+ }
+ // the local one shared again is the one carried
+ ok(t)(SaveServer("db", Server{Name: "db", Transport: "stdio", Command: "/opt/my-db", Agents: []string{"claude"}, Local: true}))
+ ok(t)(Put(&theirs))
+ ok(t)(ServerLocal("db", false))
+ if b := carry(t); len(b.MCP) != 1 || b.MCP[0].Command != "/opt/my-db" {
+ t.Fatalf("shared again, carried %s", mustJSON(t, b))
+ }
+}
diff --git a/internal/tui/library.go b/internal/tui/library.go
index 33a79c95e..a3354e55d 100644
--- a/internal/tui/library.go
+++ b/internal/tui/library.go
@@ -64,6 +64,9 @@ func (m *model) reloadLibrary() {
if s.Command != "" {
what = strings.TrimSpace(s.Command + " " + strings.Join(s.Args, " "))
}
+ if s.Local {
+ what = "this computer only · " + what
+ }
m.lib = append(m.lib, libRow{kind: "mcp", name: s.Name, about: what, on: s.Agents, bad: len(s.Problems)})
}
for _, s := range v.Skills {
@@ -421,7 +424,8 @@ func saveServer(old *library.Server, line string) tea.Cmd {
if old != nil {
was, done = old.Name, "saved "+s.Name
// and its OAuth app and startup timeout, which only the GUI edits
- s.Agents, s.Env, s.Headers, s.OAuth, s.StartupTimeout = old.Agents, old.Env, old.Headers, old.OAuth, old.StartupTimeout
+ // and whether it is kept to this computer
+ s.Agents, s.Env, s.Headers, s.OAuth, s.StartupTimeout, s.Local = old.Agents, old.Env, old.Headers, old.OAuth, old.StartupTimeout, old.Local
}
return libCmd(func() (*library.Result, error) { return library.SaveServer(was, s) }, done)()
}