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.

Thread-safe application authorization policy for establishing and renewing MCP subscriptions. Soklet may invoke one authorizer concurrently for independent subscriptions, but runs at most one authorization callback at a time for each subscription.

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