Skip to content

Commit fe3e99b

Browse files
committed
Implement flattened _meta format for server extensions
Replace the confusing wrapper format (server + x-* extensions) with a clean flattened format using structured _meta fields. This provides better developer ergonomics while maintaining extensibility and MCP compliance. Key changes: - Move from wrapper format to flattened ServerJSON with _meta field - Use structured ServerMeta with known fields (publisher, registry metadata) - Simplify PostgreSQL to simple id/value table for easier management - Update all APIs, validation, and services to use flattened format - Migrate seed data and examples to new format - Add migration 003_simplify_to_key_value.sql Publishers now maintain a single server.json file instead of separate files, improving the developer experience significantly. Fixes #284 🏠 Remote-Dev: homespace
1 parent be036a4 commit fe3e99b

File tree

30 files changed

+19283
-19549
lines changed

30 files changed

+19283
-19549
lines changed

cmd/publisher/commands/init.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111
"strings"
1212
"time"
1313

14+
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
1415
"github.com/modelcontextprotocol/registry/pkg/model"
1516
)
1617

17-
1818
func InitCommand() error {
1919
// Check if server.json already exists
2020
if _, err := os.Stat("server.json"); err == nil {
@@ -266,7 +266,7 @@ func createServerJSON(
266266
name, description, version, repoURL, repoSource,
267267
packageType, packageIdentifier, packageVersion string,
268268
envVars []model.KeyValueInput,
269-
) model.ServerJSON {
269+
) apiv0.ServerJSON {
270270
// Determine registry type and base URL
271271
var registryType, registryBaseURL string
272272
switch packageType {
@@ -297,7 +297,7 @@ func createServerJSON(
297297
}
298298

299299
// Create server structure
300-
return model.ServerJSON{
300+
return apiv0.ServerJSON{
301301
Schema: "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
302302
Name: name,
303303
Description: description,

cmd/publisher/commands/publish.go

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"os"
1212
"path/filepath"
1313
"strings"
14+
15+
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
1416
)
1517

1618
func PublishCommand(args []string) error {
@@ -30,7 +32,7 @@ func PublishCommand(args []string) error {
3032
}
3133

3234
// Validate JSON
33-
var serverJSON map[string]any
35+
var serverJSON apiv0.ServerJSON
3436
if err := json.Unmarshal(serverData, &serverJSON); err != nil {
3537
return fmt.Errorf("invalid server.json: %w", err)
3638
}
@@ -73,26 +75,14 @@ func PublishCommand(args []string) error {
7375

7476
func publishToRegistry(registryURL string, serverData []byte, token string) error {
7577
// Parse the server JSON data
76-
var serverDetails map[string]any
77-
err := json.Unmarshal(serverData, &serverDetails)
78+
var serverJSON apiv0.ServerJSON
79+
err := json.Unmarshal(serverData, &serverJSON)
7880
if err != nil {
7981
return fmt.Errorf("error parsing server.json file: %w", err)
8082
}
8183

82-
// Create the publish request payload
83-
var publishReq map[string]any
84-
if _, hasServerField := serverDetails["server"]; hasServerField {
85-
// Already in PublishRequest format
86-
publishReq = serverDetails
87-
} else {
88-
// Wrap in server field
89-
publishReq = map[string]any{
90-
"server": serverDetails,
91-
}
92-
}
93-
9484
// Convert to JSON
95-
jsonData, err := json.Marshal(publishReq)
85+
jsonData, err := json.Marshal(serverJSON)
9686
if err != nil {
9787
return fmt.Errorf("error serializing request: %w", err)
9888
}
@@ -129,4 +119,4 @@ func publishToRegistry(registryURL string, serverData []byte, token string) erro
129119
}
130120

131121
return nil
132-
}
122+
}

cmd/registry/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/modelcontextprotocol/registry/internal/database"
1717
"github.com/modelcontextprotocol/registry/internal/service"
1818
"github.com/modelcontextprotocol/registry/internal/telemetry"
19-
"github.com/modelcontextprotocol/registry/pkg/model"
19+
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
2020
)
2121

2222
func main() {
@@ -46,7 +46,7 @@ func main() {
4646
// Initialize services based on environment
4747
switch cfg.DatabaseType {
4848
case config.DatabaseTypeMemory:
49-
db = database.NewMemoryDB(map[string]*model.ServerJSON{})
49+
db = database.NewMemoryDB(map[string]*apiv0.ServerJSON{})
5050
registryService = service.NewRegistryServiceWithDB(db)
5151
case config.DatabaseTypePostgreSQL:
5252
// Use PostgreSQL for real registry service

0 commit comments

Comments
 (0)