Repository navigation
Description
Problem
In a multi-upstream VirtualMCPServer, without a custom UpstreamFilter, users walk the full upstream authorization chain regardless of their identity or group membership.
A user who does not have an account on one of the upstream providers is prompted for OAuth login, which fails and blocks the entire authorization flow — even though they only need credentials from a subset of upstream providers for the backends they are entitled to use.
This is not just a UX issue but an authentication failure: a single upstream that is unavailable to a particular principal can prevent the user from accessing other backends they are authorized to use.
Background
#5724 / #5725 added the UpstreamFilter interface and the callback handler hook that consults it after the first upstream resolves.
The integration is complete — computeChain calls FilterUpstreams when a filter is present — but no concrete implementation ships with ToolHive and no CRD surface exposes the configuration.
Proposal
Provide a built-in UpstreamFilter implementation that narrows the upstream chain based on claims from the first-leg principal, initially supporting group membership.
Operators could configure a mapping from identity groups to upstream subsets, so that users in different groups walk different authorization chains.
This would also require a CRD field on VirtualMCPServer (e.g. authServerConfig.upstreamFilter) to configure the filter without requiring a custom Go build.
The exact configuration shape is open for discussion.
This proposal is intentionally limited to authentication-chain selection. It does not replace backend or tool authorization; backend-scoped Cedar authorization remains responsible for determining which backend capabilities the principal may access.
Given the OSS / Enterprise boundary described in #5383, I’d also like to confirm whether a group-aware UpstreamFilter exposed through the VirtualMCPServer CRD would fall under the Connector Gateway / Enterprise boundary as well.
Related
- authserver: filter the upstream authorization chain via a callback-handler hook #5724 / Filter upstream auth chain via callback hook #5725 —
UpstreamFilterinterface and handler hook (merged) - feat(vmcp): composing per-user federated-IdP backends behind vmcp — linked-account model or per-backend IncomingAuth overrides #5383 — per-user federated-IdP composition (linked-account model)
- Support backend-scoped Cedar authorization in VirtualMCPServer #5483 / Add backend-scoped vMCP authorization #6487 — backend-scoped Cedar authorization
Activity
hellouz818 commentedon Sep 17, 2026
I'd be happy to work on this if the approach makes sense. Happy to adjust the implementation based on maintainer feedback.
jhrozek commentedon Sep 22, 2026
I apologize for the late reply. I think the request makes sense. I'll post a high-level plan that I produced in an AI co-design session - let me know if this tracks with what you were thinking. Also let us know if this is something you'd like to work on or if you'd like some help/co-develop this feature with us.
jhrozek commentedon Sep 22, 2026
Proposed implementation direction
The existing
UpstreamFilterhook already provides the runtime enforcement we need. The missing work is a built-in group-aware implementation plus aVirtualMCPServerAPI that can configure it without custom Go code.The implementation should remain split into two layers:
The auth-server implementation should not know about Kubernetes. The operator should translate a vMCP-only CRD field into serializable auth-server configuration.
Proposed API
Keep the new field on
VirtualMCPServerSpec, besideauthServerConfig.EmbeddedAuthServerConfigis shared by other CRDs, while multi-upstream filtering is specific to vMCP.Proposed semantics:
claimis an exact top-level claim name, defaulting togroups.defaultUpstreamsis used for a valid empty claim or when no rule matches.defaultUpstreamsmeans no optional upstreams; the mandatory first provider remains.The configurable claim name supports mappings such as
groups,roles,cognito:groups, and URI-shaped custom claims. Provider-native nested claims should be mapped by the identity provider into a top-level string array for the initial implementation.Implementation steps
1. Extract reusable string-array claim decoding
ToolHive already handles
[]stringand JSON-decoded[]anyclaims in the Cedar authorizer. Extract the low-level decoding into a neutral helper rather than duplicating it.The helper should:
[]stringand[]anycontaining only strings;Cedar should adopt the helper without changing its existing behavior. The new upstream filter should use it strictly and reject malformed arrays.
Deliverables:
2. Implement the built-in group filter
Add a focused package such as
pkg/authserver/upstreamfilter.The constructor should validate:
At runtime, the filter should:
defaultUpstreamsfor a valid empty or unmatched claim.The existing callback, chain persistence, and
computeChainlogic should remain unchanged.Deliverables:
handlers.UpstreamFilter;3. Add serializable auth-server configuration
Add an optional group-filter field to
authserver.RunConfig.RunConfig.Validate()must enforce the same static invariants so direct auth-server consumers also fail at startup on invalid configuration.Update the embedded-auth runner to construct the filter and assign it to
authserver.Config.UpstreamFilter. When the field is absent,UpstreamFilterremains nil and the current full-chain behavior is preserved.Deliverables:
4. Add the VirtualMCPServer API and conversion
Add vMCP-only API types to
VirtualMCPServerSpec.Use OpenAPI markers for structural constraints and CEL for cross-field validation:
authServerConfig;Repeat security-critical checks during reconciliation because older stored resources and fake clients can bypass admission.
Invalid configuration should set
AuthServerConfigValidated=FalsewithObservedGeneration, return no retryable error, and recover toTrueafter the spec is corrected.Extend the vMCP converter after the shared
BuildAuthServerRunConfigcall, keeping that shared converter free of vMCP-only CRD concerns.Deliverables:
RunConfigconversion;5. Prove the user-visible behavior and document it
Add one functional end-to-end flow:
Document:
Deliverables:
Compatibility
This adds a new implementation of the existing
UpstreamFilterinterface. It should not change the interface, its nil behavior, or the existing handler semantics.When the new configuration is absent, ToolHive continues walking the complete upstream chain exactly as it does today.
The implementation should not introduce generic filter composition or precedence rules. The auth-server configuration selects at most one built-in upstream filter.
Suggested delivery split
RunConfig, validation, runner wiring, and auth-server tests.This keeps the auth-server capability independent of Kubernetes while giving vMCP operators the requested declarative configuration.
Sanskarzz commentedon Sep 27, 2026
Thanks for the detailed direction, @jhrozek. The separation makes sense to me:
This also fits the model in #6487, where BackendID is trusted authorization metadata rather than something inferred from provider selection.
One smaller semantics question: for a rule with multiple values such as groups: [engineering, production], should matching use any-group or all-groups semantics?
@hellouz818, since you already offered to work on this, I don’t want to step on ownership. I’d be happy to help review, create a sub-issue, or test the shared claim-decoding/Cedar regression portion and the interaction with backend-scoped authorization from #6487.
hellouz818 commentedon Sep 28, 2026
Thanks @jhrozek and @Sanskarzz — the proposed API direction and separation make sense to me.
I’d like to take the lead on implementing this issue, starting with the auth-server filter and then following through the RunConfig and VirtualMCPServer CRD integration. @jhrozek, if that works for you, could you assign the issue to me?
@Sanskarzz, thanks for offering to help. I’m happy to coordinate on the shared claim-decoding / Cedar regression portion, and later test the interaction with #6487 while keeping backend-scoped authorization separate from provider-selection logic.
Before I start, I just want to confirm one matching semantic:
groups: [engineering, production], should a principal match if it has either value (OR), or only if it has both values (AND)?One longer-term scope question as well: is the initial implementation intentionally limited to token claims, with external entitlement resolution kept out of scope for v1?
We have a use case where upstream eligibility is determined outside the token itself, so selecting the effective upstream chain may eventually require an external entitlement lookup after the first identity provider resolves.
I’m not suggesting adding that to the initial implementation — I just want to make sure the filter/config design leaves room for that kind of extension later without requiring a major redesign.
Sanskarzz commentedon Sep 28, 2026
Thanks @hellouz818, that coordination works for me. Once @jhrozek confirms the assignment and delivery split, I’d be happy to take or co-develop the first prerequisite around shared string-array claim decoding and Cedar regression coverage. We can keep that PR independent of the auth-server filter and coordinate its API before the filter work builds on it.
On the external-entitlement question, my reading is that the proposed v1 is intentionally claim-only. The existing UpstreamFilter Go interface already receives context.Context and PrincipalInfo, so a future implementation could perform an external lookup without changing the handler contract. The declarative RunConfig/CRD shape is where we may eventually need an extension.
I agree it would be useful for the other maintainers to confirm whether external entitlement resolution is explicitly out of scope for v1, and whether it falls under the Connector Gateway/Enterprise boundary discussed in #5383.
Add shared JWT claim string-array decoder
Add shared JWT claim string-array decoder
Add group-based upstream filter for vMCP auth
Expose group-based upstream filter via vMCP CRD
Expose group-based upstream filter via vMCP CRD
Add group-based upstream filter for vMCP auth
8 remaining items
Fix SDK schema count assertion syntax
Cover YAML round-trip for upstream filter
Document the source of the group claim
Pin OR semantics for multi-group rules
Test the RunConfig path for the upstream filter
Regenerate the Go SDK for the claim doc comment
Add group-based upstream filter for vMCP auth (#6739)
Expose group-based upstream filter via vMCP CRD
Expose group-based upstream filter via vMCP CRD
hellouz818 commentedon Oct 13, 2026
All three PRs from the suggested delivery split are up: #6738 (shared claim decoder + Cedar) and #6739 (group-based upstream filter) are merged, and #6740 (vMCP CRD surface) is open.
@jhrozek, could you add me as an assignee on this issue? Happy for you to remain assigned as well if you'd prefer to track it together.
Thanks for your guidance and reviews throughout!
jhrozek commentedon Oct 16, 2026
I'm sorry I completely missed your reply on this PR. I assigned you to the issue.
hellouz818 commentedon Nov 2, 2026
All three PRs (#6738, #6739, #6740) are merged, so I'm closing this. Thanks for the reviews!