Skip to content

Commit db0d6bd

Browse files
committed
refactor: simplify to only support current schema version
1 parent 79b2785 commit db0d6bd

File tree

5 files changed

+6
-240
lines changed

5 files changed

+6
-240
lines changed

cmd/publisher/commands/publish.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func PublishCommand(args []string) error {
3838
return fmt.Errorf("invalid server.json: %w", err)
3939
}
4040

41-
// Validate $schema field is required and must be a valid schema URL
41+
// Validate $schema field is required and must be the current schema URL
4242
if serverJSON.Schema == "" {
4343
return fmt.Errorf(`$schema field is required.
4444
@@ -48,10 +48,10 @@ Add the following to your server.json:
4848
📖 Schema reference: https://github.com/modelcontextprotocol/registry/tree/main/docs/reference/server-json`, model.CurrentSchemaURL)
4949
}
5050

51-
if !model.IsValidSchemaURL(serverJSON.Schema) {
51+
if serverJSON.Schema != model.CurrentSchemaURL {
5252
return fmt.Errorf(`invalid $schema URL: %s
5353
54-
Update your server.json to use a valid schema URL, e.g.:
54+
Update your server.json to use:
5555
"$schema": "%s"
5656
5757
📖 Schema reference: https://github.com/modelcontextprotocol/registry/tree/main/docs/reference/server-json`, serverJSON.Schema, model.CurrentSchemaURL)

internal/validators/validators.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ func ValidateServerJSON(serverJSON *apiv0.ServerJSON) error {
5858
if serverJSON.Schema == "" {
5959
return fmt.Errorf("$schema field is required. Use: %s", model.CurrentSchemaURL)
6060
}
61-
if !model.IsValidSchemaURL(serverJSON.Schema) {
62-
return fmt.Errorf("invalid $schema URL: %s. Must be one of the valid schema URLs (e.g., %s)", serverJSON.Schema, model.CurrentSchemaURL)
61+
if serverJSON.Schema != model.CurrentSchemaURL {
62+
return fmt.Errorf("invalid $schema URL: %s. Must be: %s", serverJSON.Schema, model.CurrentSchemaURL)
6363
}
6464

6565
// Validate server name exists and format

internal/validators/validators_test.go

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestValidate(t *testing.T) {
3333
expectedError: "$schema field is required",
3434
},
3535
{
36-
name: "Schema version rejects old schema (2025-01-27)",
36+
name: "Schema version rejects old schema",
3737
serverDetail: apiv0.ServerJSON{
3838
Schema: "https://static.modelcontextprotocol.io/schemas/2025-01-27/server.schema.json",
3939
Name: "com.example/test-server",
@@ -46,62 +46,6 @@ func TestValidate(t *testing.T) {
4646
},
4747
expectedError: "invalid $schema URL",
4848
},
49-
{
50-
name: "Schema version accepts 2025-10-11 schema",
51-
serverDetail: apiv0.ServerJSON{
52-
Schema: "https://static.modelcontextprotocol.io/schemas/2025-10-11/server.schema.json",
53-
Name: "com.example/test-server",
54-
Description: "A test server",
55-
Repository: &model.Repository{
56-
URL: "https://github.com/owner/repo",
57-
Source: "github",
58-
},
59-
Version: "1.0.0",
60-
},
61-
expectedError: "",
62-
},
63-
{
64-
name: "Schema version accepts 2025-09-29 schema",
65-
serverDetail: apiv0.ServerJSON{
66-
Schema: "https://static.modelcontextprotocol.io/schemas/2025-09-29/server.schema.json",
67-
Name: "com.example/test-server",
68-
Description: "A test server",
69-
Repository: &model.Repository{
70-
URL: "https://github.com/owner/repo",
71-
Source: "github",
72-
},
73-
Version: "1.0.0",
74-
},
75-
expectedError: "",
76-
},
77-
{
78-
name: "Schema version accepts 2025-09-16 schema",
79-
serverDetail: apiv0.ServerJSON{
80-
Schema: "https://static.modelcontextprotocol.io/schemas/2025-09-16/server.schema.json",
81-
Name: "com.example/test-server",
82-
Description: "A test server",
83-
Repository: &model.Repository{
84-
URL: "https://github.com/owner/repo",
85-
Source: "github",
86-
},
87-
Version: "1.0.0",
88-
},
89-
expectedError: "",
90-
},
91-
{
92-
name: "Schema version accepts 2025-07-09 schema",
93-
serverDetail: apiv0.ServerJSON{
94-
Schema: "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
95-
Name: "com.example/test-server",
96-
Description: "A test server",
97-
Repository: &model.Repository{
98-
URL: "https://github.com/owner/repo",
99-
Source: "github",
100-
},
101-
Version: "1.0.0",
102-
},
103-
expectedError: "",
104-
},
10549
{
10650
name: "Schema version rejects random URL",
10751
serverDetail: apiv0.ServerJSON{

pkg/model/constants.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,41 +39,5 @@ const (
3939
CurrentSchemaVersion = "2025-10-17"
4040
// CurrentSchemaURL is the full URL to the current schema
4141
CurrentSchemaURL = "https://static.modelcontextprotocol.io/schemas/" + CurrentSchemaVersion + "/server.schema.json"
42-
// SchemaURLPrefix is the common prefix for all schema URLs
43-
SchemaURLPrefix = "https://static.modelcontextprotocol.io/schemas/"
44-
// SchemaURLSuffix is the common suffix for all schema URLs
45-
SchemaURLSuffix = "/server.schema.json"
4642
)
4743

48-
// ValidSchemaVersions is the list of all accepted schema versions.
49-
// This is used by validators to accept any valid schema version (not just the current one).
50-
// TODO: Consider only supporting more recent schema versions.
51-
var ValidSchemaVersions = []string{
52-
"2025-10-17",
53-
"2025-10-11",
54-
"2025-09-29",
55-
"2025-09-16",
56-
"2025-07-09",
57-
}
58-
59-
// IsValidSchemaURL checks if the given schema URL is a valid MCP server schema URL.
60-
// It must match the pattern: https://static.modelcontextprotocol.io/schemas/{version}/server.schema.json
61-
// where {version} is one of the valid schema versions.
62-
func IsValidSchemaURL(schemaURL string) bool {
63-
for _, version := range ValidSchemaVersions {
64-
expectedURL := SchemaURLPrefix + version + SchemaURLSuffix
65-
if schemaURL == expectedURL {
66-
return true
67-
}
68-
}
69-
return false
70-
}
71-
72-
// ValidSchemaURLs returns the list of all valid schema URLs.
73-
func ValidSchemaURLs() []string {
74-
urls := make([]string, len(ValidSchemaVersions))
75-
for i, version := range ValidSchemaVersions {
76-
urls[i] = SchemaURLPrefix + version + SchemaURLSuffix
77-
}
78-
return urls
79-
}

pkg/model/constants_test.go

Lines changed: 0 additions & 142 deletions
This file was deleted.

0 commit comments

Comments
 (0)