Skip to content

fix(registry/types): accept any value for non-ToolHive publisher-provided keys - #374

Merged
rdimitrov merged 2 commits into
mainfrom
loosen-publisher-provided-schema
Oct 14, 2026
Merged

rdimitrov merged 2 commits into
mainfrom
loosen-publisher-provided-schema

Conversation

@rdimitrov

Copy link
Copy Markdown
Member

Summary

publisher-provided.schema.json required every key under _meta["io.modelcontextprotocol.registry/publisher-provided"] other than io.github.stacklok to be an object:

"additionalProperties": { "type": "object", ... }

The upstream MCP Registry server.json spec doesn't constrain this. Its own documented example uses plain values:

"io.modelcontextprotocol.registry/publisher-provided": {
  "tool": "publisher-cli",
  "version": "1.2.3",
  "buildInfo": { "commit": "abc123def456", ... }
}

That example failed our validation with tool: Invalid type. Expected: object. In toolhive-registry-server this goes through ValidateUpstreamRegistryBytes, which validates a registry file as a whole, so one such server made an entire file or Git source fail to sync. API sources and POST /v1/entries don't run this check, so the same server.json was accepted there.

Changes

  • Schema: keys outside io.github.stacklok may now hold any JSON value. The io.github.stacklok namespace is still validated as before.
  • ServerExtensions.Validate(): this validated a single server's extensions ({status, tier, ...}) against the schema root instead of the server_extensions definition. It only returned errors because scalar fields like status weren't objects at the root, so it rejected valid extensions as well, which the old test locked in as "non-empty struct fails schema structure". It now wraps the extensions as {"io.github.stacklok": {"server": ...}} before validating, so the real definition applies. Error paths therefore include io.github.stacklok.server. as a prefix. No callers were found in toolhive, toolhive-registry-server, dockyard or toolhive-catalog.

Tests

  • ValidatePublisherProvidedExtensionsBytes:
    • upstream's documented example (strings, numbers, booleans, arrays, null, nested objects) is accepted;
    • the io.github.stacklok namespace is still validated when it sits next to plain values;
    • io.github.stacklok itself must still be an object.
  • ValidateServerJSON: a server whose publisher-provided metadata has plain values validates with extension checking enabled.
  • ServerExtensions.Validate: an empty struct fails (missing status), a valid struct passes, and an unknown tier fails.
  • task test and task license-check pass. task lint couldn't run locally: the installed golangci-lint was built with an older Go than 1.27 and fails to typecheck. go vet and gofmt are clean.

🤖 Generated with Claude Code

…ided keys

The publisher-provided schema required every key outside the
io.github.stacklok namespace to be an object. The upstream MCP Registry
server.json spec places no such constraint, and its own documented
example uses plain values ("tool": "publisher-cli", "version": "1.2.3").
Such server.json documents failed validation, and because registry
files validate as a whole, one of them made an entire file or Git source
fail to sync in toolhive-registry-server. Other keys may now hold any
JSON value; the io.github.stacklok namespace is still fully validated.

Also fix ServerExtensions.Validate, which validated a single server's
extensions against the schema root instead of the server_extensions
definition. It only rejected input because scalar fields such as
status were not objects at the root, so it rejected valid extensions
too. It now wraps the extensions in the ToolHive namespace before
validating.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rdimitrov
rdimitrov enabled auto-merge (squash) October 14, 2026 10:15
@rdimitrov
rdimitrov disabled auto-merge October 14, 2026 10:30
@rdimitrov
rdimitrov merged commit 78fcb49 into main Oct 14, 2026
6 checks passed
@rdimitrov
rdimitrov deleted the loosen-publisher-provided-schema branch October 14, 2026 10:30
rdimitrov added a commit to stacklok/toolhive-registry-server that referenced this pull request Oct 14, 2026
## Summary

Bumps `github.com/stacklok/toolhive-core` from v0.0.50 to v0.0.53 to
pick up stacklok/toolhive-core#374.

Before that fix, the `publisher-provided` schema required every key
outside `io.github.stacklok` to be an object. A server.json that follows
the upstream MCP Registry spec's own example failed validation:

```jsonc
"_meta": {
  "io.modelcontextprotocol.registry/publisher-provided": {
    "tool": "publisher-cli", "version": "1.2.3", "buildInfo": { "commit": "abc" }
  }
}
```

File and Git sources validate the whole registry file, so a single
server like this made the **entire source** fail to sync. API sources
and `POST /v1/entries` don't run that check, so the same server.json was
already accepted there.

## Dependency changes

The diff is large because v0.0.53 requires newer versions of many shared
dependencies; Go then upgrades everything else in the module to match.
The only other direct dependencies that move are small bumps:
`prometheus/client_golang` v1.25.0, `aws/smithy-go` v1.28.5 and
`golang.org/x/term` v0.47.0. The rest are indirect, including
`golang.org/x/net` v0.61.0 and `grpc` v1.84.0.

## Testing

- `go build ./...` and `go test ./...` pass.
- Integration tests pass for `internal/authz`, `internal/app/...` and
`internal/sync/...`.
- A temporary test (not committed) confirmed that a file source
containing the upstream example above now syncs and keeps the
`publisher-provided` data. It was rejected before.
- Grype (`--only-fixed --fail-on high`) reports no vulnerabilities.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants