Allow usage of validators (and authentication checks) as a library
Is your feature request related to a problem? Please describe. The registry contains a bunch of validators that make sure only valid entries make it into the registry:
- Authentication: Ensure that you are authenticated to publish servers on a given namespace
- Validation that packages and remotes match the given authentication permissions
Unfortunately, it is very hard to reuse this outside of running a full-blown registry. I would want to avoid maintaining the logic myself, because there a quite a few specifics here.
My goal is to have a small tool with which I can, given a serverName and packages/remotes locally validate if the server is valid. This tooling could be used as part of a private subregistry that is not based on this repository.
Describe the solution you'd like
For validation, I guess it might be enough to move the internal/validators package to pkg. Mostly, I'm interested in the registries validation: https://github.com/modelcontextprotocol/registry/tree/main/internal/validators
For authentication, it seems like this logic is currently tied up in the individual auth handlers (e.g. https://github.com/modelcontextprotocol/registry/blob/535941a30e92c88b5bc83ef4e951d4183ccf19db/internal/api/handlers/v0/auth/github_oidc.go#L293), making this a broader refactoring, it seems.
Describe alternatives you've considered
- Using the validation command of the publisher: https://github.com/modelcontextprotocol/registry/blob/main/cmd/publisher/commands/validate.go – unfortunately, it uses the
/validatepart of a deployed registry, making this non-optimal - Reimplementing the relevant logic: This will soon become outdated, as other package registries are added or authentication schemes change, so I'd ideally avoid that
+1 from the publisher side: my registry publish runs in CI on release tags, so a bad server.json only fails after the tag is cut. I ended up maintaining my own preflight check script, i.e. alternative 2.
Phase 1 might be smaller than it looks. The per-registry ownership validators already take pkg/model.Package plus a server name and return an error, and the dispatch already exists in internal/validators/package.go. A thin pkg/validators facade over that dispatcher would cover the registries validation without exporting the per-registry helpers. The schema layer depends on internal/config, and auth is tied up in the handlers as you note, so both would be later phases.
This would also let mcp-publisher validate run locally instead of calling the deployed /validate.
One open question: library consumers probably want typed outcomes (package missing vs ownership mismatch vs transient upstream error) rather than matching on error strings.
I can put up the phase-1 PR if maintainers want to go this way.