Skip to content

Remove deprecated fields from MCPServer and MCPRemoteProxy CRDs - #4467

Merged
ChrisJBurns merged 3 commits into
mainfrom
cburns/remove-deprecated-crd-fields
Mar 31, 2026
Merged

ChrisJBurns merged 3 commits into
mainfrom
cburns/remove-deprecated-crd-fields

Conversation

@ChrisJBurns

@ChrisJBurns ChrisJBurns commented Mar 31, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The v1alpha2 API is a breaking change, making this the right time to remove deprecated CRD fields that were retained during v1alpha1 for backward compatibility. Keeping them creates API ambiguity and, in the case of clientSecret, a security liability (plaintext secrets in CRD specs visible in etcd and audit logs).

  • Remove 6 deprecated fields: MCPServer.spec.port, targetPort, toolsFilter, InlineOIDCConfig.clientSecret, thvCABundlePath, and MCPRemoteProxy.spec.port
  • Simplify GetProxyPort() and GetMcpPort() helpers to use only the canonical fields
  • Update all controllers, OIDC resolver, vMCP converter, export logic, and tests
  • Regenerate CRD schemas, deepcopy, and API docs
  • Update example manifests

Fixes #4250

Type of change

  • Refactoring (no behavior change)

Test plan

  • Unit tests (task test)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Verified go build ./... and go vet ./... pass cleanly. Ran unit tests for all 7 changed packages (api/v1alpha1, controllers, pkg/oidc, pkg/vmcpconfig, pkg/controllerutil, pkg/export, pkg/vmcp/workloads) — all pass. Integration tests require kubebuilder/etcd which is not available locally. Confirmed no deprecated field references remain in production Go code, CRD YAML schemas, or example manifests.

Changes

