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.
()
| 61 | // load fails fast on the first malformed file so binary-time validation |
| 62 | // surfaces drift between Python and Go. |
| 63 | func 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. |
| 93 | func (r *Registry) Get(name string) (ServerSchema, bool) { |