@@ -158,6 +158,40 @@ func (r *RegistryEntry) SetDefaults() {
158158 }
159159}
160160
161+ // extendedFields contains fields for YAML parsing that are not part of the standard schema
162+ type extendedFields struct {
163+ Examples []Example `yaml:"examples,omitempty"`
164+ License string `yaml:"license,omitempty"`
165+ // OAuth configuration in simplified YAML format
166+ OAuth * struct {
167+ Issuer string `yaml:"issuer,omitempty"`
168+ AuthorizeURL string `yaml:"authorize_url,omitempty"`
169+ TokenURL string `yaml:"token_url,omitempty"`
170+ ClientID string `yaml:"client_id,omitempty"`
171+ Scopes []string `yaml:"scopes,omitempty"`
172+ UsePKCE * bool `yaml:"use_pkce,omitempty"`
173+ OAuthParams map [string ]string `yaml:"oauth_params,omitempty"`
174+ CallbackPort int `yaml:"callback_port,omitempty"`
175+ } `yaml:"oauth,omitempty"`
176+ // Headers for remote server authentication
177+ Headers []struct {
178+ Name string `yaml:"name"`
179+ Description string `yaml:"description"`
180+ Required bool `yaml:"required"`
181+ Default string `yaml:"default,omitempty"`
182+ Secret bool `yaml:"secret,omitempty"`
183+ Choices []string `yaml:"choices,omitempty"`
184+ } `yaml:"headers,omitempty"`
185+ // Environment variables for server configuration
186+ EnvVars []struct {
187+ Name string `yaml:"name"`
188+ Description string `yaml:"description"`
189+ Required bool `yaml:"required"`
190+ Default string `yaml:"default,omitempty"`
191+ Secret bool `yaml:"secret,omitempty"`
192+ } `yaml:"env_vars,omitempty"`
193+ }
194+
161195// UnmarshalYAML implements custom YAML unmarshaling to determine server type
162196func (r * RegistryEntry ) UnmarshalYAML (unmarshal func (interface {}) error ) error {
163197 // First unmarshal into a map to check which fields are present
@@ -192,17 +226,88 @@ func (r *RegistryEntry) UnmarshalYAML(unmarshal func(interface{}) error) error {
192226 }
193227 }
194228
195- // Unmarshal extended fields (examples, license) separately
196- type extendedFields struct {
197- Examples []Example `yaml:"examples,omitempty"`
198- License string `yaml:"license,omitempty"`
199- }
229+ // Unmarshal extended fields (examples, license, oauth, headers, env_vars) separately
200230 var extended extendedFields
201231 if err := unmarshal (& extended ); err != nil {
202232 return err
203233 }
204234 r .Examples = extended .Examples
205235 r .License = extended .License
206236
237+ // Handle OAuth configuration transformation for remote servers
238+ if r .RemoteServerMetadata != nil && extended .OAuth != nil {
239+ r .OAuthConfig = & registry.OAuthConfig {
240+ Issuer : extended .OAuth .Issuer ,
241+ AuthorizeURL : extended .OAuth .AuthorizeURL ,
242+ TokenURL : extended .OAuth .TokenURL ,
243+ ClientID : extended .OAuth .ClientID ,
244+ Scopes : extended .OAuth .Scopes ,
245+ OAuthParams : extended .OAuth .OAuthParams ,
246+ CallbackPort : extended .OAuth .CallbackPort ,
247+ }
248+ // Set UsePKCE default or explicit value
249+ if extended .OAuth .UsePKCE != nil {
250+ r .OAuthConfig .UsePKCE = * extended .OAuth .UsePKCE
251+ } else {
252+ r .OAuthConfig .UsePKCE = true // default to true
253+ }
254+ }
255+
256+ // Handle additional fields for remote servers
257+ if r .RemoteServerMetadata != nil {
258+ r .handleRemoteServerFields (& extended , raw )
259+ }
260+
207261 return nil
208262}
263+
264+ // handleRemoteServerFields handles headers, env vars, and custom metadata for remote servers
265+ func (r * RegistryEntry ) handleRemoteServerFields (extended * extendedFields , raw map [string ]interface {}) {
266+ // Handle Headers transformation
267+ if len (extended .Headers ) > 0 {
268+ r .Headers = make ([]* registry.Header , len (extended .Headers ))
269+ for i , h := range extended .Headers {
270+ r .Headers [i ] = & registry.Header {
271+ Name : h .Name ,
272+ Description : h .Description ,
273+ Required : h .Required ,
274+ Default : h .Default ,
275+ Secret : h .Secret ,
276+ Choices : h .Choices ,
277+ }
278+ }
279+ }
280+
281+ // Handle EnvVars transformation (only for RemoteServerMetadata)
282+ if len (extended .EnvVars ) > 0 {
283+ r .RemoteServerMetadata .EnvVars = make ([]* registry.EnvVar , len (extended .EnvVars ))
284+ for i , e := range extended .EnvVars {
285+ r .RemoteServerMetadata .EnvVars [i ] = & registry.EnvVar {
286+ Name : e .Name ,
287+ Description : e .Description ,
288+ Required : e .Required ,
289+ Default : e .Default ,
290+ Secret : e .Secret ,
291+ }
292+ }
293+ }
294+
295+ // Handle custom metadata fields (homepage, license, author, etc.)
296+ customFields := make (map [string ]interface {})
297+
298+ // Check for common custom fields
299+ if val , exists := raw ["homepage" ]; exists {
300+ customFields ["homepage" ] = val
301+ }
302+ if val , exists := raw ["license" ]; exists {
303+ customFields ["license" ] = val
304+ }
305+ if val , exists := raw ["author" ]; exists {
306+ customFields ["author" ] = val
307+ }
308+
309+ // Set custom metadata if we found any custom fields
310+ if len (customFields ) > 0 {
311+ r .RemoteServerMetadata .CustomMetadata = customFields
312+ }
313+ }
0 commit comments