Repository navigation
Closed
Labels
apiItems related to the APIbreaking-changeenhancementNew feature or requestgoPull requests that update go codekubernetesItems related to Kubernetesoperator
Description
Summary
The MCPRegistry CRD and its config generation produce a v1 config format for the registry server. The registry server has moved to v2 with separate sources[] and registries[], claims-based authorization, authz roles, managed sources, and kubernetes namespaces. Operators deploying via the MCPRegistry CRD get none of the v2 authorization features.
Current state
The operator generates:
registryName: my-registry
registries:
- name: default
format: upstream
kubernetes: {}
- name: user-registry
format: toolhive
git: { ... }
database: { ... }
auth: { mode: anonymous }The registry server expects (v2):
sources:
- name: k8s
claims: { org: acme }
kubernetes:
namespaces: [toolhive-system]
- name: git-catalog
claims: { org: acme }
git: { ... }
- name: internal
managed: {}
registries:
- name: default
sources: [k8s, git-catalog, internal]
claims: { org: acme }
database: { ... }
auth:
mode: oauth
oauth: { ... }
authz:
roles:
superAdmin: [{ ... }]
manageSources: [{ ... }]
manageRegistries: [{ ... }]
manageEntries: [{ ... }]What's missing in the CRD
| Feature | Status |
|---|---|
| Sources/registries separation | Missing — flat registries[] with inline source configs |
| Claims on sources | Missing |
| Claims on registries (access gate) | Missing |
| Authz roles (superAdmin, manageSources, manageRegistries, manageEntries) | Missing |
| Managed (internal) source type for publishing | Missing |
| Kubernetes source type with namespaces | Missing (hardcoded default only) |
| Telemetry config | Missing |
Proposed changes
CRD types (api/v1alpha1/mcpregistry_types.go)
- Replace
spec.registries(source+endpoint) with separatespec.sources(data sources) andspec.registries(lightweight views referencing sources by name) - Add
claimsfield to both source and registry configs - Add
managedandkubernetes(with namespaces) source types - Add
spec.authConfig.authz.roleswith superAdmin, manageSources, manageRegistries, manageEntries
Config generation (pkg/registryapi/config/config.go)
- Update
Configstruct to produce v2 format (sources[]+registries[]) - Map claims from CRD to config
- Map authz roles from CRD to config
- Remove hardcoded default kubernetes registry (user defines it explicitly)
- Remove top-level
registryName(v2 uses named registries)
Controller (controllers/mcpregistry_controller.go)
- Update volume mount iteration to use
spec.sourcesinstead ofspec.registries - ConfigMap/PVC/Git secret mounting iterates sources
Tests (pkg/registryapi/config/config_test.go)
- All tests need updating for v2 structure
- New test cases: claims, authz roles, managed source, kubernetes namespaces, source references
Migration
Since this is v1alpha1 (explicitly unstable), an in-place update is acceptable. Existing MCPRegistry resources will need updating to the new CRD shape. Document the migration in release notes.
Impact
- Registry server: No changes needed — already expects v2 config
- Helm chart: No changes needed — already generates v2 config via passthrough
- Demo sandbox: MCPRegistry manifests need updating to v2 CRD shape
Context
Registry server v2 authorization work:
- Part 1: Add registry access gate and publish/delete claim validation toolhive-registry-server#649 — Registry access gate + publish/delete claim validation
- Part 2: Add claim-scoped admin management for sources and registries toolhive-registry-server#650 — Claim-scoped admin management
- Part 3: Fix insecure HTTP OAuth and super-admin bypass on consumer endpoints toolhive-registry-server#651 — Super-admin bypass + OAuth fixes
- Add per-entry claims for K8s sources via authz-claims annotation toolhive-registry-server#662 — K8s per-entry claims via authz-claims annotation
Metadata
Metadata
Assignees
Labels
apiItems related to the APIbreaking-changeenhancementNew feature or requestgoPull requests that update go codekubernetesItems related to Kubernetesoperator
Activity
rdimitrov commentedon Apr 6, 2026
Plan:
New
MCPRegistrySourceConfig(replaces oldMCPRegistryConfig)New
MCPRegistryViewConfig(lightweight registry view)New source types
Add authz roles to auth config
Note: Claims on CRD use
map[string]string(K8s CRD limitation — noany). The configgenerator converts to
map[string]anyfor the registry server config. For array claimvalues, use comma-separated strings in the CRD and parse them during config generation,
or use JSON string values.
Alternative: Use
apiextensionsv1.JSON(raw JSON) for claims fields to allow arbitrarytypes. This is the more flexible approach and avoids the string-to-any conversion complexity.
2. Config Generation Changes
File:
cmd/thv-operator/pkg/registryapi/config/config.goUpdate
Configstruct to v2 formatNew
SourceConfig(replaces oldRegistryConfig)New
RegistryConfig(lightweight view)New source type configs
Add authz to
AuthConfigUpdate
BuildConfig()Sources[]fromCRD spec.Sources(each source config maps 1:1)Registries[]fromCRD spec.Registries(name + source refs + claims)RegistryName— v2 uses named registries3. Deployment Changes
File:
cmd/thv-operator/pkg/registryapi/deployment.goMinimal changes — ConfigMap mount path stays the same (
/config/config.yaml). The registryserver reads the same file, just with v2 structure.
Update the default image tag if the registry server version needs bumping.
4. Controller Changes
File:
cmd/thv-operator/controllers/mcpregistry_controller.gomcpRegistry.Spec.RegistriestomcpRegistry.Spec.SourcesandmcpRegistry.Spec.Registries(new types)Spec.Sourcesinstead ofSpec.Registries5. Test Changes
File:
cmd/thv-operator/pkg/registryapi/config/config_test.goAll tests need updating:
Registriesin CRD spec withSources+RegistriesSources[]andRegistries[]in outputmultiple sources per registry, name validation
6. CRD Schema / Validation
Sourcesmin 1 item requiredRegistriesmin 1 item requiredSourcesrefs must be valid source namesManagedsource allowedmake generate && make manifests7. Migration / Backward Compatibility
This is a breaking CRD change. The
spec.registriesfield changes meaning (fromsource+endpoint to just endpoint).
Since this is v1alpha1 (explicitly unstable), an in-place update is acceptable. Existing
MCPRegistry resources will need updating to the new CRD shape. Document the migration in
release notes.
8. Impact on Other Components
Files Modified (toolhive repo)
api/v1alpha1/mcpregistry_types.goapi/v1alpha1/zz_generated.deepcopy.gopkg/registryapi/config/config.gopkg/registryapi/config/config_test.gopkg/registryapi/deployment.gocontrollers/mcpregistry_controller.goconfig/crd/bases/REGISTRY.mdVerification
make generate && make manifests— regenerate deepcopy and CRD schemasmake test— all tests passrdimitrov commentedon Apr 7, 2026
Operator MCPRegistry CRD v2 Alignment — Implementation Plan
Context
The ToolHive operator's MCPRegistry CRD generates a v1 config format for the registry server (flat
registries[]with inline source configs). The registry server (toolhive-registry-server) has moved to v2 (separatesources[]andregistries[]with claims, authz roles, managed sources, and kubernetes namespaces). Operators deploying via the MCPRegistry CRD get none of the v2 authorization features.This plan updates the MCPRegistry CRD and config generation to produce v2-compatible config.
Repo:
stacklok/toolhiveRegistry server repo:
stacklok/toolhive-registry-serverAffected subtree:
cmd/thv-operator/v2 Server Config Reference
The registry server (
toolhive-registry-server/internal/config/config.go) expects:Where
SourceConfighas: Name, Format, Git/API/File/Managed/Kubernetes (exactly one), SyncPolicy, Filter, Claims (map[string]any, values must bestringor[]string).Where
RegistryConfighas: Name, Sources (ordered source name refs), Claims (map[string]any).PR Splitting Strategy
This change exceeds the 400-line / 10-file PR limit. Split into 3 PRs:
mcpregistry_types.go,zz_generated.deepcopy.go, CRD manifestsconfig/config.go,config/config_test.gomcpregistry_controller.go,deployment.go,podtemplatespec.go, examples, REGISTRY.mdPRs are sequential — each builds on the previous.
1. CRD Type Changes (PR 1)
File:
cmd/thv-operator/api/v1alpha1/mcpregistry_types.goReplace
RegistrieswithSources+RegistriesNew
MCPRegistrySourceConfig(replaces oldMCPRegistryConfig)New
MCPRegistryViewConfig(lightweight registry view)Claims typing:
apiextensionsv1.JSONUse
apiextensionsv1.JSON(fromk8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1) for bothClaimsfields. This preserves type fidelity with the server'smap[string]any(where values arestringor[]string) without CSV parsing hacks. The config generator unmarshals the raw JSON and validates that values arestringor[]stringbefore emittingmap[string]anyin the YAML config.Add kubebuilder marker
+kubebuilder:validation:Type=objectand+kubebuilder:pruning:PreserveUnknownFieldsto allow arbitrary JSON.New source types
Add authz to auth config
Each role entry is
apiextensionsv1.JSONrather than[]map[string]any— this gives CRD schema flexibility while keeping the API typed. The config generator deserializes each entry tomap[string]anyfor the server config.Kubebuilder validation markers
Sources:+kubebuilder:validation:MinItems=1,+listType=map,+listMapKey=nameRegistries:+kubebuilder:validation:MinItems=1,+listType=map,+listMapKey=nameManagedsource allowed (CEL validation rule)Sourcesrefs must be valid source names (CEL validation rule, or validated in controller)Auto-default Kubernetes source behavior
If the user defines no
KubernetesSourceinspec.sources, the config generator auto-injects a default Kubernetes source named"default"and prepends it to the first registry'ssourceslist. This preserves backward compatibility for MCP server discovery. If the user explicitly defines aKubernetesSource, no auto-injection occurs.2. Config Generation Changes (PR 2)
File:
cmd/thv-operator/pkg/registryapi/config/config.goUpdate
Configstruct to v2 formatRemove
RegistryName— v2 uses named registries, not a top-level name.New
SourceConfig(replaces oldRegistryConfig)New
RegistryConfig(lightweight view)New source type configs
Updated
FileConfig(match server)Note: The CRD currently only generates
Path-based file configs (from ConfigMapRef/PVCRef). URL and Data fields are included for server parity but not yet exposed in the CRD. They can be added later if needed.Add authz to
AuthConfigUpdate
BuildConfig()Sources[]fromCRD spec.Sources(each source maps 1:1, same as today's registry→source mapping)Registries[]fromCRD spec.Registries(name + source refs + claims)apiextensionsv1.JSONclaims →map[string]any, validate values arestringor[]stringmap[string]anyPublicPathsandAuthzfrom CRD to configRegistryNamefrom config outputToConfigMapWithContentChecksum()to use MCPRegistry name directly (instead ofconfig.RegistryName)Test changes
File:
cmd/thv-operator/pkg/registryapi/config/config_test.goAll tests need updating:
Registriesin CRD spec withSources+RegistriesSources[]andRegistries[]in output3. Wiring Changes (PR 3)
Controller
File:
cmd/thv-operator/controllers/mcpregistry_controller.gomcpRegistry.Spec.RegistriestomcpRegistry.Spec.SourcesSpec.Sourcesinstead ofSpec.RegistriesDeployment
File:
cmd/thv-operator/pkg/registryapi/deployment.goMinimal changes — ConfigMap mount path stays the same (
/config/config.yaml). Config hash calculation still uses full spec.PodTemplateSpec Builder
File:
cmd/thv-operator/pkg/registryapi/podtemplatespec.goThis is the most impacted wiring file (~600 lines):
WithRegistrySourceMounts(containerName, registries []MCPRegistryConfig)→ change parameter type to[]MCPRegistrySourceConfigSpec.Sourcesfor ConfigMap/PVC volume mountsWithGitAuthMount()iterates sources for git auth secretsSpec.SourcesExamples
Update example MCPRegistry manifests in
examples/operator/mcp-registries/:mcpregistry-multi-source.yaml→ v2 format with sources + registriesDocumentation
File:
cmd/thv-operator/REGISTRY.md— update for v2 CRD fields4. Out of Scope (Future PRs)
These server features are noted but not included in this change:
FileConfig.URL/FileConfig.Datafile.url,file.dataTelemetryconfigtelemetryDynamicAuth(AWS RDS IAM)database.dynamicAuthMaxMetaSizedatabase.maxMetaSize5. Migration / Backward Compatibility
This is a breaking CRD change. The
spec.registriesfield changes meaning (from source definitions to registry views referencing sources).Since this is v1alpha1 (explicitly unstable), an in-place update is acceptable. Existing MCPRegistry resources will need updating to the new CRD shape.
Migration example
Before (v1):
After (v2):
Document the migration in release notes.
6. Impact on Other Components
7. Files Modified (per PR)
PR 1: CRD Types
cmd/thv-operator/api/v1alpha1/mcpregistry_types.gocmd/thv-operator/api/v1alpha1/zz_generated.deepcopy.gocmd/thv-operator/config/crd/bases/PR 2: Config Generation
cmd/thv-operator/pkg/registryapi/config/config.gocmd/thv-operator/pkg/registryapi/config/config_test.goPR 3: Wiring
cmd/thv-operator/controllers/mcpregistry_controller.gocmd/thv-operator/pkg/registryapi/deployment.gocmd/thv-operator/pkg/registryapi/podtemplatespec.goexamples/operator/mcp-registries/*.yamlcmd/thv-operator/REGISTRY.md8. Verification
task operator-generate && task operator-manifests— regenerate deepcopy and CRD schemastask crdref-gen(fromcmd/thv-operator/) — regenerate API docstask operator-test— all unit tests passGenerated with Claude Code
Align MCPRegistry CRD with registry server v2 config format
Align MCPRegistry CRD with registry server v2 config format
Align MCPRegistry CRD with registry server v2 config format
Align MCPRegistry CRD with registry server v2 config format (#4653)