The owner: both markets have too little in them. With nothing searched, the MCP market offered only its 31 featured servers. A search asked the MCP Registry and kept at most 30 of its results. What changed: - market_servers.json is a snapshot of the registry, crawled 2026-11-01: 54,048 latest entries and the GitHub stars of their 27,816 repositories. It keeps the 500 most starred servers that can be installed: an https remote, or an npm/pypi/oci stdio package with no required named argument left blank. At most 3 come from one repository. Smithery's re-hosts, inactive entries and entries with no description are left out. - A name has to belong to the repository it points to. io.github.<owner>/ matches the repository's owner, and a domain name's main label is in the repository's path. That drops name squatters pointing at famous repos (IncorporatedPartners → paperclip, secforge → ChromeDevTools, ai.com.mcp → agentskills). Past that, star order is the only rule. - After the featured servers and their copies, 478 remain. Browsing offers featured, then these by stars: 509 in all. Show more pages them 60 at a time (df0320156). - A search keeps up to 100 of the registry's results, not 30. Popular servers that match the words come after them, and for an address search they come before the registry's. A server is offered once. - A popular server installs by its id with no registry call (marketServer), and its icon is offered like a featured one. Run at f79c0994e (origin/mainace58117aplus this), on mote: - gofmt -l internal/library: clean. go vet ./internal/library: ok. - go test -count=1 ./internal/library: ok (133s); ./internal/gui: ok. - GUI: i18n-keys, market-*, library-mcp-*, search-mcp-library, images-library-way and vision-mcp-library: 280 of 284. - The 4 reds are search-mcp-library's WebKit 420px "Turn on the Library" cases, TimeoutError, at load 145 to 220, a different language each run. This change touches no GUI asset, so the page is main's. - They are #4756 (comment with this run). The same file passed 62/62 at77e853588. images-library-way and vision-mcp-library pass alone. Broken by hand, each red in TestMarketServersPopular: - no popular servers when browsing; - the cap back at 30; - a popular server not installable by id; - popular matches put before the registry's in a word search; - featured not seeded into the snapshot's dedupe (caught by the marketServer("io.github.feat/copy") check); - a popular icon not offered. Real servers: - the tldraw and frontend-checklist remotes answered initialize; - worldmonitor answered 401 (it needs a sign-in); - on mote, npx -y @agent-infra/mcp-server-commands answered initialize as "Run Commands". Not tried: - installing a popular server from the GUI in the real app; - a fresh crawl. Stars are a snapshot, and crawl.py/build.py are not in the repo.
127 lines
4.7 KiB
Go
127 lines
4.7 KiB
Go
package library
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"slices"
|
|
"strings"
|
|
"sync/atomic"
|
|
"testing"
|
|
)
|
|
|
|
// The owner: the MCP market had too little in it. Before anything is
|
|
// searched it offers the featured servers and then the registry's most
|
|
// starred (a snapshot shipped with magpie, the registry not asked); one a
|
|
// featured server already is, two that start the same package, and one
|
|
// magpie can't fill in are offered once or not at all. A word search gets
|
|
// the registry's ranked results first, then the popular ones whose words
|
|
// have it, and up to 100 of the registry's, not 30.
|
|
func TestMarketServersPopular(t *testing.T) {
|
|
sandbox(t)
|
|
i := slices.IndexFunc(featured, func(m MarketServer) bool { return m.server.Remote() })
|
|
if i < 0 {
|
|
t.Fatal("no featured remote")
|
|
}
|
|
entries := []string{
|
|
`{"name":"io.github.big/one","title":"Big One","description":"Reads files on disk.","icons":[{"src":"https://big.dev/i.png"}],"packages":[{"registryType":"npm","identifier":"@big/one"}]}`,
|
|
`{"name":"io.github.big/again","description":"The same package.","packages":[{"registryType":"npm","identifier":"@big/one"}]}`,
|
|
`{"name":"io.github.feat/copy","description":"A featured one.","remotes":[{"type":"streamable-http","url":"` + featured[i].server.URL + `"}]}`,
|
|
`{"name":"io.github.x/named","description":"Needs a named argument.","packages":[{"registryType":"npm","identifier":"x-named","packageArguments":[{"type":"named","name":"--root","isRequired":true}]}]}`,
|
|
}
|
|
for i := range 130 {
|
|
entries = append(entries, fmt.Sprintf(`{"name":"io.github.o%d/m%d","description":"Server %d.","packages":[{"registryType":"npm","identifier":"m%d-pkg"}]}`, i, i, i, i))
|
|
}
|
|
was := popularServers
|
|
popularServers = func() []MarketServer { return readPopular([]byte("[" + strings.Join(entries, ",") + "]")) }
|
|
t.Cleanup(func() { popularServers = was })
|
|
|
|
var asked atomic.Int32
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
asked.Add(1)
|
|
var list []string
|
|
switch r.URL.Query().Get("search") {
|
|
case "files":
|
|
list = append(list, `{"server":{"name":"io.github.reg/files","title":"files","remotes":[{"type":"streamable-http","url":"https://reg.dev/mcp"}]}}`)
|
|
case "many":
|
|
for i := range 150 {
|
|
list = append(list, fmt.Sprintf(`{"server":{"name":"io.github.r%d/many%d","remotes":[{"type":"streamable-http","url":"https://r%d.dev/mcp"}]}}`, i, i, i))
|
|
}
|
|
}
|
|
w.Write([]byte(`{"servers":[` + strings.Join(list, ",") + `]}`))
|
|
}))
|
|
defer srv.Close()
|
|
wasURL := registryURL
|
|
registryURL = srv.URL
|
|
t.Cleanup(func() { registryURL = wasURL })
|
|
|
|
ids := func(list []MarketServer) []string {
|
|
var out []string
|
|
for _, m := range list {
|
|
out = append(out, m.ID)
|
|
}
|
|
return out
|
|
}
|
|
|
|
all, err := MarketServers("")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
got := ids(all)
|
|
if len(got) != len(featured)+131 || asked.Load() != 0 {
|
|
t.Fatalf("%d offered (want %d), registry asked %d times", len(got), len(featured)+131, asked.Load())
|
|
}
|
|
for i, m := range featured {
|
|
if got[i] != m.ID {
|
|
t.Fatalf("%d: %s, want featured %s", i, got[i], m.ID)
|
|
}
|
|
}
|
|
if got[len(featured)] != "io.github.big/one" || got[len(featured)+1] != "io.github.o0/m0" || got[len(got)-1] != "io.github.o129/m129" {
|
|
t.Fatalf("popular order: %v", got[len(featured):])
|
|
}
|
|
for _, id := range []string{"io.github.big/again", "io.github.feat/copy", "io.github.x/named"} {
|
|
if slices.Contains(got, id) {
|
|
t.Fatalf("%s offered: %v", id, got)
|
|
}
|
|
}
|
|
// nor kept to be installed by its id
|
|
if _, ok := marketServer("io.github.feat/copy"); ok {
|
|
t.Fatal("a featured one's copy is kept")
|
|
}
|
|
// a popular one is installed by its id, and its icon is fetched
|
|
if m, ok := marketServer("io.github.o5/m5"); !ok || m.Runs != "npx" {
|
|
t.Fatalf("by id: %+v %v", m, ok)
|
|
}
|
|
if !offered("https://big.dev/i.png") {
|
|
t.Fatal("popular icon not offered")
|
|
}
|
|
|
|
found, _ := MarketServers("files")
|
|
got = ids(found)
|
|
r, p := slices.Index(got, "io.github.reg/files"), slices.Index(got, "io.github.big/one")
|
|
if r < 0 || p < 0 || r > p || slices.Contains(got, "io.github.o0/m0") {
|
|
t.Fatalf("files: %v", got)
|
|
}
|
|
|
|
if found, _ := MarketServers("many"); len(found) != 100 {
|
|
t.Fatalf("many: %d offered, want 100", len(found))
|
|
}
|
|
}
|
|
|
|
// What magpie ships: hundreds of the registry's servers, each one magpie
|
|
// can add, none a Smithery wrapper, and none twice.
|
|
func TestPopularServersSnapshot(t *testing.T) {
|
|
list := readPopular(serversSnapshot)
|
|
t.Logf("%d popular servers", len(list))
|
|
if len(list) < 300 {
|
|
t.Fatalf("%d popular servers", len(list))
|
|
}
|
|
seen := map[string]bool{}
|
|
for _, m := range list {
|
|
if strings.HasPrefix(m.ID, "ai.smithery/") || m.Description == "" || seen[m.ID] {
|
|
t.Fatalf("shipped: %+v", m)
|
|
}
|
|
seen[m.ID] = true
|
|
}
|
|
}
|