Interface McpSubscriptionAuthorizer
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Authorization is distinct from initial request admission and catalog-item
access. Implementations establish a bounded whole-subscription grant from
current application state. A thrown exception or null result fails
closed. Soklet invokes callbacks through bounded application execution,
never on an event loop. Invocation features contain the check's cooperative
cancellation token; they do not expose task creation, progress reporting, or
a localization context computed before authorization completes.
For an established 2026-07-28 listen, denial, expiry or a failed
required check fences delivery and ends the subscription. A usable stream
receives its tagged completion result before closing; diagnostics retain
the authorization reason. A broken writer or partially written revoked
frame may close abruptly. Initial denial still rejects before acknowledgment.
For exact 2025-era delivery, the authorizer establishes and renews one
session-owned resource URI grant through a real resources/subscribe
context. That grant is independent of an individual GET connection and
survives its disconnect within configured bounds. GET notification-family
admission is controlled separately by McpSessionTransportAdmissionController.
Unsubscribe does not invoke this authorizer.
A transient renewal exception or timeout fences delivery and permits at most
three consecutive failed attempts within the existing lease. Successful
authorization resets this retry count. Explicit renewal denial, exhausted
retries, or an expired established grant retires its session: the client must
reinitialize and resubscribe. Legacy protocols have no subscription-ended
notification. Initial subscribe rejection and explicit unsubscribe do not
themselves retire a session.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionauthorize(@NonNull McpSubscriptionAuthorizationContext subscriptionAuthorizationContext, @NonNull McpInvocationFeatures invocationFeatures) Authorizes one initial, renewal, or reconciliation check.Returns the shared authorizer that denies every authorization check.
-
Method Details
-
authorize
@NonNull McpSubscriptionAuthorization authorize(@NonNull McpSubscriptionAuthorizationContext subscriptionAuthorizationContext, @NonNull McpInvocationFeatures invocationFeatures) throws Exception Authorizes one initial, renewal, or reconciliation check.- Parameters:
subscriptionAuthorizationContext- immutable authorization contextinvocationFeatures- features scoped to this authorization check; includes its cancellation token- Returns:
- a non-null allowed or denied authorization result
- Throws:
Exception- if authorization cannot be established; Soklet fails the check closed
-
denyAllInstance
Returns the shared authorizer that denies every authorization check.- Returns:
- shared deny-all authorizer
-