Token Expiration
Fixed lifetime policies, MongoDB TTL cleanup indexes, and token refresh handling across OAuth grants, scoped PATs, and setup previews.
Credential & State Lifetime Table
Every credential, authorization artifact, and pending setup plan stored in taicket_mcp has a bounded, non-infinite expiration timestamp enforced both in application checks and via MongoDB TTL indexes.
| Artifact | Collection | Lifetime (TTL) | Notes |
|---|---|---|---|
| OAuth Access Token | mcp_access_tokens | 1 hour (3,600s) | Short-lived bearer credential bound to https://mcp.taicket.xyz/mcp |
| OAuth Refresh Token | mcp_refresh_tokens | 30 days | Single-use rotating token; replay revokes entire familyId |
| Authorization Code | mcp_oauth_codes | 60 seconds | Single-use code bound to PKCE challenge and redirect_uri |
| OAuth Transaction | mcp_oauth_transactions | 10 minutes | Pending browser handshake between /oauth/authorize and /oauth/consent |
| Setup Preview Plan | mcp_setup_previews | 15 minutes | Dry-run planId and human browser approval window at /oauth/approve-action |
| Scoped PAT (tmcp_...) | mcp_access_tokens | 7, 30, or 90 days | User selects expiry on creation; infinite PATs are prohibited |
Client Refresh Strategy
OAuth 2.1 MCP clients should refresh access tokens proactively 60 to 120 seconds prior to expires_in or immediately upon receiving HTTP 401 with error="invalid_token". Serialize concurrent refresh calls per grant so two parallel requests never submit the same rotating refresh token.
let inflightRefresh: Promise<TokenBundle> | null = null;
export async function refreshAccessTokenOnce(
tokenEndpoint: string,
clientId: string,
refreshToken: string
): Promise<TokenBundle> {
if (inflightRefresh) {
return inflightRefresh;
}
inflightRefresh = fetch(tokenEndpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
grant_type: 'refresh_token',
refresh_token: refreshToken,
client_id: clientId,
resource: 'https://mcp.taicket.xyz/mcp',
}),
})
.then(async (res) => {
if (!res.ok) {
throw new Error(`Token refresh failed with HTTP ${res.status}`);
}
return (await res.json()) as TokenBundle;
})
.finally(() => {
inflightRefresh = null;
});
return inflightRefresh;
}Avoid concurrent refresh races
Because refresh tokens rotate atomically, firing two parallel refresh requests with the same refresh_token triggers replay detection and revokes the entire grant family. Always coalesce refreshes behind a single-flight lock.
Scoped PAT Rotation & Renewal
Scoped Personal Access Tokens created in https://mcp.taicket.xyz/account do not issue refresh tokens and cannot be extended past their chosen 7, 30, or 90 day lifetime. To rotate a PAT with zero downtime, generate a replacement token in /account, update your MCP client configuration, and immediately revoke the previous token.