library: another app's MCP server in an agent's config is offered to bring in, not taken for the agent's own (#2635)
iomect's Codex server, written in ~/.codex/config.toml as
[mcp_servers.netcatty-external]
command = "/Applications/Netcatty.app/Contents/Resources/app.asar.unpacked/electron/cli/netcatty-external-mcp"
args = []
env = { NETCATTY_EXTERNAL_MCP_DISCOVERY_FILE = "…" }
never showed under the Library's servers found in agents. The TOML was
read correctly; the cause was appOwned. It marked any command under a
".app/Contents/" as one the agent's app writes itself (Codex's node_repl
and cua_repl, 0f9d60db0). The page leaves such servers out of the list to
bring in (client.js: foundServers.filter(f => !f.own)).
appOwned now takes the agent and counts only the agent's own install:
an .app bundle or WindowsApps package whose name has the agent's id or
name in it (Codex.app, "Codex Computer Use.app", OpenAI.Codex_…), plus
Codex's runtimes and cua_node folders for Codex. Netcatty.app in Codex's
config is now a found server like any other.
TestFoundServerFromAnotherApp uses the reporter's TOML as given, with the
**** placeholder in the path. It checks the found entry's command, empty
args, inline env and agent, and that Codex.app's computer-use is still
Codex's own. The existing TestFoundServersAppOwned and
TestRemoveFoundServerOwn pass unchanged.
I put the old ".app/contents/" match back by hand and
TestFoundServerFromAnotherApp went red (netcatty-external Own: true).
The issue's second part, imported skills not following an app update
(ego lite's Versions/0.5.0.13 -> 0.6.0.12), isn't in this commit.
ImportSkill links the library to the found skill's fully resolved path
(f.real). Whether ego links into Versions/Current or rewrites a
versioned link on update isn't known yet, so the issue asks the
reporter, and stays open.
Run: gofmt -l clean; go vet ./... (darwin), GOOS=linux and GOOS=windows
go vet -tags nogui ./... clean; go test -timeout 45m ./... at 7154fe61c, set -o pipefail: 66 packages ok, exit 0 (internal/library 372s under load ~280; internal/gateway cached from the run for d4a1b9baa, same code). No GUI files touched.
This commit is contained in:
@@ -1209,6 +1209,45 @@ command = "gh-mcp"
|
||||
}
|
||||
}
|
||||
|
||||
// Another app's server in Codex's config, run from inside that app's
|
||||
// bundle, is one to bring in, its empty args and inline env table read as
|
||||
// they are (iomect's #2635, the TOML as the report gave it). Only the
|
||||
// agent's own app's servers are its own.
|
||||
func TestFoundServerFromAnotherApp(t *testing.T) {
|
||||
h := sandbox(t)
|
||||
write(t, filepath.Join(h, ".codex/config.toml"), `[mcp_servers.netcatty-external]
|
||||
command = "/Applications/Netcatty.app/Contents/Resources/app.asar.unpacked/electron/cli/netcatty-external-mcp"
|
||||
args = []
|
||||
env = { NETCATTY_EXTERNAL_MCP_DISCOVERY_FILE = "/Users/****/Library/Application Support/netcatty/external-mcp/discovery.json" }
|
||||
|
||||
[mcp_servers.computer-use]
|
||||
command = "/Applications/Codex.app/Contents/Resources/SkyComputerUseClient"
|
||||
`)
|
||||
v, err := Read(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var got *Found
|
||||
own := map[string]bool{}
|
||||
for i, f := range v.FoundServers {
|
||||
own[f.Server.Name] = f.Own
|
||||
if f.Server.Name == "netcatty-external" {
|
||||
got = &v.FoundServers[i]
|
||||
}
|
||||
}
|
||||
if got == nil || got.Own {
|
||||
t.Fatalf("netcatty-external found as %+v; own %v", got, own)
|
||||
}
|
||||
s := got.Server
|
||||
if s.Command != "/Applications/Netcatty.app/Contents/Resources/app.asar.unpacked/electron/cli/netcatty-external-mcp" || len(s.Args) != 0 ||
|
||||
s.Env["NETCATTY_EXTERNAL_MCP_DISCOVERY_FILE"] != "/Users/****/Library/Application Support/netcatty/external-mcp/discovery.json" || !slices.Contains(s.Agents, "codex") {
|
||||
t.Errorf("netcatty-external read as %+v", s)
|
||||
}
|
||||
if !own["computer-use"] {
|
||||
t.Errorf("the Codex app's own server isn't its own: %v", own)
|
||||
}
|
||||
}
|
||||
|
||||
// TestInstructionSets: several sets are kept, one is on, and the agents
|
||||
// read that one; switching rewrites their files (#106).
|
||||
func TestInstructionSets(t *testing.T) {
|
||||
|
||||
+32
-9
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/tidwall/jsonc"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/yetone/magpie/internal/agent"
|
||||
"github.com/yetone/magpie/internal/edit"
|
||||
"github.com/yetone/magpie/internal/filememo"
|
||||
"github.com/yetone/magpie/internal/imagemcp"
|
||||
@@ -1333,17 +1334,39 @@ type Found struct {
|
||||
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() {
|
||||
// appOwned is whether a server runs from inside the agent's own app
|
||||
// install — its Mac app bundle, its Microsoft Store app, the Codex app's
|
||||
// runtimes — as the servers an agent's app writes into its config itself
|
||||
// do. Another app's server in the agent's config (Netcatty's, #2635) is
|
||||
// one the user added there: it is brought in like any other.
|
||||
func appOwned(s *Server, a *agent.Agent) bool {
|
||||
if s.Remote() || a == nil {
|
||||
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
|
||||
if a.ID == "codex" && (strings.Contains(cmd, "/cua_node/") || strings.Contains(cmd, "/openai/codex/runtimes/")) {
|
||||
return true
|
||||
}
|
||||
names := []string{strings.ToLower(a.ID), strings.ToLower(a.Name)}
|
||||
if id, _, ok := strings.Cut(names[0], "-"); ok {
|
||||
names = append(names, id)
|
||||
}
|
||||
if n, _, ok := strings.Cut(names[1], " "); ok {
|
||||
names = append(names, n)
|
||||
}
|
||||
segs := strings.Split(cmd, "/")
|
||||
for i, seg := range segs {
|
||||
// an app is a bundle (Codex.app) or a Store package
|
||||
// (WindowsApps/OpenAI.Codex_1.0_x64) the command is inside
|
||||
app := strings.HasSuffix(seg, ".app") && i+1 < len(segs) && segs[i+1] == "contents"
|
||||
app = app || (i > 0 && segs[i-1] == "windowsapps" && i+1 < len(segs))
|
||||
if !app {
|
||||
continue
|
||||
}
|
||||
for _, n := range names {
|
||||
if n != "" && strings.Contains(seg, n) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
@@ -1372,7 +1395,7 @@ func foundServersOf(l *Library, targets []*Target) []Found {
|
||||
switch {
|
||||
case f == nil:
|
||||
s.Agents = []string{t.Agent.ID}
|
||||
byName[name] = &Found{Server: s, Own: appOwned(s)}
|
||||
byName[name] = &Found{Server: s, Own: appOwned(s, t.Agent)}
|
||||
names = append(names, name)
|
||||
case f.Server.same(s):
|
||||
f.Server.Agents = append(f.Server.Agents, t.Agent.ID)
|
||||
|
||||
Reference in New Issue
Block a user