File Change
cmd/thv-operator/api/v1alpha1/mcpserver_types.go Remove Port, TargetPort, ToolsFilter from MCPServerSpec; remove ClientSecret, ThvCABundlePath from InlineOIDCConfig; simplify GetProxyPort(), GetMcpPort()
cmd/thv-operator/api/v1alpha1/mcpremoteproxy_types.go Remove Port from MCPRemoteProxySpec; simplify GetProxyPort()
cmd/thv-operator/api/v1alpha1/zz_generated.deepcopy.go Remove ToolsFilter deepcopy block
cmd/thv-operator/controllers/mcpserver_runconfig.go ToolsFilter now only from MCPToolConfig, not inline
cmd/thv-operator/controllers/virtualmcpserver_deployment.go Remove generated-secret branch for inline ClientSecret
cmd/thv-operator/pkg/oidc/resolver.go Remove inline ClientSecret/ThvCABundlePath handling
cmd/thv-operator/pkg/vmcpconfig/converter.go Only check ClientSecretRef, not inline ClientSecret
pkg/export/k8s.go Remove ToolsFilter export (requires MCPToolConfig now)
pkg/vmcp/workloads/k8s.go Use GetProxyPort() instead of direct field access with fallback
deploy/charts/operator-crds/** Regenerated CRD schemas (6 files)
docs/operator/crd-api.md Regenerated API reference docs
examples/operator/** Update 5 example manifests to use canonical fields
*_test.go (14 files) Update all tests to use canonical fields

Does this introduce a user-facing change?

Yes. Users referencing deprecated field names in MCPServer or MCPRemoteProxy manifests must migrate to the canonical replacements. See migration guide below.

Migration Guide

Field Mappings

Removed Field Replacement Resource
spec.port spec.proxyPort MCPServer
spec.targetPort spec.mcpPort MCPServer
spec.tools (ToolsFilter) spec.toolConfigRef + MCPToolConfig MCPServer
spec.oidcConfig.inline.clientSecret spec.oidcConfig.inline.clientSecretRef MCPServer, MCPRemoteProxy, VirtualMCPServer
spec.oidcConfig.inline.thvCABundlePath spec.oidcConfig.inline.caBundleRef MCPServer, MCPRemoteProxy, VirtualMCPServer
spec.port spec.proxyPort MCPRemoteProxy

Port fields (port → proxyPort, targetPort → mcpPort)

Replace directly in your manifests:

# Before
spec:
  port: 9090
  targetPort: 3000

# After
spec:
  proxyPort: 9090
  mcpPort: 3000

Tools filter (tools → toolConfigRef + MCPToolConfig)

Create a separate MCPToolConfig resource and reference it:

# Before
apiVersion: toolhive.stacklok.dev/v1alpha1
kind: MCPServer
metadata:
  name: my-server
spec:
  tools:
    - fetch
    - search

# After
apiVersion: toolhive.stacklok.dev/v1alpha1
kind: MCPToolConfig
metadata:
  name: my-server-tools
spec:
  toolsFilter:
    - fetch
    - search
---
apiVersion: toolhive.stacklok.dev/v1alpha1
kind: MCPServer
metadata:
  name: my-server
spec:
  toolConfigRef:
    name: my-server-tools

Client secret (clientSecret → clientSecretRef)

Store the client secret in a Kubernetes Secret and reference it:

# Before
spec:
  oidcConfig:
    type: inline
    inline:
      issuer: "https://auth.example.com"
      clientId: "my-client"
      clientSecret: "my-secret-value"

# After
apiVersion: v1
kind: Secret
metadata:
  name: oidc-client-secret
type: Opaque
stringData:
  client-secret: "my-secret-value"
---
spec:
  oidcConfig:
    type: inline
    inline:
      issuer: "https://auth.example.com"
      clientId: "my-client"
      clientSecretRef:
        name: oidc-client-secret
        key: client-secret

CA bundle path (thvCABundlePath → caBundleRef)

Store the CA certificate in a ConfigMap and reference it:

# Before
spec:
  oidcConfig:
    type: inline
    inline:
      thvCABundlePath: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"

# After
apiVersion: v1
kind: ConfigMap
metadata:
  name: oidc-ca-bundle
data:
  ca.crt: |
    -----BEGIN CERTIFICATE-----
    ...
    -----END CERTIFICATE-----
---
spec:
  oidcConfig:
    type: inline
    inline:
      caBundleRef:
        configMapRef:
          name: oidc-ca-bundle
          key: ca.crt

ToolHive automatically mounts the ConfigMap and computes the CA bundle path.

Special notes for reviewers

  • The resolved OIDCConfig struct in pkg/oidc/resolver.go intentionally retains ClientSecret and ThvCABundlePath fields — these are internal resolved values used by the ConfigMap OIDC path, not CRD fields.
  • The if port > 0 check in pkg/vmcp/workloads/k8s.go after GetProxyPort() is now technically always true (returns >= 8080), but is harmless and left for clarity.
  • CRD YAML schemas were regenerated via task operator-manifests; API docs via task crdref-gen.

Generated with Claude Code

The v1alpha2 API is a breaking change and the right time to drop
deprecated fields that were retained for backward compatibility.

Remove six deprecated CRD fields and their fallback helper logic:
- MCPServer.spec.port → use proxyPort
- MCPServer.spec.targetPort → use mcpPort
- MCPServer.spec.toolsFilter → use toolConfigRef + MCPToolConfig
- InlineOIDCConfig.clientSecret → use clientSecretRef (SecretKeyRef)
- InlineOIDCConfig.thvCABundlePath → use caBundleRef (ConfigMap)
- MCPRemoteProxy.spec.port → use proxyPort

Simplify GetProxyPort() and GetMcpPort() helpers to use only the
canonical fields. Update all controllers, OIDC resolver, vMCP
converter, export logic, tests, CRD schemas, examples, and docs.

Fixes #4250

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@github-actions github-actions Bot added the size/XL Extra large PR: 1000+ lines changed label Mar 31, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 transformation

Alternative:

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.

The migration notes are better suited for the PR description where
they are visible to reviewers alongside the breaking change context.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@github-actions github-actions Bot removed the size/XL Extra large PR: 1000+ lines changed label Mar 31, 2026
@github-actions
github-actions Bot dismissed their stale review March 31, 2026 20:57

PR size has been reduced below the XL threshold. Thank you for splitting this up!

@github-actions

Copy link
Copy Markdown
Contributor

✅ PR size has been reduced below the XL threshold. The size review has been dismissed and this PR can now proceed with normal review. Thank you for splitting this up!

@github-actions github-actions Bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Mar 31, 2026
@codecov

codecov Bot commented Mar 31, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.62%. Comparing base (e69251a) to head (129cc37).
⚠️ Report is 27 commits behind head on main.

Files with missing lines Patch % Lines
.../thv-operator/api/v1alpha1/mcpremoteproxy_types.go 0.00% 1 Missing ⚠️
pkg/vmcp/workloads/k8s.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4467      +/-   ##
==========================================
- Coverage   69.64%   69.62%   -0.03%     
==========================================
  Files         491      491              
  Lines       50304    50270      -34     
==========================================
- Hits        35036    34999      -37     
- Misses      12580    12592      +12     
+ Partials     2688     2679       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Mar 31, 2026
@ChrisJBurns
ChrisJBurns merged commit 029ecbd into main Mar 31, 2026
51 of 55 checks passed
@ChrisJBurns
ChrisJBurns deleted the cburns/remove-deprecated-crd-fields branch March 31, 2026 23:44
@ChrisJBurns ChrisJBurns added the breaks-compatibility A change that breaks compatibility with a previous release label Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaks-compatibility A change that breaks compatibility with a previous release size/L Large PR: 600-999 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove Deprecated Fields

2 participants