- Notifications
You must be signed in to change notification settings - Fork 156
Implement discovered mode for vMCP authentication #2747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
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 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 #2747 +/- ## ========================================== + Coverage 55.96% 56.18% +0.21% ========================================== Files 318 318 Lines 30677 30733 +56 ========================================== + Hits 17168 17266 +98 + Misses 12022 11973 -49 - Partials 1487 1494 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d58778c to ba6c538 Compare Large PR justification has been provided. Thank you!
| ✅ Large PR justification has been provided. The size review has been dismissed and this PR can now proceed with normal review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements discovered mode for VirtualMCPServer authentication, enabling vMCP to automatically discover and apply authentication configurations from backend MCPServer ExternalAuthConfigRefs at runtime. This allows backends with heterogeneous authentication strategies (OAuth 2.0 token exchange, API key header injection, or no auth) to coexist in the same MCPGroup.
Key Changes:
- Added
DiscoverAndResolveAuth()function in converters package to fetch MCPExternalAuthConfig from Kubernetes and resolve secrets dynamically - Implemented
discoverAuthConfig()in k8s workload discoverer to populate backend AuthStrategy and AuthMetadata fields during discovery - Added
applyAuthConfigToBackend()method in aggregator discoverer to handle auth source mode logic (discovered/mixed/inline)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/vmcp/auth/converters/interface.go | Adds DiscoverAndResolveAuth() function to fetch and convert MCPExternalAuthConfig to auth strategy metadata with secret resolution |
pkg/vmcp/workloads/k8s.go | Implements discoverAuthConfig() to populate backend auth fields from ExternalAuthConfigRef during workload discovery |
pkg/vmcp/aggregator/discoverer.go | Adds applyAuthConfigToBackend() to decide which auth to use based on source mode (discovered/mixed/inline) |
pkg/vmcp/workloads/k8s_test.go | Comprehensive unit tests covering token exchange, header injection, no auth, and error scenarios (9 test cases) |
test/e2e/thv-operator/virtualmcp/virtualmcp_auth_discovery_test.go | E2E test validating discovered auth with real MCP requests, tool aggregation, and heterogeneous auth backends |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
test/e2e/thv-operator/virtualmcp/virtualmcp_auth_discovery_test.go Outdated Show resolved Hide resolved
test/e2e/thv-operator/virtualmcp/virtualmcp_auth_discovery_test.go Outdated Show resolved Hide resolved
Add runtime authentication discovery for VirtualMCPServer, enabling vMCP to automatically discover and apply authentication configurations from backend MCPServer ExternalAuthConfigRefs. Changes: - Add DiscoverAndResolveAuth() function in converters package to fetch and convert MCPExternalAuthConfig to auth strategy metadata with dynamic secret resolution from Kubernetes - Implement discoverAuthConfig() in k8s workload discoverer to populate backend AuthStrategy and AuthMetadata fields from ExternalAuthConfigRef - Add applyAuthConfigToBackend() method in aggregator discoverer to decide which auth to use based on source mode (discovered/mixed/inline) - Add comprehensive unit tests for auth discovery scenarios (token exchange, header injection, no auth, error cases) - Add e2e test validating discovered auth with real MCP requests, tool aggregation, and tool calls through VirtualMCPServer The discovered mode allows backends with heterogeneous authentication (OAuth 2.0 token exchange, API key header injection, or no auth) to coexist in the same group, with vMCP automatically discovering and applying the appropriate auth to each backend request. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ba6c538 to c977a17 Compare | @claude Please review this PR |
| Claude finished @tgrunnagle's task —— View job PR Review: Discovered Mode for vMCP AuthenticationReview Complete ✓OverviewThis PR implements runtime authentication discovery for VirtualMCPServer, enabling vMCP to automatically discover and apply authentication configurations from backend MCPServer ExternalAuthConfigRefs. The implementation is well-structured and follows ToolHive's architecture patterns. Code Quality & ArchitectureStrengths
Issues & Recommendations1. Error Message Missing Namespace Context |
Add runtime authentication discovery for VirtualMCPServer, enabling vMCP
to automatically discover and apply authentication configurations from
backend MCPServer ExternalAuthConfigRefs.
Changes:
The discovered mode allows backends with heterogeneous authentication
(OAuth 2.0 token exchange, API key header injection, or no auth) to
coexist in the same group, with vMCP automatically discovering and
applying the appropriate auth to each backend request.
🤖 Generated with Claude Code
Large PR Justification
This PR implements the "discovered" mode for vMCP authentication, which requires atomic changes across multiple interconnected components:
Why this must be large:
Atomic feature implementation: The discovered auth mode requires coordinated changes across three core subsystems that must work together:
Splitting these would create non-functional intermediate states.
Comprehensive test coverage: Includes unit tests (9 test cases, ~490 lines) and e2e test (~620 lines) that validate the entire flow with real
Kubernetes resources and MCP protocol requests. Tests cannot be added separately without the implementation.
Multi-auth support: Handles heterogeneous authentication (OAuth 2.0, API keys, no auth) in a single group, requiring all converter logic
present simultaneously.
Lines breakdown:
The size delivers a complete, testable, production-ready feature atomically.