8
8
"net/http"
9
9
"os"
10
10
"strings"
11
- "time"
12
11
13
12
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
14
13
)
@@ -125,20 +124,8 @@ func fetchFromRegistryAPI(ctx context.Context, baseURL string) ([]*apiv1.ServerR
125
124
}
126
125
127
126
func convertServerResponseToRecord (response apiv1.ServerRecord ) * apiv1.ServerRecord {
128
- // Extract registry metadata from the extension
129
- registryExt := response .XIOModelContextProtocolRegistry
130
-
131
- // Parse timestamps
132
- publishedAt , _ := time .Parse (time .RFC3339 , getStringFromInterface (registryExt , "published_at" ))
133
- updatedAt , _ := time .Parse (time .RFC3339 , getStringFromInterface (registryExt , "updated_at" ))
134
-
135
- registryMetadata := apiv1.RegistryExtensions {
136
- ID : getStringFromInterface (registryExt , "id" ),
137
- IsLatest : getBoolFromInterface (registryExt , "is_latest" ),
138
- PublishedAt : publishedAt ,
139
- UpdatedAt : updatedAt ,
140
- ReleaseDate : getStringFromInterface (registryExt , "release_date" ),
141
- }
127
+ // The registry extensions are already properly typed, so we can use them directly
128
+ registryMetadata := response .XIOModelContextProtocolRegistry
142
129
143
130
// Publisher extensions
144
131
publisherExtensions := response .XPublisher
@@ -153,24 +140,3 @@ func convertServerResponseToRecord(response apiv1.ServerRecord) *apiv1.ServerRec
153
140
}
154
141
}
155
142
156
- func getStringFromInterface (data interface {}, key string ) string {
157
- if dataMap , ok := data .(map [string ]interface {}); ok {
158
- if value , exists := dataMap [key ]; exists {
159
- if strValue , ok := value .(string ); ok {
160
- return strValue
161
- }
162
- }
163
- }
164
- return ""
165
- }
166
-
167
- func getBoolFromInterface (data interface {}, key string ) bool {
168
- if dataMap , ok := data .(map [string ]interface {}); ok {
169
- if value , exists := dataMap [key ]; exists {
170
- if boolValue , ok := value .(bool ); ok {
171
- return boolValue
172
- }
173
- }
174
- }
175
- return false
176
- }
0 commit comments