Skip to content

Commit 5ee15ca

Browse files
rdimitrovclaude
andcommitted
Fix upstream format detection for registries with $schema
The legacy registry format also includes a $schema key, so checking for $schema alone incorrectly classified legacy files as upstream. Use the "data" wrapper object as the sole discriminator since only the upstream format wraps servers inside it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ffb1dfe commit 5ee15ca

2 files changed

Lines changed: 8 additions & 14 deletions

File tree

pkg/config/registry.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,19 +333,16 @@ func setRegistryFile(provider Provider, registryPath string) error {
333333
}
334334

335335
// isUpstreamRegistryFormat returns true if the JSON data appears to be in the
336-
// upstream MCP registry format (has "$schema" or "data" wrapper object).
336+
// upstream MCP registry format. The key discriminator is the "data" wrapper
337+
// object — only the upstream format wraps servers inside it.
337338
func isUpstreamRegistryFormat(data []byte) bool {
338339
var probe struct {
339-
Schema string `json:"$schema"`
340-
Data json.RawMessage `json:"data"`
340+
Data json.RawMessage `json:"data"`
341341
}
342342
if err := json.Unmarshal(data, &probe); err != nil {
343343
return false
344344
}
345-
if probe.Schema != "" {
346-
return true
347-
}
348-
// data must be a JSON object (starts with '{'), not a primitive
345+
// The "data" wrapper object is unique to the upstream format.
349346
return len(probe.Data) > 0 && probe.Data[0] == '{'
350347
}
351348

pkg/registry/upstream_parser.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,15 @@ type upstreamFormatProbe struct {
6464
}
6565

6666
// isUpstreamFormat returns true when the raw JSON appears to be in the upstream
67-
// registry format. It checks for the presence of a "$schema" key or a "data"
68-
// wrapper object (must be a JSON object, not a string/number), both of which
69-
// are unique to the upstream format.
67+
// registry format. The key discriminator is the "data" wrapper object — only
68+
// the upstream format wraps servers inside a "data" object. The "$schema" key
69+
// alone is not sufficient because the legacy format also includes one.
7070
func isUpstreamFormat(data []byte) bool {
7171
var probe upstreamFormatProbe
7272
if err := json.Unmarshal(data, &probe); err != nil {
7373
return false
7474
}
75-
if probe.Schema != "" {
76-
return true
77-
}
78-
// data must be a JSON object (starts with '{'), not a primitive
75+
// The "data" wrapper object is unique to the upstream format.
7976
return len(probe.Data) > 0 && probe.Data[0] == '{'
8077
}
8178

0 commit comments

Comments
 (0)