Align MCPRegistry CRD with registry server v2 config format#4653
Open
Align MCPRegistry CRD with registry server v2 config format#4653
Conversation
Contributor
There was a problem hiding this comment.
Large PR Detected
This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.
How to unblock this PR:
Add a section to your PR description with the following format:
## Large PR Justification
[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformationAlternative:
Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.
See our Contributing Guidelines for more details.
This review will be automatically dismissed once you add the justification section.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4653 +/- ##
==========================================
- Coverage 68.84% 68.69% -0.15%
==========================================
Files 508 508
Lines 52604 52725 +121
==========================================
+ Hits 36215 36222 +7
- Misses 13587 13687 +100
- Partials 2802 2816 +14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fee3776 to
821ccda
Compare
The registry server has moved to a v2 config format that separates data sources from registry views, adds claims-based authorization, and supports managed and Kubernetes source types. The operator's MCPRegistry CRD was still generating v1 config (flat registries[] with inline source configs), meaning operators deploying via the CRD got none of the v2 authorization features. This updates the CRD spec to use separate sources[] and registries[] fields, adds support for claims (apiextensionsv1.JSON), authz roles, managed sources, Kubernetes sources with namespace selectors, and public paths on auth config. The config generator now produces v2-compatible YAML that the registry server can consume directly. A default Kubernetes source is auto-injected when the user defines none, preserving backward compatibility for MCP server discovery. Closes #4572 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Users should explicitly define all sources in their MCPRegistry spec, including Kubernetes discovery sources. The auto-injection was adding implicit behavior that would be surprising when combined with claims-based authorization. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add remaining v2 config fields to achieve full parity with the registry server configuration format: - MaxMetaSize (*int32) on DatabaseConfig for controlling metadata size limits - DynamicAuth with AWS RDS IAM support on DatabaseConfig for short-lived database credentials - TelemetryConfig on MCPRegistrySpec for OpenTelemetry configuration with tracing (sampling rate) and metrics sub-configs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add URLSource as a new source type for fetching registry data from HTTP/HTTPS URLs. This maps to the registry server's FileConfig with the url and timeout fields, complementing the existing ConfigMapRef and PVCRef file-based sources. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The RegistryBuilder's Build() method now syncs the default registry view's source list with the actual source names from spec.sources. This fixes integration test failures where WithRegistryName changed a source name but the registry view still referenced the old "default" name. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PVC-based registry sources are not a supported use case. Remove the PVCRef field, PVCSource struct, all associated config building, pod template volume mounting, tests, examples, and documentation. Also fix mutual exclusivity comments on remaining source types to consistently list all alternatives including URL. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The test was asserting the config YAML contains `registryName:` which was removed in the v2 format. Check for `sources:` instead, which is the v2 top-level key. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
99e64c0 to
d2d6430
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The registry server (
toolhive-registry-server) moved to a v2 config format that separates data sources from registry views and adds claims-based authorization. The operator's MCPRegistry CRD was still generating v1 config (flatregistries[]with inline source configs), so operators deploying via the CRD got none of the v2 authorization features.This updates the MCPRegistry CRD and config generation to produce v2-compatible config with full parity:
spec.registriesintospec.sources(data source definitions) andspec.registries(lightweight views referencing sources by name)apiextensionsv1.JSONManagedSource,KubernetesSource(with namespace selectors), andURLSourceas new source typesauthz(role-based access control) andpublicPathsto auth configmaxMetaSizeanddynamicAuth(AWS RDS IAM) to database configtelemetryConfigwith tracing (sampling) and metrics sub-configsCloses #4572
Type of change
Test plan
task test)task lint-fix)Deployed updated CRDs to a Kind cluster, applied a v2 MCPRegistry resource with sources + registries + claims, ran the operator locally, and verified the generated ConfigMap produces correct v2 YAML with
sources[]andregistries[].Changes
cmd/thv-operator/api/v1alpha1/mcpregistry_types.goMCPRegistrySourceConfig,MCPRegistryViewConfig,ManagedSource,KubernetesSource,URLSource,MCPRegistryAuthzConfig,MCPRegistryRolesConfig,MCPRegistryTelemetryConfig,MCPRegistryDynamicAuthConfig; claims viaapiextensionsv1.JSON;PublicPathson auth;MaxMetaSize/DynamicAuthon database; removedPVCSourcecmd/thv-operator/api/v1alpha1/zz_generated.deepcopy.gocmd/thv-operator/pkg/registryapi/config/config.goSourceConfig/RegistryConfigstructs, claims deserialization, authz mapping, telemetry/database config mapping, URL source support, removed PVC config buildingcmd/thv-operator/pkg/registryapi/config/config_test.gocmd/thv-operator/pkg/registryapi/deployment.goSpec.Sourcesfor git auth mountscmd/thv-operator/pkg/registryapi/podtemplatespec.goWithRegistrySourceMountstakes[]MCPRegistrySourceConfig, removed PVC volume mountingcmd/thv-operator/pkg/registryapi/{*_test.go}cmd/thv-operator/test-integration/mcp-registry/*.godeploy/charts/operator-crds/**docs/operator/crd-api.mdexamples/operator/mcp-registries/*.yamlDoes this introduce a user-facing change?
Yes. This is a breaking CRD change —
spec.registrieschanges meaning from source definitions to registry views. Since this isv1alpha1(explicitly unstable), an in-place update is acceptable. Existing MCPRegistry resources must be updated to the new format.Migration example:
Before:
After:
Special notes for reviewers
apiextensionsv1.JSONfor claims fields on sources and registries, and for role entries in authz config. The config generator deserializes and validates that values arestringor[]stringbefore emittingmap[string]anyin the YAML output.mcpregistry_types.goandconfig.go.Generated with Claude Code