Changes on the server.json format and the API (#562)

This commit is contained in:
Radoslav Dimitrov 2025-09-29 23:30:35 +03:00 • committed by GitHub
commit b21c6f564d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 4056 additions and 5608 deletions

View file

@ -301,10 +301,9 @@ func createServerJSON(
// Create server structure
return apiv0.ServerJSON{
Schema: "https://static.modelcontextprotocol.io/schemas/2025-09-16/server.schema.json",
Schema: "https://static.modelcontextprotocol.io/schemas/2025-09-29/server.schema.json",
Name: name,
Description: description,
Status: model.StatusActive,
Repository: model.Repository{
URL: repoURL,
Source: repoSource,

View file

@ -39,7 +39,7 @@ func PublishCommand(args []string) error {
// Check for deprecated schema and recommend migration
// Allow empty schema (will use default) but reject old schemas
if serverJSON.Schema != "" && !strings.Contains(serverJSON.Schema, "2025-09-16") {
if serverJSON.Schema != "" && !strings.Contains(serverJSON.Schema, "2025-09-29") {
return fmt.Errorf(`deprecated schema detected :%s.
Migrate to the current schema format for new servers.
@ -82,14 +82,12 @@ Migrate to the current schema format for new servers.
}
_, _ = fmt.Fprintln(os.Stdout, "✓ Successfully published")
if serverID := response.GetServerID(); serverID != "" {
_, _ = fmt.Fprintf(os.Stdout, "✓ Server Id %s version %s\n", serverID, response.Version)
}
_, _ = fmt.Fprintf(os.Stdout, "✓ Server %s version %s\n", response.Server.Name, response.Server.Version)
return nil
}
func publishToRegistry(registryURL string, serverData []byte, token string) (*apiv0.ServerJSON, error) {
func publishToRegistry(registryURL string, serverData []byte, token string) (*apiv0.ServerResponse, error) {
// Parse the server JSON data
var serverJSON apiv0.ServerJSON
err := json.Unmarshal(serverData, &serverJSON)
@ -134,9 +132,10 @@ func publishToRegistry(registryURL string, serverData []byte, token string) (*ap
return nil, fmt.Errorf("server returned status %d: %s", resp.StatusCode, body)
}
if err := json.Unmarshal(body, &serverJSON); err != nil {
var serverResponse apiv0.ServerResponse
if err := json.Unmarshal(body, &serverResponse); err != nil {
return nil, err
}
return &serverJSON, nil
return &serverResponse, nil
}

View file

@ -44,8 +44,8 @@ func TestPublishCommand_DeprecatedSchema(t *testing.T) {
errorSubstr: "deprecated schema detected",
},
{
name: "current 2025-09-16 schema should pass validation",
schema: "https://static.modelcontextprotocol.io/schemas/2025-09-16/server.schema.json",
name: "current 2025-09-29 schema should pass validation",
schema: "https://static.modelcontextprotocol.io/schemas/2025-09-29/server.schema.json",
expectError: false,
},
{
@ -69,7 +69,6 @@ func TestPublishCommand_DeprecatedSchema(t *testing.T) {
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
Status: model.StatusActive,
Repository: model.Repository{
URL: "https://github.com/example/test",
Source: "github",

View file

@ -84,11 +84,9 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
importerService := importer.NewService(db)
importerService := importer.NewService(registryService)
if err := importerService.ImportFromPath(ctx, cfg.SeedFrom); err != nil {
log.Printf("Failed to import seed data: %v", err)
} else {
log.Println("Data import completed successfully")
}
}