Skip to content

Conversation

JAORMX
Copy link
Collaborator

@JAORMX JAORMX commented Oct 2, 2025

Summary

Add support for exporting MCP server configurations as Kubernetes MCPServer resources with the --format flag.

Use Case

This feature enables a smooth development-to-production workflow for MCP servers:

  1. Local Development: Users can run and test MCP servers locally using thv run with various configurations (environment variables, volumes, OIDC, authorization policies, etc.)
  2. Export for Production: Once satisfied with the local configuration, users can export it as a Kubernetes manifest with thv export --format k8s
  3. Deploy to Cluster: Apply the exported manifest directly to their Kubernetes cluster for production deployment

This eliminates the need to manually recreate configurations when moving from local development to cluster deployment, reducing errors and accelerating the transition to production.

Changes

  • Add pkg/export package with k8s.go for converting RunConfig to MCPServer CRD
  • Enhance thv export command with --format flag (json/k8s)
  • Convert all RunConfig fields to appropriate MCPServer spec fields:
    • Image, transport, ports, and command arguments
    • Environment variables
    • Volume mounts
    • OIDC authentication configuration
    • Cedar authorization policies
    • Audit logging settings
    • OpenTelemetry and Prometheus telemetry
    • Tool filtering
  • Sanitize names to comply with Kubernetes naming requirements
  • Add comprehensive unit tests for all export functionality (32 tests)
  • Add e2e tests for export command with both formats
  • Fix linting issue in version.go

Test plan

  • All unit tests pass (32 new tests)
  • Linter passes
  • E2E tests created for both export formats

Usage

# Run and configure MCP server locally
thv run --name my-server \
  --env "API_KEY=secret" \
  --volume "/data:/data:ro" \
  --oidc-issuer "https://auth.example.com" \
  ghcr.io/my-org/my-mcp-server

# Test locally until satisfied...

# Export as Kubernetes MCPServer resource for production
thv export my-server ./my-server.yaml --format k8s

# Deploy to Kubernetes cluster
kubectl apply -f my-server.yaml

🤖 Generated with Claude Code

Add support for exporting MCP server configurations as Kubernetes
MCPServer resources with the --format flag. Users can now export
their running servers to K8s manifests for deployment in Kubernetes.

Changes:
- Add pkg/export package with k8s.go for converting RunConfig to MCPServer CRD
- Enhance thv export command with --format flag (json/k8s)
- Convert all RunConfig fields to appropriate MCPServer spec fields
- Handle environment variables, volumes, OIDC, authz, audit, telemetry
- Sanitize names to comply with Kubernetes naming requirements
- Add comprehensive unit tests for all export functionality
- Add e2e tests for export command with both formats

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Juan Antonio Osorio <[email protected]>
@JAORMX JAORMX force-pushed the add-k8s-export-format branch from 12741a7 to ea576eb Compare October 2, 2025 15:49
Copy link

codecov bot commented Oct 3, 2025

Codecov Report

❌ Patch coverage is 98.13665% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.58%. Comparing base (b58c533) to head (ea576eb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/export/k8s.go 98.13% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2072      +/-   ##
==========================================
+ Coverage   48.26%   48.58%   +0.31%     
==========================================
  Files         236      237       +1     
  Lines       29690    30061     +371     
==========================================
+ Hits        14331    14604     +273     
- Misses      14281    14351      +70     
- Partials     1078     1106      +28     

☔ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant