Authentication

Token Issuance

Issuing audience-bound Bearer access tokens and atomically rotating refresh tokens via POST /oauth/token.

Authorization Code Exchange

POST /oauth/token accepts application/x-www-form-urlencoded (standard OAuth 2.1) or application/json request bodies. For grant_type=authorization_code, Taicket verifies the client_id, redirect_uri, single-use code hash, RFC 8707 resource indicator, and PKCE S256 code_verifier.

Token exchange requesthttp
POST /oauth/token HTTP/1.1
Host: mcp.taicket.xyz
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&code=ac_7f31c9e4b2a04d819e5c6b1a&redirect_uri=http%3A%2F%2F127.0.0.1%3A49152%2Foauth%2Fcallback&client_id=dcr_9f4b2a1c8e7d6053a1b2c3d4&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk&resource=https%3A%2F%2Fmcp.taicket.xyz%2Fmcp
Token issuance response (HTTP 200)json
{
  "access_token": "tmcp_oa_6a8f4d91e2c04b7790c1a4e5f8d2b3c4",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "tmcp_rt_3d7c9e2a1b4f5082e6a9c0d1f2e3b4a5",
  "scope": "mcp:read mcp:write"
}

Cache prevention headers

Every response from POST /oauth/token sets Cache-Control: no-store and Pragma: no-cache so intermediary proxies and client caches never persist issued credentials.

Opaque Hashed Storage in taicket_mcp

Taicket issues high-entropy opaque bearer tokens rather than self-contained JWTs. Plaintext tokens are returned once in the HTTP response and discarded from memory immediately. Only the SHA-256 hex digest (tokenHash), a short prefix (tokenPrefix), and the trailing four characters (tokenLast4) are stored in McpAccessToken and McpRefreshToken inside the dedicated taicket_mcp database.

Opaque database-backed tokens guarantee instant revocation with zero clock-skew or JWT revocation-list lag, and prevent server IDs, scopes, or Discord identifiers from leaking inside base64-decoded token headers.

Atomic Refresh Token Rotation & Replay Detection

Refresh tokens rotate on every use via an atomic MongoDB compare-and-swap update: findOneAndUpdate({ tokenHash, revokedAt: null, rotatedAt: null }, { $set: { rotatedAt: now, replacedByHash } }). Only one concurrent refresh call can succeed for a given token hash.

Refresh token requesthttp
POST /oauth/token HTTP/1.1
Host: mcp.taicket.xyz
Content-Type: application/x-www-form-urlencoded

grant_type=refresh_token&refresh_token=tmcp_rt_3d7c9e2a1b4f5082e6a9c0d1f2e3b4a5&client_id=dcr_9f4b2a1c8e7d6053a1b2c3d4&resource=https%3A%2F%2Fmcp.taicket.xyz%2Fmcp

If the atomic update returns null and the submitted refresh token hash exists with rotatedAt != null, Taicket classifies the request as refresh token replay and immediately revokes the entire familyId across McpOAuthGrant, McpAccessToken, and McpRefreshToken. Both the attacker and the legitimate client are forced to re-authenticate through Discord consent.

Refresh token replay error (HTTP 400)json
{
  "error": "invalid_grant",
  "error_description": "Refresh token reuse detected. The authorization grant has been revoked."
}

Related documentation