Skip to content

Align MCPRegistry CRD with registry server v2 config format #4572

Closed

Description

@rdimitrov

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 separate spec.sources (data sources) and spec.registries (lightweight views referencing sources by name)
  • Add claims field to both source and registry configs
  • Add managed and kubernetes (with namespaces) source types
  • Add spec.authConfig.authz.roles with superAdmin, manageSources, manageRegistries, manageEntries

Config generation (pkg/registryapi/config/config.go)

  • Update Config struct 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.sources instead of spec.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:

Activity

  1. added
    enhancement
    go
    kubernetes
    api
    on Apr 6, 2026
  2. self-assigned this
    on Apr 6, 2026
  3. rdimitrov commented on Apr 6, 2026

    @rdimitrov
    MemberAuthor

    Plan:

    # Operator MCPRegistry CRD v2 Alignment
    
    **Tracking issue**: stacklok/toolhive#4572
    
    ## 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 has moved to v2 (separate `sources[]` and `registries[]` 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/toolhive`
    **Affected files**: `cmd/thv-operator/` subtree
    
    ---
    
    ## 1. CRD Type Changes
    
    **File**: `cmd/thv-operator/api/v1alpha1/mcpregistry_types.go`
    
    ### Replace `Registries` with `Sources` + `Registries`
    
    ```go
    type MCPRegistrySpec struct {
        DisplayName    string                    `json:"displayName,omitempty"`
        Sources        []MCPRegistrySourceConfig `json:"sources"`        // NEW: data source definitions
        Registries     []MCPRegistryViewConfig   `json:"registries"`     // CHANGED: registry views
        EnforceServers bool                      `json:"enforceServers,omitempty"`
        PodTemplateSpec *runtime.RawExtension    `json:"podTemplateSpec,omitempty"`
        DatabaseConfig *MCPRegistryDatabaseConfig `json:"databaseConfig,omitempty"`
        AuthConfig     *MCPRegistryAuthConfig    `json:"authConfig,omitempty"`
    }

    New MCPRegistrySourceConfig (replaces old MCPRegistryConfig)

    type MCPRegistrySourceConfig struct {
        Name         string                         `json:"name"`
        Format       string                         `json:"format,omitempty"`
        Claims       map[string]string              `json:"claims,omitempty"`      // NEW
        ConfigMapRef *corev1.ConfigMapKeySelector    `json:"configMapRef,omitempty"`
        Git          *GitSource                     `json:"git,omitempty"`
        API          *APISource                     `json:"api,omitempty"`
        PVCRef       *PVCSource                     `json:"pvcRef,omitempty"`
        Managed      *ManagedSource                 `json:"managed,omitempty"`     // NEW
        Kubernetes   *KubernetesSource              `json:"kubernetes,omitempty"` // NEW (explicit)
        SyncPolicy   *SyncPolicy                    `json:"syncPolicy,omitempty"`
        Filter       *RegistryFilter                `json:"filter,omitempty"`
    }

    New MCPRegistryViewConfig (lightweight registry view)

    type MCPRegistryViewConfig struct {
        Name    string            `json:"name"`
        Sources []string          `json:"sources"`              // ordered source refs
        Claims  map[string]string `json:"claims,omitempty"`     // registry access gate
    }

    New source types

    type ManagedSource struct {
        // Empty — presence indicates this is a managed (internal) source for publishing
    }
    
    type KubernetesSource struct {
        Namespaces []string `json:"namespaces,omitempty"`
    }

    Add authz roles to auth config

    type MCPRegistryAuthConfig struct {
        Mode  MCPRegistryAuthMode  `json:"mode,omitempty"`
        OAuth *MCPRegistryOAuthConfig `json:"oauth,omitempty"`
        Authz *MCPRegistryAuthzConfig `json:"authz,omitempty"`  // NEW
    }
    
    type MCPRegistryAuthzConfig struct {
        Roles MCPRegistryRolesConfig `json:"roles"`
    }
    
    type MCPRegistryRolesConfig struct {
        SuperAdmin       []map[string]any `json:"superAdmin,omitempty"`
        ManageSources    []map[string]any `json:"manageSources,omitempty"`
        ManageRegistries []map[string]any `json:"manageRegistries,omitempty"`
        ManageEntries    []map[string]any `json:"manageEntries,omitempty"`
    }

    Note: Claims on CRD use map[string]string (K8s CRD limitation — no any). The config
    generator converts to map[string]any for the registry server config. For array claim
    values, 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 arbitrary
    types. 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.go

    Update Config struct to v2 format

    type Config struct {
        Sources    []SourceConfig   `yaml:"sources"`
        Registries []RegistryConfig `yaml:"registries"`
        Database   *DatabaseConfig  `yaml:"database,omitempty"`
        Auth       *AuthConfig      `yaml:"auth,omitempty"`
    }

    New SourceConfig (replaces old RegistryConfig)

    type SourceConfig struct {
        Name       string            `yaml:"name"`
        Format     string            `yaml:"format,omitempty"`
        Claims     map[string]any    `yaml:"claims,omitempty"`
        Git        *GitConfig        `yaml:"git,omitempty"`
        API        *APIConfig        `yaml:"api,omitempty"`
        File       *FileConfig       `yaml:"file,omitempty"`
        Managed    *ManagedConfig    `yaml:"managed,omitempty"`
        Kubernetes *KubernetesConfig `yaml:"kubernetes,omitempty"`
        SyncPolicy *SyncPolicyConfig `yaml:"syncPolicy,omitempty"`
        Filter     *FilterConfig     `yaml:"filter,omitempty"`
    }

    New RegistryConfig (lightweight view)

    type RegistryConfig struct {
        Name    string         `yaml:"name"`
        Sources []string       `yaml:"sources"`
        Claims  map[string]any `yaml:"claims,omitempty"`
    }

    New source type configs

    type ManagedConfig struct{}
    
    type KubernetesConfig struct {
        Namespaces []string `yaml:"namespaces,omitempty"`
    }

    Add authz to AuthConfig

    type AuthConfig struct {
        Mode  AuthMode     `yaml:"mode,omitempty"`
        OAuth *OAuthConfig `yaml:"oauth,omitempty"`
        Authz *AuthzConfig `yaml:"authz,omitempty"`
    }
    
    type AuthzConfig struct {
        Roles RolesConfig `yaml:"roles"`
    }
    
    type RolesConfig struct {
        SuperAdmin       []map[string]any `yaml:"superAdmin,omitempty"`
        ManageSources    []map[string]any `yaml:"manageSources,omitempty"`
        ManageRegistries []map[string]any `yaml:"manageRegistries,omitempty"`
        ManageEntries    []map[string]any `yaml:"manageEntries,omitempty"`
    }

    Update BuildConfig()

    • Build Sources[] from CRD spec.Sources (each source config maps 1:1)
    • Build Registries[] from CRD spec.Registries (name + source refs + claims)
    • Remove hardcoded default K8s registry — user defines it explicitly
    • Remove top-level RegistryName — v2 uses named registries
    • Map authz roles from CRD to config

    3. Deployment Changes

    File: cmd/thv-operator/pkg/registryapi/deployment.go

    Minimal changes — ConfigMap mount path stays the same (/config/config.yaml). The registry
    server 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.go

    • Update references from mcpRegistry.Spec.Registries to mcpRegistry.Spec.Sources and
      mcpRegistry.Spec.Registries (new types)
    • ConfigMap source mounting iterates Spec.Sources instead of Spec.Registries
    • Volume mount logic for Git auth secrets, ConfigMaps, PVCs iterates sources

    5. Test Changes

    File: cmd/thv-operator/pkg/registryapi/config/config_test.go

    All tests need updating:

    • Replace Registries in CRD spec with Sources + Registries
    • Update assertions to check Sources[] and Registries[] in output
    • New test cases: claims mapping, authz roles, managed source, kubernetes namespaces,
      multiple sources per registry, name validation

    6. CRD Schema / Validation

    • Add kubebuilder validation markers for new fields
    • Sources min 1 item required
    • Registries min 1 item required
    • Each registry's Sources refs must be valid source names
    • At most one Managed source allowed
    • Source types remain mutually exclusive (exactly one of git/api/file/managed/kubernetes/configmapref/pvcref)
    • Regenerate CRD manifests: make generate && make manifests

    7. Migration / Backward Compatibility

    This is a breaking CRD change. The spec.registries field changes meaning (from
    source+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

    • Registry server: No changes — it already expects v2 config
    • Helm chart: No changes — it already generates v2 config via passthrough
    • Demo sandbox: MCPRegistry manifests need updating to v2 CRD shape
    • Documentation: REGISTRY.md needs updating for v2 CRD fields

    Files Modified (toolhive repo)

    File Change
    api/v1alpha1/mcpregistry_types.go New Sources/Registries CRD types, claims, authz, managed/k8s source types
    api/v1alpha1/zz_generated.deepcopy.go Regenerated
    pkg/registryapi/config/config.go v2 Config/SourceConfig/RegistryConfig structs, updated BuildConfig
    pkg/registryapi/config/config_test.go All tests updated for v2 structure
    pkg/registryapi/deployment.go Source mount iteration (minor)
    controllers/mcpregistry_controller.go Source iteration, volume mounts
    config/crd/bases/ Regenerated CRD manifests
    REGISTRY.md Updated docs

    Verification

    1. make generate && make manifests — regenerate deepcopy and CRD schemas
    2. make test — all tests pass
    3. Deploy to Kind cluster with v2 MCPRegistry CRD → verify generated ConfigMap has v2 format
    4. Registry server reads the config and starts correctly
    5. Sources with claims → entries inherit claims
    6. Registries with claims → access gate works
  4. rdimitrov commented on Apr 7, 2026

    @rdimitrov
    MemberAuthor

    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 (separate sources[] and registries[] 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/toolhive
    Registry server repo: stacklok/toolhive-registry-server
    Affected subtree: cmd/thv-operator/

    v2 Server Config Reference

    The registry server (toolhive-registry-server/internal/config/config.go) expects:

    type Config struct {
        Sources    []SourceConfig    `yaml:"sources"`
        Registries []RegistryConfig  `yaml:"registries,omitempty"`
        Database   *DatabaseConfig   `yaml:"database,omitempty"`
        Auth       *AuthConfig       `yaml:"auth,omitempty"`
        Telemetry  *telemetry.Config `yaml:"telemetry,omitempty"`
    }

    Where SourceConfig has: Name, Format, Git/API/File/Managed/Kubernetes (exactly one), SyncPolicy, Filter, Claims (map[string]any, values must be string or []string).
    Where RegistryConfig has: 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:

    PR Scope Files
    PR 1: CRD Types New source/registry types, claims, authz, managed/k8s sources mcpregistry_types.go, zz_generated.deepcopy.go, CRD manifests
    PR 2: Config Generation v2 Config structs, updated BuildConfig, all tests config/config.go, config/config_test.go
    PR 3: Wiring Controller, deployment, podtemplatespec, examples, docs mcpregistry_controller.go, deployment.go, podtemplatespec.go, examples, REGISTRY.md

    PRs are sequential — each builds on the previous.


    1. CRD Type Changes (PR 1)

    File: cmd/thv-operator/api/v1alpha1/mcpregistry_types.go

    Replace Registries with Sources + Registries

    type MCPRegistrySpec struct {
        DisplayName     string                    `json:"displayName,omitempty"`
        Sources         []MCPRegistrySourceConfig `json:"sources"`
        Registries      []MCPRegistryViewConfig   `json:"registries"`
        EnforceServers  bool                      `json:"enforceServers,omitempty"`
        PodTemplateSpec *runtime.RawExtension     `json:"podTemplateSpec,omitempty"`
        DatabaseConfig  *MCPRegistryDatabaseConfig `json:"databaseConfig,omitempty"`
        AuthConfig      *MCPRegistryAuthConfig    `json:"authConfig,omitempty"`
    }

    New MCPRegistrySourceConfig (replaces old MCPRegistryConfig)

    type MCPRegistrySourceConfig struct {
        Name         string                          `json:"name"`
        Format       string                          `json:"format,omitempty"`
        Claims       *apiextensionsv1.JSON           `json:"claims,omitempty"`
        ConfigMapRef *corev1.ConfigMapKeySelector     `json:"configMapRef,omitempty"`
        Git          *GitSource                      `json:"git,omitempty"`
        API          *APISource                      `json:"api,omitempty"`
        PVCRef       *PVCSource                      `json:"pvcRef,omitempty"`
        Managed      *ManagedSource                  `json:"managed,omitempty"`
        Kubernetes   *KubernetesSource               `json:"kubernetes,omitempty"`
        SyncPolicy   *SyncPolicy                     `json:"syncPolicy,omitempty"`
        Filter       *RegistryFilter                 `json:"filter,omitempty"`
    }

    New MCPRegistryViewConfig (lightweight registry view)

    type MCPRegistryViewConfig struct {
        Name    string                `json:"name"`
        Sources []string              `json:"sources"`
        Claims  *apiextensionsv1.JSON `json:"claims,omitempty"`
    }

    Claims typing: apiextensionsv1.JSON

    Use apiextensionsv1.JSON (from k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1) for both Claims fields. This preserves type fidelity with the server's map[string]any (where values are string or []string) without CSV parsing hacks. The config generator unmarshals the raw JSON and validates that values are string or []string before emitting map[string]any in the YAML config.

    Add kubebuilder marker +kubebuilder:validation:Type=object and +kubebuilder:pruning:PreserveUnknownFields to allow arbitrary JSON.

    New source types

    type ManagedSource struct {
        // Empty — presence indicates this is a managed (internal) source
    }
    
    type KubernetesSource struct {
        // Namespaces to watch for MCP servers
        // If empty, watches the operator's configured namespace
        Namespaces []string `json:"namespaces,omitempty"`
    }

    Add authz to auth config

    type MCPRegistryAuthConfig struct {
        Mode        MCPRegistryAuthMode        `json:"mode,omitempty"`
        PublicPaths []string                   `json:"publicPaths,omitempty"`  // NEW
        OAuth       *MCPRegistryOAuthConfig    `json:"oauth,omitempty"`
        Authz       *MCPRegistryAuthzConfig    `json:"authz,omitempty"`       // NEW
    }
    
    type MCPRegistryAuthzConfig struct {
        Roles MCPRegistryRolesConfig `json:"roles,omitempty"`
    }
    
    type MCPRegistryRolesConfig struct {
        SuperAdmin       []apiextensionsv1.JSON `json:"superAdmin,omitempty"`
        ManageSources    []apiextensionsv1.JSON `json:"manageSources,omitempty"`
        ManageRegistries []apiextensionsv1.JSON `json:"manageRegistries,omitempty"`
        ManageEntries    []apiextensionsv1.JSON `json:"manageEntries,omitempty"`
    }

    Each role entry is apiextensionsv1.JSON rather than []map[string]any — this gives CRD schema flexibility while keeping the API typed. The config generator deserializes each entry to map[string]any for the server config.

    Kubebuilder validation markers

    • Sources: +kubebuilder:validation:MinItems=1, +listType=map, +listMapKey=name
    • Registries: +kubebuilder:validation:MinItems=1, +listType=map, +listMapKey=name
    • Source types remain mutually exclusive (exactly one of git/api/configmapref/pvcref/managed/kubernetes)
    • At most one Managed source allowed (CEL validation rule)
    • Each registry's Sources refs must be valid source names (CEL validation rule, or validated in controller)

    Auto-default Kubernetes source behavior

    If the user defines no KubernetesSource in spec.sources, the config generator auto-injects a default Kubernetes source named "default" and prepends it to the first registry's sources list. This preserves backward compatibility for MCP server discovery. If the user explicitly defines a KubernetesSource, no auto-injection occurs.


    2. Config Generation Changes (PR 2)

    File: cmd/thv-operator/pkg/registryapi/config/config.go

    Update Config struct to v2 format

    type Config struct {
        Sources    []SourceConfig   `yaml:"sources"`
        Registries []RegistryConfig `yaml:"registries,omitempty"`
        Database   *DatabaseConfig  `yaml:"database,omitempty"`
        Auth       *AuthConfig      `yaml:"auth,omitempty"`
    }

    Remove RegistryName — v2 uses named registries, not a top-level name.

    New SourceConfig (replaces old RegistryConfig)

    type SourceConfig struct {
        Name       string            `yaml:"name"`
        Format     string            `yaml:"format,omitempty"`
        Claims     map[string]any    `yaml:"claims,omitempty"`
        Git        *GitConfig        `yaml:"git,omitempty"`
        API        *APIConfig        `yaml:"api,omitempty"`
        File       *FileConfig       `yaml:"file,omitempty"`
        Managed    *ManagedConfig    `yaml:"managed,omitempty"`
        Kubernetes *KubernetesConfig `yaml:"kubernetes,omitempty"`
        SyncPolicy *SyncPolicyConfig `yaml:"syncPolicy,omitempty"`
        Filter     *FilterConfig     `yaml:"filter,omitempty"`
    }

    New RegistryConfig (lightweight view)

    type RegistryConfig struct {
        Name    string         `yaml:"name"`
        Sources []string       `yaml:"sources"`
        Claims  map[string]any `yaml:"claims,omitempty"`
    }

    New source type configs

    type ManagedConfig struct{}
    
    type KubernetesConfig struct {
        Namespaces []string `yaml:"namespaces,omitempty"`
    }

    Updated FileConfig (match server)

    type FileConfig struct {
        Path    string `yaml:"path,omitempty"`
        URL     string `yaml:"url,omitempty"`     // NEW: HTTP/HTTPS URL source
        Data    string `yaml:"data,omitempty"`     // NEW: inline JSON data
        Timeout string `yaml:"timeout,omitempty"` // NEW: HTTP timeout for URL
    }

    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 AuthConfig

    type AuthConfig struct {
        Mode        AuthMode     `yaml:"mode,omitempty"`
        PublicPaths []string     `yaml:"publicPaths,omitempty"` // NEW
        OAuth       *OAuthConfig `yaml:"oauth,omitempty"`
        Authz       *AuthzConfig `yaml:"authz,omitempty"`       // NEW
    }
    
    type AuthzConfig struct {
        Roles RolesConfig `yaml:"roles,omitempty"`
    }
    
    type RolesConfig struct {
        SuperAdmin       []map[string]any `yaml:"superAdmin,omitempty"`
        ManageSources    []map[string]any `yaml:"manageSources,omitempty"`
        ManageRegistries []map[string]any `yaml:"manageRegistries,omitempty"`
        ManageEntries    []map[string]any `yaml:"manageEntries,omitempty"`
    }

    Update BuildConfig()

    1. Build Sources[] from CRD spec.Sources (each source maps 1:1, same as today's registry→source mapping)
    2. Build Registries[] from CRD spec.Registries (name + source refs + claims)
    3. Auto-inject default Kubernetes source if none defined (see section 1)
    4. Deserialize apiextensionsv1.JSON claims → map[string]any, validate values are string or []string
    5. Deserialize role entries → map[string]any
    6. Map PublicPaths and Authz from CRD to config
    7. Remove RegistryName from config output
    8. Update ToConfigMapWithContentChecksum() to use MCPRegistry name directly (instead of config.RegistryName)

    Test changes

    File: cmd/thv-operator/pkg/registryapi/config/config_test.go

    All tests need updating:

    • Replace Registries in CRD spec with Sources + Registries
    • Update assertions to check Sources[] and Registries[] in output
    • New test cases:
      • Claims deserialization and validation (string, []string, invalid types)
      • Authz roles mapping
      • Managed source
      • Kubernetes source with namespaces
      • Multiple sources per registry
      • Auto-default Kubernetes source injection
      • Source name ref validation in registries

    3. Wiring Changes (PR 3)

    Controller

    File: cmd/thv-operator/controllers/mcpregistry_controller.go

    • Update references from mcpRegistry.Spec.Registries to mcpRegistry.Spec.Sources
    • ConfigMap source mounting iterates Spec.Sources instead of Spec.Registries
    • Volume mount logic for Git auth secrets, ConfigMaps, PVCs iterates sources

    Deployment

    File: cmd/thv-operator/pkg/registryapi/deployment.go

    Minimal 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.go

    This is the most impacted wiring file (~600 lines):

    • WithRegistrySourceMounts(containerName, registries []MCPRegistryConfig) → change parameter type to []MCPRegistrySourceConfig
    • Iterate Spec.Sources for ConfigMap/PVC volume mounts
    • WithGitAuthMount() iterates sources for git auth secrets
    • All callers updated to pass Spec.Sources

    Examples

    Update example MCPRegistry manifests in examples/operator/mcp-registries/:

    • mcpregistry-multi-source.yaml → v2 format with sources + registries

    Documentation

    File: cmd/thv-operator/REGISTRY.md — update for v2 CRD fields


    4. Out of Scope (Future PRs)

    These server features are noted but not included in this change:

    Feature Server field Reason
    FileConfig.URL / FileConfig.Data file.url, file.data Not needed for operator-managed sources (ConfigMap/PVC → path)
    Telemetry config telemetry Separate concern, can be added independently
    DynamicAuth (AWS RDS IAM) database.dynamicAuth Database auth enhancement, separate PR
    MaxMetaSize database.maxMetaSize Minor config option, separate PR

    5. Migration / Backward Compatibility

    This is a breaking CRD change. The spec.registries field 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):

    spec:
      registries:
        - name: production
          format: toolhive
          configMapRef:
            name: prod-registry
            key: registry.json
          syncPolicy:
            interval: "1h"

    After (v2):

    spec:
      sources:
        - name: production
          format: toolhive
          configMapRef:
            name: prod-registry
            key: registry.json
          syncPolicy:
            interval: "1h"
      registries:
        - name: default
          sources: ["production"]

    Document the migration in release notes.


    6. Impact on Other Components

    • Registry server: No changes — it already expects v2 config
    • Helm chart: No changes — operator chart passes through CRD values
    • Demo sandbox: MCPRegistry manifests need updating to v2 CRD shape
    • Documentation: REGISTRY.md needs updating for v2 CRD fields

    7. Files Modified (per PR)

    PR 1: CRD Types

    File Change
    cmd/thv-operator/api/v1alpha1/mcpregistry_types.go New Sources/Registries types, claims (apiextensionsv1.JSON), authz, managed/k8s sources, publicPaths
    cmd/thv-operator/api/v1alpha1/zz_generated.deepcopy.go Regenerated
    cmd/thv-operator/config/crd/bases/ Regenerated CRD manifests

    PR 2: Config Generation

    File Change
    cmd/thv-operator/pkg/registryapi/config/config.go v2 Config/SourceConfig/RegistryConfig structs, updated BuildConfig, claims deserialization, authz mapping
    cmd/thv-operator/pkg/registryapi/config/config_test.go All tests updated for v2 structure + new test cases

    PR 3: Wiring

    File Change
    cmd/thv-operator/controllers/mcpregistry_controller.go Source iteration, volume mounts
    cmd/thv-operator/pkg/registryapi/deployment.go Minor: pass Sources to mount builder
    cmd/thv-operator/pkg/registryapi/podtemplatespec.go WithRegistrySourceMounts takes Sources, git auth iterates sources
    examples/operator/mcp-registries/*.yaml Updated to v2 CRD shape
    cmd/thv-operator/REGISTRY.md Updated docs

    8. Verification

    1. task operator-generate && task operator-manifests — regenerate deepcopy and CRD schemas
    2. task crdref-gen (from cmd/thv-operator/) — regenerate API docs
    3. task operator-test — all unit tests pass
    4. Deploy to Kind cluster with v2 MCPRegistry CRD → verify generated ConfigMap has v2 format
    5. Registry server reads the config and starts correctly
    6. Sources with claims → entries inherit claims
    7. Registries with claims → access gate works
    8. Auto-default Kubernetes source injection works when no KubernetesSource defined

    Generated with Claude Code

  5. added 4 commits that reference this issue on Apr 7, 2026
    fee3776
    821ccda
    17f5f34
    a443469
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

apibreaking-changeenhancementgokubernetesoperator

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions