library: the MCP servers an agent's app writes into its config itself (Codex's node_repl and cua_repl, run from inside its install) are told apart — not offered to bring in, shown as the agent's own and left as they are; magpie library lists what agents have that the library doesn't
This commit is contained in:
@@ -142,6 +142,7 @@ const I18N = {
|
||||
"Local servers need no key": "本地服务无需密钥",
|
||||
"Open the row and paste an API key": "展开这一行并粘贴 API 密钥",
|
||||
"{agent} is signed in, but stays out of this list. ": "{agent} 已登录,但不在此列表中。",
|
||||
"{agents} adds these itself, each time it starts, and magpie leaves them as they are: {names}": "{agents} 每次启动都会自己加上这些,magpie 不去动它们:{names}",
|
||||
"{agent}'s saved accounts aren't offered. ": "{agent} 保存的账号没有提供出来。",
|
||||
"signed in": "已登录",
|
||||
"{p} exposes no models yet — pick some below": "{p} 尚未暴露模型 — 在下方选几个",
|
||||
|
||||
@@ -442,14 +442,21 @@
|
||||
after.append(button(t("+ Add server"), "", () => editServer(null)));
|
||||
body.append(after);
|
||||
}
|
||||
if (lib.foundServers.length) {
|
||||
const found = lib.foundServers.filter((f) => !f.own), own = lib.foundServers.filter((f) => f.own);
|
||||
if (found.length) {
|
||||
const rh = el("div", "row-head");
|
||||
rh.append(el("span", "label", t("In your agents")), el("span", "grow"), el("span", "note", t("not in the library — bring one in to manage it here")));
|
||||
body.append(rh);
|
||||
const list = el("div", "list lib-list");
|
||||
for (const f of lib.foundServers) list.append(foundServerRow(f));
|
||||
for (const f of found) list.append(foundServerRow(f));
|
||||
body.append(list);
|
||||
}
|
||||
if (own.length) {
|
||||
const by = [...new Set(own.flatMap((f) => f.server.agents))].map(nameOf).join(", ");
|
||||
const p = el("p", "lib-aside", t("{agents} adds these itself, each time it starts, and magpie leaves them as they are: {names}", { agents: by, names: own.map((f) => f.server.name).join(", ") }));
|
||||
p.title = own.map((f) => f.server.name + ": " + serverLine(f.server)).join("\n");
|
||||
body.append(p);
|
||||
}
|
||||
const skip = shownAgents().filter((a) => !a.mcp);
|
||||
if (skip.length) body.append(el("p", "lib-aside", t("{agents} has no MCP servers magpie can write.", { agents: skip.map((a) => a.name).join(", ") })));
|
||||
body.append(discover("mcp"));
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"encoding/json"
|
||||
"maps"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
@@ -706,3 +707,34 @@ func TestClaudeDesktopMCP(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The servers Codex's app writes into its config itself are told apart:
|
||||
// its own, not ones to bring in.
|
||||
func TestFoundServersAppOwned(t *testing.T) {
|
||||
h := sandbox(t)
|
||||
write(t, filepath.Join(h, ".codex/config.toml"), `[mcp_servers.node_repl]
|
||||
command = 'C:\Users\u\AppData\Local\OpenAI\Codex\runtimes\cua_node\1.0\node_repl.exe'
|
||||
|
||||
[mcp_servers.cua_repl]
|
||||
command = 'C:\Program Files\WindowsApps\OpenAI.Codex_1.0_x64\ChatGPT.exe'
|
||||
enabled = false
|
||||
|
||||
[mcp_servers.computer-use]
|
||||
command = "./Codex Computer Use.app/Contents/SharedSupport/SkyComputerUseClient.app/Contents/MacOS/SkyComputerUseClient"
|
||||
|
||||
[mcp_servers.gh]
|
||||
command = "gh-mcp"
|
||||
`)
|
||||
v, err := Read(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
own := map[string]bool{}
|
||||
for _, f := range v.FoundServers {
|
||||
own[f.Server.Name] = f.Own
|
||||
}
|
||||
want := map[string]bool{"node_repl": true, "cua_repl": true, "computer-use": true, "gh": false}
|
||||
if !maps.Equal(own, want) {
|
||||
t.Errorf("own: %v, want %v", own, want)
|
||||
}
|
||||
}
|
||||
|
||||
+21
-1
@@ -599,6 +599,26 @@ type Found struct {
|
||||
Server *Server `json:"server"`
|
||||
Others []string `json:"others,omitempty"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
// Own: the agent's app puts it there itself, each time it starts
|
||||
// (Codex's node_repl and cua_repl): it isn't one to bring in, and
|
||||
// taking it out doesn't last.
|
||||
Own bool `json:"own,omitempty"`
|
||||
}
|
||||
|
||||
// appOwned is whether a server runs from inside an app's own install — a
|
||||
// Mac app bundle, a Microsoft Store app, the Codex app's runtimes — as the
|
||||
// servers an agent's app writes into its config itself do.
|
||||
func appOwned(s *Server) bool {
|
||||
if s.Remote() {
|
||||
return false
|
||||
}
|
||||
cmd := strings.ToLower(strings.ReplaceAll(s.Command, `\`, "/"))
|
||||
for _, in := range []string{".app/contents/", "/windowsapps/", "/cua_node/", "/openai/codex/runtimes/"} {
|
||||
if strings.Contains(cmd, in) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func foundServers(l *Library) []Found {
|
||||
@@ -621,7 +641,7 @@ func foundServers(l *Library) []Found {
|
||||
switch {
|
||||
case f == nil:
|
||||
s.Agents = []string{t.Agent.ID}
|
||||
byName[name] = &Found{Server: s}
|
||||
byName[name] = &Found{Server: s, Own: appOwned(s)}
|
||||
names = append(names, name)
|
||||
case f.Server.same(s):
|
||||
f.Server.Agents = append(f.Server.Agents, t.Agent.ID)
|
||||
|
||||
@@ -187,6 +187,20 @@ func libraryStatus() error {
|
||||
fmt.Println(" ", amber.Render("!"), a, muted.Render(e))
|
||||
}
|
||||
}
|
||||
var found, own []string
|
||||
for _, f := range v.FoundServers {
|
||||
if f.Own {
|
||||
own = append(own, f.Server.Name+muted.Render(" ("+strings.Join(f.Server.Agents, ", ")+"'s own)"))
|
||||
} else {
|
||||
found = append(found, f.Server.Name+muted.Render(" ("+strings.Join(f.Server.Agents, ", ")+")"))
|
||||
}
|
||||
}
|
||||
if len(found) > 0 {
|
||||
fmt.Println(" ", muted.Render("in your agents, not in the library:"), strings.Join(found, ", "))
|
||||
}
|
||||
if len(own) > 0 {
|
||||
fmt.Println(" ", muted.Render("added by the agent itself, left as they are:"), strings.Join(own, ", "))
|
||||
}
|
||||
fmt.Println(bold.Render("Skills"))
|
||||
if len(v.Skills) == 0 {
|
||||
fmt.Println(" ", muted.Render("none yet"))
|
||||
|
||||
Reference in New Issue
Block a user