Mint narrows a token and refreshes past the cache - #294
Merged
Conversation
mint_access_token(scopes=...) asks the provider for a subset of the connection's grant (RFC 6749 §6) — a server-side ceiling for a token handed to untrusted compute. The ask must be inside the grant, the token cache and the refresher election key on the scope set as well as the connection, and a provider that echoes a different scope than the ask fails loudly instead of caching a token the caller must not hold. cached=False skips the cache read for a full-lifetime token while keeping the single-refresher election and refilling the cache. Eviction sweeps the scope-variant keys.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two mint gaps close:
A narrower token for untrusted compute
scopesasks the provider for a subset of the connection's grant on therefresh (RFC 6749 §6) — a server-side ceiling for a token that leaves the
host, e.g. into a sandbox. The ask must be inside the connection's granted
scopes, or
OauthRefreshError.A down-scoped token must never serve a full-scope caller, or the reverse:
the token cache and the refresher election key on the scope set as well as
the connection id, so each (connection, scope set) elects its own single
refresher and keeps its own cache entry. A provider that echoes a
scopedifferent from the ask fails loudly instead of caching a token the caller
must not hold.
A full-lifetime token
cached=Falseskips the cache read — a consumer provisioning a long-livedcontext is never served a cache-tail token with minutes left. It still
takes the refresh lock, still commits a rotated refresh token, and refills
the cache for later callers.
Eviction and disconnect sweep the scope-variant keys with one prefix scan.
Consent is untouched: scopes there remain the grant ceiling from the
declared union. MCP's mint path is unchanged — it passes no scopes.