@@ -30,12 +30,17 @@ func NewOfficialRegistry(loader *Loader) *OfficialRegistry {
3030}
3131
3232// WriteJSON builds the official MCP registry and writes it to the specified path
33- // The registry is validated against the schema before writing - generation fails if validation fails
33+ // Individual entries and the complete registry are validated before writing - generation fails if validation fails
3434func (or * OfficialRegistry ) WriteJSON (path string ) error {
35+ // Validate all entries first
36+ if err := or .validateEntries (); err != nil {
37+ return fmt .Errorf ("entry validation failed: %w" , err )
38+ }
39+
3540 // Build the registry structure
3641 registry := or .build ()
3742
38- // Validate the registry before writing
43+ // Validate the complete registry against schema
3944 if err := or .validateRegistry (registry ); err != nil {
4045 return fmt .Errorf ("registry validation failed: %w" , err )
4146 }
@@ -107,6 +112,20 @@ func (*OfficialRegistry) validateRegistry(registry *ToolHiveRegistryType) error
107112 return nil
108113}
109114
115+ // validateEntries validates all individual registry entries
116+ func (or * OfficialRegistry ) validateEntries () error {
117+ entries := or .loader .GetEntries ()
118+ validator := NewSchemaValidator ()
119+
120+ for name , entry := range entries {
121+ if err := validator .ValidateEntryFields (entry , name ); err != nil {
122+ return fmt .Errorf ("entry '%s' validation failed: %w" , name , err )
123+ }
124+ }
125+
126+ return nil
127+ }
128+
110129// build creates the ToolHiveRegistryType structure from loaded entries
111130func (or * OfficialRegistry ) build () * ToolHiveRegistryType {
112131 entries := or .loader .GetEntries ()
0 commit comments