Skip to content

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

library: `magpie library mcp add` without agents= says the server went to no agent

yetonefba554c7f886
diff --git a/internal/cli/library_cli.go b/internal/cli/library_cli.go
index ac219534a..dff889765 100644
--- a/internal/cli/library_cli.go
+++ b/internal/cli/library_cli.go
@@ -46,8 +46,9 @@ func libraryCmd(args []string) error {
return libraryStatus()
}
var (
- res *library.Result
- err error
+ res *library.Result
+ err error
+ unused string // a server just added that no agent is given
)
switch sub, rest := args[1], args[2:]; sub {
case "sync":
@@ -106,6 +107,9 @@ func libraryCmd(args []string) error {
s.Agents = agents
}
res, err = library.SaveServer("", s)
+ if len(s.Agents) == 0 {
+ unused = s.Name
+ }
case len(rest) == 3 && rest[0] == "agents":
var as []string
if as, err = libraryAgents(rest[2], "mcp"); err == nil {
@@ -180,6 +184,13 @@ func libraryCmd(args []string) error {
if err != nil {
return err
}
+ if unused != "" && len(res.Changed) == 0 && len(res.Problems) == 0 {
+ // a server added with no agents= is given to none, which isn't
+ // every agent having it already
+ fmt.Println(green.Render("✓"), unused, "is in the library, given to no agent yet")
+ fmt.Println(muted.Render(" magpie library mcp agents " + unused + " <a,b…> gives it to them"))
+ return nil
+ }
printLibraryResult(res)
return nil
}
diff --git a/internal/cli/library_rm_all_test.go b/internal/cli/library_rm_all_test.go
index f72e45da6..3c734544d 100644
--- a/internal/cli/library_rm_all_test.go
+++ b/internal/cli/library_rm_all_test.go
@@ -1,6 +1,7 @@
package cli
import (
+ "io"
"os"
"path/filepath"
"strings"
@@ -63,3 +64,49 @@ func TestLibrarySkillRmAll(t *testing.T) {
t.Errorf("an empty library: %v", err)
}
}
+
+// magpie library mcp add without agents= gives the server to no agent,
+// and says so: it said "every agent already has it" (found writing the
+// magpie-setup skill). With agents= it names the agents written into.
+func TestLibraryMCPAddNoAgents(t *testing.T) {
+ h := t.TempDir()
+ for k, v := range map[string]string{"HOME": h, "USERPROFILE": h, "XDG_CONFIG_HOME": filepath.Join(h, ".config"), "CLAUDE_CONFIG_DIR": "", "CODEX_HOME": "", "APPDATA": "", "LOCALAPPDATA": ""} {
+ t.Setenv(k, v)
+ }
+ if err := os.MkdirAll(filepath.Join(h, ".claude"), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(filepath.Join(h, ".claude/settings.json"), []byte("{}"), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ out := func(args ...string) string {
+ t.Helper()
+ r, w, err := os.Pipe()
+ if err != nil {
+ t.Fatal(err)
+ }
+ old := os.Stdout
+ os.Stdout = w
+ done := make(chan string)
+ go func() { b, _ := io.ReadAll(r); done <- string(b) }()
+ err = libraryCmd(append([]string{"library", "mcp"}, args...))
+ w.Close()
+ os.Stdout = old
+ s := <-done
+ r.Close()
+ if err != nil {
+ t.Fatalf("library mcp %v: %v", args, err)
+ }
+ return s
+ }
+ got := out("add", "ctx7", "https://mcp.example.com/mcp")
+ if strings.Contains(got, "every agent") || !strings.Contains(got, "given to no agent yet") || !strings.Contains(got, "magpie library mcp agents ctx7") {
+ t.Fatalf("added to none: %q", got)
+ }
+ if got := out("agents", "ctx7", "claude"); !strings.Contains(got, "written into claude") {
+ t.Fatalf("given to claude: %q", got)
+ }
+ if got := out("add", "other", "https://mcp.example.com/other", "agents=claude"); !strings.Contains(got, "written into claude") {
+ t.Fatalf("added to claude: %q", got)
+ }
+}