library: a synced MCP server can run its own command on this computer (jinpwng on X, #6426)

jinpwng runs one MCP server on a Mac and in WSL. Each needs its own
program path, and the only ways around it were two servers with two
names or keeping the server to one computer, which loses the sync of its
agents and note (#3836).

A command server now has an optional `shared` start. When it is set,
command, args and env are this computer's, and every reader (the agents'
files, projects, the router, the check) runs them with no change of its
own. Collect carries the shared start in their place and never the field,
so the other computers get exactly what they had. Put keeps this
computer's start, and what comes in for the server becomes the shared
start, so a note, agents or the other computer's own command change still
comes in. A server that comes in as a URL, one kept to this computer,
and the editor sending no shared start each end it.

- GUI: a saved synced command server's editor has "Use another command
  on this computer" under Command. With it on, the hint names what the
  other computers run, and "Use the synced command" goes back. Nothing
  else on the page moves; a new server and a local one have no button.
- CLI: `magpie library mcp here <name> <command args…>` and
  `… here <name> off`; the listing names a server that has one.
- TUI: an edit keeps the shared start.
- Docs: docs/subsystems/library.md, site docs (en, zh, ja).

Run (mote, at the tree pushed but before the rebase):
- go test ./internal/library/... ./internal/cli/... ./internal/tui/...
  ./internal/backup/... ./internal/gui/: ok
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: clean
- GUI, chromium and webkit: mcp-server-here (new: en, zh, zh-TW, ja, de at
  1100 and 390, the payload, no button on a local server, no sideways
  scroll), library-mcp-json, library-mcp-spaced-path, library-mcp-win-line,
  market-address, mcp-home-health, mcp-startup-timeout, market-have,
  mcp-editor-cancel, mcp-local-server, i18n-en-no-cjk, i18n-keys and the
  other library MCP files: 235 of 238. The reds:
  - i18n-keys "a plugin's words are its own": the same at origin/main
    3f6b1b0c9 (#6422, #6423, memory's "No folder").
  - market-have chromium "a server added by hand is marked added": a flake,
    red 1 of 3 at origin/main 3f6b1b0c9 and 1 of 3 here (#4620).

At the rebased head (on 04776ec6c, which touched library/client.js):
go test ./internal/gui/ ./internal/cli/ ok; GUI mcp-server-here,
mcp-local-server, library-group-steady, i18n-keys: 69 of 70, the red is
i18n-keys' #6422 above.

Broken by hand:
- keepStart doing nothing: TestServerHereThroughSync red (a sync took
  this computer's own command away).
- Collect carrying the server as is: red (carried /opt and "shared").

Not tried: the CLI's here command by hand (vet only; it calls the
tested ServerHere); the real app on a Mac with a real WSL computer syncing over
WebDAV; the test does the Mac-to-WSL round trip through Collect and Put.
A backup restored into an empty library gets the synced command only,
since a backup carries what sync carries.
This commit is contained in:
yetone
2026-11-13 13:42:48 +08:00
parent 406ad72f1a
commit 741d502d2a
15 changed files with 406 additions and 5 deletions
+3 -2
View File
@@ -86,6 +86,7 @@ Pi's extensions and packages.
- 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)
- A skill's group (its repository, `tracer.repoOf`) is traced from files that are one computer's own: the skills CLI's lock, a git checkout, CC Switch's record. `Collect` carries the result as `CarriedSkill.From` for a skill with no source of its own (ConatusMoon2222 on X: skills grouped by library on one computer sat in "this computer" on the next after a sync, and Group again had nothing to start from), and `Put` writes it as `Skill.From`. A bundle from before has none: `Put` then keeps the `From` this computer found for the same skill (a Group again, or an earlier sync), and `Skill.Gone` for one with the same source, which are this computer's. Group again fetches each GitHub repository some skill is traced to, so skills synced before still need one skill of the pack that carries its source (or an updated computer's next sync); a pack with no skill traced to it here has nothing to start from. Not covered: `Put` still writes a skill with a bundle's source, so a copy Group again bound to its repository here is unbound by a sync from a computer that has it unbound (`TestSyncedSkillKeepsItsRepo`, `TestSyncKeepsRepoFoundHere`, `TestRegroupAfterOldSync`). [`carry.go`](../../internal/library/carry.go), [`skill_from.go`](../../internal/library/skill_from.go)
- An MCP server can be kept to this computer (`Server.Local`; the editor's "Sync to your other computers" switch, off for a local one (it said "This computer only", which bin.90 on Discord read as sharing), the row tagged "Not synced", `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 router, 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 router serves local servers like any other, since it runs on this computer. A carried subagent names its servers, a local one too; a computer without that server leaves it out of the agents' files, as any server the library hasn't. 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 synced command server can be started its own way on this computer (#3836, #6426; jinpwng on X: one server on a Mac and in WSL, each with its own program path), where `Local` would keep the whole server here. `Server.Shared` holds the synced start (`Start`: command, args, env) while `Command`, `Args` and `Env` are this computer's, so every reader (the agents' files, projects, the router, the check) runs this computer's with no change of its own. `Collect` carries `Shared` in their place and never the field (`carriedStart`), so what this computer carries is what came in; `putServers` gives a server that comes in this computer's start again and makes what came its `Shared` (`keepStart`): the name, agents, note and tools still come and go with a sync. One that comes in as a URL ends it; so does turning the server local (`ServerLocal` on, and `check` drops `Shared` off a URL or local server). The editor's Use another command on this computer under Command (a synced, saved command server that isn't a plugin's) keeps the saved start as `shared` and leaves the line this computer's, its hint naming what the other computers run; Use the synced command puts it back. `SaveServer` takes `Shared` as sent, so the editor sends it every time and the TUI's edit copies it. CLI: `magpie library mcp here <name> <command args…>` and `here <name> off` (`ServerHere`); `magpie library` lists what the others run. Not covered: a URL server's own address here, and a cwd (the library has none). (`TestServerHereThroughSync`, `TestServerHereEnds`, `mcp-server-here.test.cjs`) [`mcp_here.go`](../../internal/library/mcp_here.go)
- The CLI sets a server's headers, env and startup timeout (#6111, Abandon332 on X): `magpie library mcp add <name> <url|command args…> header=K=V env=K=V timeout=SECS agents=…`, `mcp set <name> header=K=V|header-=K|env=K=V|env-=K|timeout=SECS` (the rest of the server kept) and `mcp show <name>` (JSON). `SplitServerWords` takes those words out of the line before `--`; words after `--` are the program's own, and a word that looks like a setting magpie doesn't know (`headers=`, `envs=`) is refused rather than passed on as an argument. `header=` on a command or `env=` on a URL is an error. (`TestSplitServerWords`, `TestLibraryMCPHeadersEnvTimeout`) [`mcp_options.go`](../../internal/library/mcp_options.go)
- A skill brought in from a link into a folder an app keeps per version (ego lite's framework `Versions/<v>`, #2635) is linked through the app's own steady link, or through `Versions/Current` when Current is that version (`linkVia`, `currentVersion`; `TestImportedSkillFollowsAppUpdate`, `TestImportedSkillThroughVersionsCurrent`). One brought in before that links straight to `Versions/<old>`, which the app's update deletes (tjhhhh on Discord). Every read of the page (looking at each link once, `readParts`, and starting that over when a link was mended) and the first step of every sync mend such links (`followMovedSkills`): a library skill that is a link, whose target isn't there, and whose first missing part is named like a version (`versionName`) is linked to the same place under that folder's `Current`, `current` or `latest` link, else under the highest version beside it that has a `SKILL.md` there (`movedVersion`, `versionLess`); one whose target is in `Versions/<v>` while the bundle's `Versions/Current` is a link to another version with the same skill is linked through Current (`laterCurrent`). `Source.Dir` follows. Only the library's link is replaced (`os.Remove` of the link, then `dirLink`; put back as it was when the new link can't be made). A folder of the library's own, a link to a folder the user deleted that isn't a version (shown missing as before) and the app's old version folder are left as they are (`TestOldImportFollowsDeletedVersion`, `TestOldImportFollowsVersionsCurrent`, `TestOldImportFollowsHighestVersion`, `TestMovedSkillsLeaveTheRest`). The app's own steady link can be left naming the version its update deleted (ego's `active_version_dir` still at 0.6.2.5 with only 0.6.2.7 on disk, tjhhhh again): the app's links are its own and never written to. When the library's link dangles and its target isn't in a version folder, the links on the way are followed as far as they are there (`linkedEnd`) and `movedVersion` is asked of where they end; the library links to the folder found, and keeps the steady link as `Source.Via`. Once the steady link leads to a `SKILL.md` again, the library links through it once more and `Via` is cleared (`TestSteadyLinkLeftOnDeletedVersion`, `TestSteadyLinkLeftOnDeletedVersionNoOther`). [`skill_moved.go`](../../internal/library/skill_moved.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) It also turns off `SharedSkills` (Put skills in, `skills_shared.go`): with every skill kept in `~/.agents/skills` every reader has every skill and the sync would link the handed-over one back there, which can't go with choosing agents; the sync then takes out magpie's own links there and never the user's entries (`TestHandOverWithSharedSetting`; the sheet says so when the setting is on; ConatusMoon2222 on X). The skill router lists nothing for an agent while that setting is on, which the Put skills in note says when both are on.
@@ -112,7 +113,7 @@ Pi's extensions and packages.
```sh
go test -tags nogui ./internal/library -run 'TestPlugin|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|TestLocalServerNotCarried|TestPutKeepsLocalServer|TestPutSameNameAsLocal'
go test -tags nogui ./internal/library -run 'TestSkillOffHere|TestLocalServerNotCarried|TestPutKeepsLocalServer|TestPutSameNameAsLocal|TestServerHere'
go test -tags nogui ./internal/backup -run 'TestRestoreKeepsLocalServer|TestBackupFileCarriesSubagents|TestBackupFileCarriesHooks'
go test -tags nogui ./internal/library -run 'TestHandOver|TestSharedUnderAnotherName|TestSharedAgentsSkills'
go test -tags nogui ./internal/davsync -run 'TestSkillOffHereThroughSync|TestLocalServerThroughSync|TestSyncSubagents|TestNoSubagentsHashAsBefore|TestSyncHooks|TestNoHooksHashAsBefore'
@@ -126,7 +127,7 @@ go test -tags nogui ./internal/library -run 'TestPi'
node --test internal/gui/tests/library-pi-extensions.test.cjs internal/gui/tests/library-pi-market.test.cjs
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/mcp-local-server.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/mcp-server-here.test.cjs internal/gui/tests/skill-handover.test.cjs
node --test internal/gui/tests/mcp-accounts.test.cjs 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-plugins.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
```
+24
View File
@@ -27,6 +27,8 @@ const libraryUsage = `magpie library what the library gives
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 here <name> <command args…> | off start a synced server with this command on this computer alone,
the others keeping the synced one (its name, agents and note still sync); off goes back to it
magpie library mcp off|on <name> take it from every agent, project and app, keeping its settings; on gives it back as it was
magpie library mcp rm <name>
magpie library mcp router on|off give each agent one MCP server, magpie, in place of the library's (magpie runs them, once for every agent)
@@ -173,6 +175,25 @@ func libraryCmd(args []string) error {
}
return nil
}
case len(rest) >= 3 && rest[0] == "here" && !strings.HasPrefix(rest[1], "-"):
// this computer's own command for a synced server (#3836, #6426)
cmd := rest[2:]
if len(cmd) > 0 && cmd[0] == "--" {
cmd = cmd[1:]
}
if len(rest) == 3 && rest[2] == "off" {
cmd = nil
} else if len(cmd) == 0 {
return fmt.Errorf("usage:\n %s", libraryUsage)
}
if res, err = library.ServerHere(rest[1], cmd); err == nil && len(res.Changed) == 0 && len(res.Problems) == 0 {
if cmd == nil {
fmt.Println(green.Render("✓"), rest[1], "runs the synced command here again")
} else {
fmt.Println(green.Render("✓"), rest[1], "runs", strings.Join(cmd, " "), "on this computer; your other computers keep the synced command")
}
return nil
}
case len(rest) == 2 && (rest[0] == "on" || rest[0] == "off") && !strings.HasPrefix(rest[1], "-"):
// off for everyone, kept with its settings; on again as it was
res, err = library.ServerOn(rest[1], rest[0] == "on")
@@ -495,6 +516,9 @@ func libraryStatus() error {
if s.Local {
fmt.Println(" ", muted.Render("not synced: a sync never carries it to your other computers · magpie library mcp local "+s.Name+" off"))
}
if sh := s.Shared; sh != nil {
fmt.Println(" ", muted.Render("this computer's own command; the others run "+strings.TrimSpace(sh.Command+" "+strings.Join(sh.Args, " "))+" · magpie library mcp here "+s.Name+" off"))
}
if s.Hub == library.HubDirect {
fmt.Println(" ", muted.Render("direct: each agent's own entry, never through the hub · magpie library mcp hub "+s.Name+" shared"))
}
+18 -2
View File
@@ -4106,7 +4106,23 @@ magpie.plugin("library", (ctx) => {
const g = el("div", "lib-grid");
if (d.transport === "stdio") {
const line = lineBox([d.command, ...(d.args || [])].filter((x, i) => i > 0 || x).map(quote).join(" "), "npx -y @modelcontextprotocol/server-github", (v) => { const w = words(v); d.command = w[0] || ""; d.args = w.slice(1); });
g.append(...field(t("Command"), line, t("The command and its arguments, as you'd type them")));
// a synced server can run its own command here (#3836, #6426;
// jinpwng on X: one server on a Mac and in WSL, each with its own
// path). Its name, agents and note stay the one server; d.shared
// is what the other computers run, the line this computer's
const cmdBox = el("div", "lib-cmdbox");
cmdBox.append(line);
const synced = d.shared ? [d.shared.command, ...(d.shared.args || [])].map(quote).join(" ") : "";
if (s && s.transport === "stdio" && !d.local && !s.plugin) {
cmdBox.append(d.shared
? button(t("Use the synced command"), "lib-addpair", () => { Object.assign(d, { command: d.shared.command, args: [...(d.shared.args || [])], env: { ...(d.shared.env || {}) } }); d.shared = null; draw(); })
: button(t("Use another command on this computer"), "lib-addpair", () => {
d.shared = { command: s.shared?.command || s.command, args: [...((s.shared || s).args || [])], env: { ...((s.shared || s).env || {}) } };
draw();
slot.querySelector(".lib-cmd")?.focus();
}));
}
g.append(...field(t("Command"), cmdBox, d.shared ? t("This computer's own, with its environment below. Your other computers run {cmd}", { cmd: synced }) : t("The command and its arguments, as you'd type them")));
g.append(...field(t("Environment"), pairs(d.env, "GITHUB_TOKEN", t("value"), (v) => { d.env = v; drawAgents(); }), refHint()));
} else {
const url = field2(d.url, "https://example.com/mcp", (v) => { d.url = v.trim(); signBox?.redraw(); });
@@ -4158,7 +4174,7 @@ magpie.plugin("library", (ctx) => {
// 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, local: !!d.local, hub: d.hub || "", note: d.note || "" } };
if (d.transport === "stdio") Object.assign(body.server, { command: d.command, args: d.args, env: d.env });
if (d.transport === "stdio") Object.assign(body.server, { command: d.command, args: d.args, env: d.env, shared: d.local ? null : d.shared || null });
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));
const was = s;
@@ -310,6 +310,9 @@ magpie.strings({
"{n} more not shown": "另有 {n} 个未显示",
"Save and sign in": "保存并登录",
"Use your own OAuth app": "使用自己的 OAuth 应用",
"Use another command on this computer": "在这台电脑上用另一条命令",
"Use the synced command": "用同步的命令",
"This computer's own, with its environment below. Your other computers run {cmd}": "这台电脑自己的命令,连同下面的环境变量。其他电脑运行 {cmd}",
"For a server whose sign-in doesn't let magpie register itself, as GitHub's": "用于不允许 magpie 自行注册的服务器登录,如 GitHub 的",
"Client ID": "客户端 ID",
"Client secret": "客户端密钥",
@@ -1320,6 +1323,9 @@ magpie.strings({
"{n} more not shown": "另有 {n} 個未顯示",
"Save and sign in": "儲存並登入",
"Use your own OAuth app": "使用自己的 OAuth 應用程式",
"Use another command on this computer": "在這台電腦上用另一條命令",
"Use the synced command": "用同步的命令",
"This computer's own, with its environment below. Your other computers run {cmd}": "這台電腦自己的命令,連同下方的環境變數。其他電腦執行 {cmd}",
"For a server whose sign-in doesn't let magpie register itself, as GitHub's": "用於不允許 magpie 自行註冊的伺服器登入,如 GitHub 的",
"Client ID": "用戶端 ID",
"Client secret": "用戶端密鑰",
@@ -2321,6 +2327,9 @@ magpie.strings({
"{n} more not shown": "ほか {n} 個は非表示",
"Save and sign in": "保存してサインイン",
"Use your own OAuth app": "自分の OAuth アプリを使う",
"Use another command on this computer": "このコンピュータでは別のコマンドを使う",
"Use the synced command": "同期したコマンドを使う",
"This computer's own, with its environment below. Your other computers run {cmd}": "このコンピュータ専用のコマンドと、下の環境変数です。ほかのコンピュータは {cmd} を実行します",
"For a server whose sign-in doesn't let magpie register itself, as GitHub's": "magpie が自身を登録できないサーバー(GitHub など)のサインイン用",
"Client ID": "クライアント ID",
"Client secret": "クライアントシークレット",
@@ -3327,6 +3336,9 @@ magpie.strings({
"{n} more not shown": "{n} weitere nicht angezeigt",
"Save and sign in": "Speichern und anmelden",
"Use your own OAuth app": "Eigene OAuth-App verwenden",
"Use another command on this computer": "Auf diesem Computer einen anderen Befehl verwenden",
"Use the synced command": "Den synchronisierten Befehl verwenden",
"This computer's own, with its environment below. Your other computers run {cmd}": "Nur für diesen Computer, mit der Umgebung darunter. Deine anderen Computer führen {cmd} aus",
"For a server whose sign-in doesn't let magpie register itself, as GitHub's": "Für einen Server, bei dessen Anmeldung sich magpie nicht selbst registrieren kann, wie bei GitHub",
"Client ID": "Client-ID",
"Client secret": "Client-Secret",
@@ -476,6 +476,8 @@ input.lib-setname:focus { border-color: var(--accent); box-shadow: 0 0 0 3px col
.lib-pair input:first-child { flex: .8; }
.lib-x { width: 24px; height: 24px; padding: 0; display: inline-grid; place-items: center; flex: none; }
.lib-addpair { padding-left: 0; }
.lib-cmdbox { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; }
.lib-cmdbox .lib-cmd { width: 100%; }
.lib-addpair:hover { background: none; }
.lib-editor .lib-picks { grid-column: 1 / -1; max-height: 320px; }
.lib-editor .lib-keep { grid-column: 1 / -1; margin: 0 -6px; }
+124
View File
@@ -0,0 +1,124 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// #3836, #6426 (jinpwng on X): one MCP server on a Mac and in WSL, each
// starting its own program. A synced command server's editor offers Use
// another command on this computer: the command line is then this
// computer's, the hint names what the other computers run, and the save
// sends that as shared. Use the synced command puts it back and sends no
// shared. A server kept to this computer has no such button. 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: "order-tools", transport: "stdio", command: "/Users/me/order-mcp", args: ["--config", "mac.yaml"], env: { TOKEN: "${ORDER_TOKEN}" }, agents: ["claude"] },
{ name: "kept", transport: "stdio", command: "/opt/kept", agents: ["claude"], local: true }],
};
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);
const i = lib.servers.findIndex((x) => x.name === old);
lib.servers[i] = { ...lib.servers[i], ...s };
if (!s.shared) delete lib.servers[i].shared;
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 + ": a synced MCP server's own command on 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);
const OWN = "Use another command on this computer", SYNCED = "Use the synced command", HINT = "This computer's own, with its environment below. Your other computers run {cmd}";
if (lang !== "en") for (const s of [OWN, SYNCED, HINT]) 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.setDefaultNavigationTimeout(60000);
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 rowOf = (n) => page.locator("#view-library .lib-server", { has: page.locator(`.lib-health[data-server="${n}"]`) });
const ed = page.locator("#modal .lib-editor");
const line = ed.locator(".lib-cmd");
const open = async (n) => { await rowOf(n).locator(".name").click(); await ed.waitFor(); };
const save = async () => { await ed.locator(":scope > .bar button.primary").click(); await ed.waitFor({ state: "detached" }); };
const synced = w(HINT, { cmd: "/Users/me/order-mcp --config mac.yaml" });
await rowOf("order-tools").waitFor();
// a synced command server offers its own command here
await open("order-tools");
await ed.getByRole("button", { name: w(OWN), exact: true }).click();
await ed.locator(".hint", { hasText: synced }).waitFor();
await line.fill("/opt/order-mcp --config /etc/ops.yaml");
await save();
assert.equal(calls.length, 1);
assert.equal(calls[0].command, "/opt/order-mcp");
assert.deepEqual(calls[0].args, ["--config", "/etc/ops.yaml"]);
assert.deepEqual(calls[0].shared, { command: "/Users/me/order-mcp", args: ["--config", "mac.yaml"], env: { TOKEN: "${ORDER_TOKEN}" } });
// opened again it says so, and saving keeps it
await open("order-tools");
await ed.locator(".hint", { hasText: synced }).waitFor();
assert.equal(await line.inputValue(), "/opt/order-mcp --config /etc/ops.yaml");
await save();
assert.deepEqual(calls[1].shared, calls[0].shared);
// back to the synced command
await open("order-tools");
await ed.getByRole("button", { name: w(SYNCED), exact: true }).click();
assert.equal(await line.inputValue(), "/Users/me/order-mcp --config mac.yaml");
assert.equal(await ed.locator(".hint", { hasText: synced }).count(), 0);
await save();
assert.equal(calls[2].shared, null);
assert.equal(calls[2].command, "/Users/me/order-mcp");
// a server kept to this computer has nothing synced to differ from
await open("kept");
assert.equal(await ed.getByRole("button", { name: w(OWN), exact: true }).count(), 0);
await ed.locator(":scope > .bar button", { hasText: w("Cancel") }).click();
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true, "no sideways scroll");
await ctx.close();
});
}
}
assert.deepEqual(errors, []);
});
}
+3 -1
View File
@@ -112,7 +112,9 @@ func Collect() (*Bundle, error) {
// 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
// magpie's own by name, each computer's own binary; a server
// started its own way here goes with the synced start (mcp_here.go)
c := *carried(carriedStart(s))
c.Agents = orNone(slices.Sorted(slices.Values(s.Agents)))
b.MCP = append(b.MCP, &c)
}
+16
View File
@@ -91,6 +91,12 @@ type Server struct {
// Discord: with many of them, which is which). Only the library keeps
// it, and a sync carries it; no agent is given it (TestNoteNeverGiven).
Note string `json:"note,omitempty"`
// Shared is set when this computer starts the server its own way
// (#3836, #6426; jinpwng on X: one server on a Mac and in WSL, each
// with its own path): Command, Args and Env are then this computer's,
// and Shared is what a sync carries and brings for them. Never carried
// itself (mcp_here.go).
Shared *Start `json:"shared,omitempty"`
// about is the hub entry's description, for an agent that shows a
// server by one before it has connected (Pi, hubServerFor)
@@ -154,6 +160,16 @@ func (s *Server) check() error {
default:
return fmt.Errorf("%s: unknown transport %q", s.Name, s.Transport)
}
// only a synced command server has a start of its own here
if s.Transport != "stdio" || s.Local {
s.Shared = nil
} else if s.Shared != nil {
s.Shared.Command = strings.TrimSpace(s.Shared.Command)
if s.Shared.Command == "" {
return fmt.Errorf("%s: the synced command is empty", s.Name)
}
s.Shared.Command, s.Shared.Args = spacedProgram(s.Shared.Command, s.Shared.Args)
}
switch s.Hub {
case "", "shared":
s.Hub = ""
+92
View File
@@ -0,0 +1,92 @@
package library
import (
"fmt"
"maps"
"slices"
)
// A synced command server can be started its own way on this computer
// (#3836, #6426; jinpwng on X: the same server on a Mac and in WSL, each
// with its own program path). Its name, agents, note and tools stay the
// one server every computer has; only how this computer starts it is its
// own.
//
// - Command, Args and Env are this computer's, so every reader (the
// agents' files, projects, the router, the check) runs what this
// computer runs with no change of its own.
// - Shared holds the synced start. Collect carries Shared in their place
// and never the field itself, so another computer gets what it had.
// - Put keeps this computer's start: what comes in for the server goes
// into Shared. A server that comes in as a URL takes the server back to
// what came in, since there is no command to start.
// - Turning it off puts the synced start back (ServerHere with none).
// Start is how a command server is started: its program, the program's
// arguments and its environment.
type Start struct {
Command string `json:"command"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
}
// startOf is a server's own start, copied.
func startOf(s *Server) *Start {
return &Start{Command: s.Command, Args: slices.Clone(s.Args), Env: maps.Clone(s.Env)}
}
// carriedStart is the server as a carried library has it: the synced
// start in place of this computer's own.
func carriedStart(s *Server) *Server {
c := *s
if s.Shared != nil {
c.Command, c.Args, c.Env = s.Shared.Command, slices.Clone(s.Shared.Args), maps.Clone(s.Shared.Env)
}
c.Shared = nil
return &c
}
// keepStart gives a server that came in this computer's own start, when
// this computer had one for the server by its name: what came in becomes
// the synced start.
func keepStart(c, here *Server) {
c.Shared = nil
if here == nil || here.Shared == nil || c.Transport != "stdio" {
return
}
c.Shared = startOf(c)
c.Command, c.Args, c.Env = here.Command, slices.Clone(here.Args), maps.Clone(here.Env)
}
// ServerHere starts a synced command server with cmd (a program and its
// arguments) on this computer alone, the other computers keeping the
// synced one; with no cmd it goes back to the synced one.
func ServerHere(name string, cmd []string) (*Result, error) {
return change(func(l *Library) error {
s := l.server(name)
switch {
case s == nil:
return fmt.Errorf("no server called %s", name)
case len(cmd) == 0:
if s.Shared != nil {
s.Command, s.Args, s.Env = s.Shared.Command, s.Shared.Args, s.Shared.Env
s.Shared = nil
}
return nil
case s.Transport != "stdio":
return fmt.Errorf("%s is reached by URL: only a command server is started its own way here", name)
case s.Local:
return fmt.Errorf("%s is kept to this computer already: its command is this computer's alone", name)
}
n := *s
if n.Shared == nil {
n.Shared = startOf(s)
}
n.Command, n.Args = cmd[0], slices.Clone(cmd[1:])
if err := n.check(); err != nil {
return err
}
*s = n
return nil
})
}
+97
View File
@@ -0,0 +1,97 @@
package library
import (
"path/filepath"
"strings"
"testing"
)
// TestServerHereThroughSync: one server on a Mac and in WSL (#3836, #6426,
// jinpwng on X). This computer runs its own program; its note, agents and
// the other computer's command still come and go with a sync, and what
// this computer carries is the other computer's command, never its own.
func TestServerHereThroughSync(t *testing.T) {
sandbox(t)
ok(t)(SaveServer("", Server{Name: "order-tools", Transport: "stdio", Command: "/Users/me/order-mcp", Args: []string{"--config", "mac.yaml"}, Agents: []string{"claude"}, Note: "orders"}))
mac := carry(t)
h := sandbox(t)
ok(t)(Put(&mac))
ok(t)(ServerHere("order-tools", []string{"/opt/order-mcp", "--config", "/etc/ops.yaml"}))
s := serverIn(t, "order-tools")
if s.Command != "/opt/order-mcp" || s.Shared == nil || s.Shared.Command != "/Users/me/order-mcp" {
t.Fatalf("after its own command here: %+v", s)
}
if c := read(t, filepath.Join(h, ".claude.json")); !strings.Contains(c, "/opt/order-mcp") || strings.Contains(c, "/Users/me") {
t.Fatalf("Claude Code was given %s", c)
}
b := carry(t)
if len(b.MCP) != 1 || b.MCP[0].Command != "/Users/me/order-mcp" || strings.Join(b.MCP[0].Args, " ") != "--config mac.yaml" || b.MCP[0].Shared != nil {
t.Fatalf("carried %s", mustJSON(t, b))
}
if j := mustJSON(t, b); strings.Contains(j, "/opt/") || strings.Contains(j, `"shared"`) {
t.Fatalf("this computer's own command was carried: %s", j)
}
if got, want := mustJSON(t, b), mustJSON(t, mac); got != want {
t.Fatalf("what this computer carries isn't what came in:\n%s\n%s", want, got)
}
// the Mac changes the note and its own path; this computer keeps its own
mac.MCP[0].Note, mac.MCP[0].Command = "orders, read only", "/Users/me/bin/order-mcp"
ok(t)(Put(&mac))
s = serverIn(t, "order-tools")
if s.Note != "orders, read only" || s.Command != "/opt/order-mcp" || s.Shared == nil || s.Shared.Command != "/Users/me/bin/order-mcp" {
t.Fatalf("after the Mac's change came in: %+v %+v", s, s.Shared)
}
// an edit here, as the editor sends it, keeps the synced command
n := *s
n.Agents = []string{"claude", "codex"}
ok(t)(SaveServer("order-tools", n))
if b := carry(t); b.MCP[0].Command != "/Users/me/bin/order-mcp" || len(b.MCP[0].Agents) != 2 {
t.Fatalf("carried after an edit here: %s", mustJSON(t, b))
}
if c := read(t, filepath.Join(h, ".codex/config.toml")); !strings.Contains(c, "/opt/order-mcp") {
t.Fatalf("Codex was given %s", c)
}
// back to the synced one
ok(t)(ServerHere("order-tools", nil))
if s := serverIn(t, "order-tools"); s.Command != "/Users/me/bin/order-mcp" || s.Shared != nil || strings.Join(s.Args, " ") != "--config mac.yaml" {
t.Fatalf("after going back to the synced command: %+v", s)
}
}
// TestServerHereEnds: the editor sending no synced command, the server
// kept to this computer, or one that comes in as a URL each end this
// computer's own command.
func TestServerHereEnds(t *testing.T) {
sandbox(t)
ok(t)(SaveServer("", Server{Name: "db", Transport: "stdio", Command: "their-db", Agents: []string{"claude"}}))
theirs := carry(t)
ok(t)(ServerHere("db", []string{"my-db"}))
n := *serverIn(t, "db")
n.Shared = nil
ok(t)(SaveServer("db", n))
if b := carry(t); b.MCP[0].Command != "my-db" {
t.Fatalf("the editor turned it off, yet carried %s", mustJSON(t, b))
}
ok(t)(ServerHere("db", []string{"mine"}))
ok(t)(ServerLocal("db", true))
if s := serverIn(t, "db"); s.Shared != nil || s.Command != "mine" {
t.Fatalf("kept to this computer: %+v", s)
}
ok(t)(ServerLocal("db", false))
ok(t)(ServerHere("db", []string{"mine"}))
url := theirs
url.MCP = []*Server{{Name: "db", Transport: "http", URL: "https://db.example/mcp", Agents: []string{"claude"}}}
ok(t)(Put(&url))
if s := serverIn(t, "db"); s.Shared != nil || s.URL != "https://db.example/mcp" || s.Command != "" {
t.Fatalf("after a URL came in: %+v", s)
}
if _, err := ServerHere("db", []string{"mine"}); err == nil {
t.Fatal("a URL server took a command of its own")
}
}
+8
View File
@@ -41,7 +41,9 @@ func (l *Library) carriedServers() []*Server {
func (l *Library) putServers(in []*Server) {
own := map[string]bool{}
servers := []*Server{}
here := map[string]*Server{}
for _, s := range l.MCP {
here[s.Name] = s
if s.Local {
own[s.Name] = true
servers = append(servers, s)
@@ -53,6 +55,9 @@ func (l *Library) putServers(in []*Server) {
c.Local = false // only this computer says what is its own
c.Bridge = "" // and which of its providers a server is
c.Agents = slices.Sorted(slices.Values(orNone(s.Agents)))
// this computer's own start stays, what came in its synced one
// (mcp_here.go)
keepStart(&c, here[c.Name])
if own[c.Name] {
l.Away = append(l.Away, &c)
} else {
@@ -90,6 +95,9 @@ func ServerLocal(name string, on bool) (*Result, error) {
return fmt.Errorf("no server called %s", name)
}
s.Local = on
if on {
s.Shared = nil // its command is this computer's alone now
}
return nil
})
}
+4
View File
@@ -434,6 +434,10 @@ func saveServer(old *library.Server, line string) tea.Cmd {
// and whether it is kept to this computer, and out of the hub,
// and the user's note on it
s.Agents, s.Env, s.Headers, s.OAuth, s.StartupTimeout, s.Local, s.Hub, s.Note = old.Agents, old.Env, old.Headers, old.OAuth, old.StartupTimeout, old.Local, old.Hub, old.Note
// and the synced command, when this computer runs its own
// (the line typed is this computer's then; check drops it
// for a URL)
s.Shared = old.Shared
}
return libCmd(func() (*library.Result, error) { return library.SaveServer(was, s) }, done)()
}
+1
View File
@@ -207,6 +207,7 @@ magpie library sync # エージェントに書き直す</pre>
<li><b>ツールごとのオフ。</b>Codex、Gemini CLI、Crush、Hermes Agent、Claude Code、OpenCode では、ツールを 1 つずつオフにでき、それぞれの設定に書かれます。ほかのエージェントにはサーバー全体が渡ります。</li>
<li><b>サインイン。</b>OAuth が必要なサーバーは magpie で一度だけサインインします。エージェントは magpie のゲートウェイの <code>/mcp/&lt;name&gt;</code> 経由で使います。</li>
<li><b>このコンピュータだけ。</b>ここに置いておくサーバーは <span class="ui">ほかのコンピュータと同期</span> をオフにします(<code>magpie library mcp local &lt;name&gt; on</code>)。</li>
<li><b>ここでは別のコマンド。</b>同期したサーバーのプログラムがこのコンピュータでは別の場所にある(Mac と WSL など)ときは、コマンドの下の <span class="ui">このコンピュータでは別のコマンドを使う</span> をクリックします。名前、エージェント、メモはそのまま同期され、ほかのコンピュータは自分のコマンドを実行し続けます(<code>magpie library mcp here &lt;name&gt; &lt;コマンド…&gt;</code>)。</li>
</ul>
<p><a href="/docs/ja/mcp-router">MCP ルーター</a> をオンにすると、各エージェントにはこれらのエントリの代わりに <code>magpie</code> という 1 つのサーバーが渡り、コマンドのサーバーは magpie がすべてのエージェントのために 1 回だけ動かします。既定ではオフです。</p>
+1
View File
@@ -207,6 +207,7 @@ magpie library sync # write it into the agents again</pre>
<li><b>Single tools off.</b> You can turn off tools one by one for Codex, Gemini CLI, Crush, Hermes Agent, Claude Code and OpenCode, each in its own setting. Every other agent gets the whole server.</li>
<li><b>Sign-in.</b> A server that needs OAuth is signed in to once, in magpie. Agents then reach it through magpie’s gateway at <code>/mcp/&lt;name&gt;</code>.</li>
<li><b>This computer only.</b> Turn off <span class="ui">Sync to your other computers</span> for a server that should stay here (<code>magpie library mcp local &lt;name&gt; on</code>).</li>
<li><b>Another command here.</b> For a synced server whose program sits elsewhere on this computer (a Mac and WSL), click <span class="ui">Use another command on this computer</span> under its command. Its name, agents and note still sync; your other computers keep running theirs (<code>magpie library mcp here &lt;name&gt; &lt;command…&gt;</code>).</li>
</ul>
<p>With the <a href="/docs/mcp-router">MCP router</a> on, each agent gets one server named <code>magpie</code> in place of these entries, and magpie runs each command server once for all of them. It is off by default.</p>
+1
View File
@@ -207,6 +207,7 @@ magpie library sync # 重新写进各个 Agent</pre>
<li><b>单独关掉工具。</b>Codex、Gemini CLI、Crush、Hermes Agent、Claude Code 和 OpenCode 可以逐个关掉工具,各自写进自己的设置。其他 Agent 拿到的是整个服务器。</li>
<li><b>登录。</b>需要 OAuth 的服务器只在 magpie 里登录一次,之后 Agent 通过 magpie 网关的 <code>/mcp/&lt;name&gt;</code> 访问它。</li>
<li><b>只在这台电脑。</b>不想同步到别处的服务器,关掉 <span class="ui">同步到其他电脑</span>(<code>magpie library mcp local &lt;name&gt; on</code>)。</li>
<li><b>这台电脑用另一条命令。</b>同步的服务器在这台电脑上的程序路径不同(比如 Mac 和 WSL),点命令下方的 <span class="ui">在这台电脑上用另一条命令</span>。名称、Agent 和备注照常同步,其他电脑仍运行它们自己的命令(<code>magpie library mcp here &lt;name&gt; &lt;命令…&gt;</code>)。</li>
</ul>
<p>打开 <a href="/docs/zh/mcp-router">MCP 路由</a> 后,每个 Agent 只拿到一个名为 <code>magpie</code> 的服务器来代替这些条目,命令型服务器由 magpie 为所有 Agent 只运行一份。它默认关闭。</p>