Changes on the server.json format and the API (#562)
This commit is contained in:
parent
4962609697
commit
b21c6f564d
1 changed files with 4056 additions and 5608 deletions
|
|
@ -8,22 +8,31 @@ import (
|
|||
|
||||
// RegistryExtensions represents registry-generated metadata
|
||||
type RegistryExtensions struct {
|
||||
ServerID string `json:"serverId"` // Consistent ID across all versions of a server
|
||||
VersionID string `json:"versionId"` // Unique ID for this specific version
|
||||
PublishedAt time.Time `json:"publishedAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt,omitempty"`
|
||||
IsLatest bool `json:"isLatest"`
|
||||
Status model.Status `json:"status"`
|
||||
PublishedAt time.Time `json:"publishedAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt,omitempty"`
|
||||
IsLatest bool `json:"isLatest"`
|
||||
}
|
||||
|
||||
// ResponseMeta represents the top-level metadata in API responses
|
||||
type ResponseMeta struct {
|
||||
Official *RegistryExtensions `json:"io.modelcontextprotocol.registry/official,omitempty"`
|
||||
}
|
||||
|
||||
// ServerResponse represents the new API response format with separated metadata
|
||||
type ServerResponse struct {
|
||||
Server ServerJSON `json:"server"`
|
||||
Meta ResponseMeta `json:"_meta"`
|
||||
}
|
||||
|
||||
// ServerListResponse represents the paginated server list response
|
||||
type ServerListResponse struct {
|
||||
Servers []ServerJSON `json:"servers"`
|
||||
Metadata Metadata `json:"metadata"`
|
||||
Servers []ServerResponse `json:"servers"`
|
||||
Metadata Metadata `json:"metadata"`
|
||||
}
|
||||
|
||||
// ServerMeta represents the structured metadata with known extension fields
|
||||
type ServerMeta struct {
|
||||
Official *RegistryExtensions `json:"io.modelcontextprotocol.registry/official,omitempty"`
|
||||
PublisherProvided map[string]interface{} `json:"io.modelcontextprotocol.registry/publisher-provided,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -32,7 +41,6 @@ type ServerJSON struct {
|
|||
Schema string `json:"$schema,omitempty"`
|
||||
Name string `json:"name" minLength:"1" maxLength:"200"`
|
||||
Description string `json:"description" minLength:"1" maxLength:"100"`
|
||||
Status model.Status `json:"status,omitempty" minLength:"1"`
|
||||
Repository model.Repository `json:"repository,omitempty"`
|
||||
Version string `json:"version"`
|
||||
WebsiteURL string `json:"websiteUrl,omitempty"`
|
||||
|
|
@ -43,20 +51,6 @@ type ServerJSON struct {
|
|||
|
||||
// Metadata represents pagination metadata
|
||||
type Metadata struct {
|
||||
NextCursor string `json:"next_cursor,omitempty"`
|
||||
NextCursor string `json:"nextCursor,omitempty"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
func (s *ServerJSON) GetServerID() string {
|
||||
if s.Meta != nil && s.Meta.Official != nil {
|
||||
return s.Meta.Official.ServerID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (s *ServerJSON) GetVersionID() string {
|
||||
if s.Meta != nil && s.Meta.Official != nil {
|
||||
return s.Meta.Official.VersionID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue