MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / LoadBundledRegistry

Function LoadBundledRegistry

internal/mcp/registry.go:63–90  ·  view source on GitHub ↗

LoadBundledRegistry parses every embedded JSON schema into a Registry. The load fails fast on the first malformed file so binary-time validation surfaces drift between Python and Go.

()

Source from the content-addressed store, hash-verified

61// load fails fast on the first malformed file so binary-time validation
62// surfaces drift between Python and Go.
63func LoadBundledRegistry() (*Registry, error) {
64 out := map[string]ServerSchema{}
65 err := fs.WalkDir(bundledRegistry, "registry/servers", func(path string, d fs.DirEntry, err error) error {
66 if err != nil {
67 return err
68 }
69 if d.IsDir() || !strings.HasSuffix(path, ".json") {
70 return nil
71 }
72 data, err := bundledRegistry.ReadFile(path)
73 if err != nil {
74 return err
75 }
76 var schema ServerSchema
77 if err := json.Unmarshal(data, &schema); err != nil {
78 return fmt.Errorf("mcp: parse %s: %w", path, err)
79 }
80 if schema.Name == "" {
81 return fmt.Errorf("mcp: schema missing name in %s", path)
82 }
83 out[schema.Name] = schema
84 return nil
85 })
86 if err != nil {
87 return nil, err
88 }
89 return &Registry{schemas: out}, nil
90}
91
92// Get looks up a server by name.
93func (r *Registry) Get(name string) (ServerSchema, bool) {

Callers 9

SearchRegistryMethod · 0.92
ShowServerMethod · 0.92
ListRegistryMethod · 0.92
InstallFromRegistryMethod · 0.92
mcpSearchCommandMethod · 0.92
mcpAddCommandMethod · 0.92
mcpServerCommandMethod · 0.92

Calls 1

ReadFileMethod · 0.80

Tested by 2