Background credential refresher + RFC 8707 resource on token requests (0.1.1-dev.2) #106
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/credential-refresher"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
v0.1.1-dev.2
Linked MCP accounts stay signed in, and public OAuth clients such as PocketSmith's hosted MCP work end to end.
corn.refresher.CredentialRefreshersweeps registered credential sources on an interval and renews grants before they expire. Linked MCP accounts (CORN_UPSTREAM_MCP_SERVERS) are the first source; other credential families can register their ownsweep(min_validity). Only one replica sweeps at a time (database leasecredential-refresher). On-demand refresh at call time is unchanged and remains the correctness path.CORN_REFRESH_INTERVAL_SECONDS(default1800,0disables)CORN_REFRESH_MIN_VALIDITY_SECONDS(default2400): grants with less remaining lifetime are refreshed. With the defaults, a one-hour token is renewed before it can expire between two sweeps.resourceon every token request. When an upstream setsresource, Corn now sends it on the authorization-code exchange and on refreshes too, not only on the authorization request, as the MCP authorization spec requires.429and5xxfrom the token endpoint no longer delete the user's linked account; the current token is used while still valid and the tool error says to retry. Only a rejected refresh token (4xx) disconnects.No configuration change is required; the refresher starts with the defaults.
Why
Linking PocketSmith's hosted MCP (read-write) per user through Corn. PocketSmith is a public OAuth client (DCR,
token_endpoint_auth_method: none), requires PKCE S256 and uses one-hour access tokens. Without a background refresh, an idle user's grant could lapse; and a temporary token-endpoint 5xx used to delete the grant.Tests
tests/test_credential_refresher.py: resource on authorize/code/refresh, public-client refresh body, sweep window selection across users, upstream down keeps grant, rejected refresh disconnects, no-refresh-token grant used until expiry, refresher source isolation + cross-replica lease skip, disabled modes. Full suite: 537 passed.Change review ·
56e682199485→e6a443911c59Call paths changed by this PR
Caller → changed symbol → callee. Each edge labels the line in the caller. One detected entry path (up to 3 hops) is included when found. Static evidence, not a runtime stack trace.
After
Changed symbols:
Settings.from_env—src/corn/config.py:296ConnectionService.user_ids_with_provider—src/corn/credentials.py:132RefreshSource.sweep—src/corn/refresher.py:32SweepReport.as_dict—src/corn/refresher.py:42CredentialRefresher.__init__—src/corn/refresher.py:54CredentialRefresher.register—src/corn/refresher.py:73Bounded view: 45 more changed symbols and 1 neighbour references omitted.
Overall architecture after this change
Source: e6a443911c59 ·
code-review 0.1.0-dev.1.Generated from resolved static calls between reviewed code areas. Numbers are call sites, not request counts.
Framework registration, dynamic dispatch, and unresolved calls are not shown. This is not a deployment map.
Showing 6 of 6 inter-area edges. Edit the reviewed source instead of this generated page.
This diagram is for the linked commit. It refreshes after required checks pass for a new head.