Discord IntegrationDiscord OAuth2

Discord Authorization

Upstream Discord OAuth2 identity bridge using minimal identify and guilds scopes, callback state binding, and AES-256-GCM token vault encryption.

Minimal Discord OAuth2 Scopes

Taicket MCP acts as an OAuth 2.1 Authorization Server that delegates human identity verification to Discord Official OAuth2. During sign-in, Taicket requests only the two minimum scopes required to identify the user and enumerate manageable servers.

Discord ScopePurpose in Taicket MCPData Accessed
identifyVerify human Discord account identityUser ID, username, global_name, avatar hash (GET /api/v10/users/@me)
guildsDiscover Discord servers where the caller holds ownership or management bitsGuild list with id, name, icon, owner flag, and permissions bitfield (GET /api/v10/users/@me/guilds)

Zero invasive user scopes

Taicket MCP never requests email, connections, guilds.join, dm_channels.read, or messages.read on user OAuth grants. Bot operations inside servers use the dedicated Taicket Bot token only after live RBAC verification succeeds.

Callback Endpoint & Transaction Binding

Both the OAuth 2.1 consent flow (/oauth/authorize) and the Account Portal sign-in (/account) redirect through the single registered Discord callback URI.

Production Callback URI
https://mcp.taicket.xyz/oauth/discord/callback
Local Development URI
http://localhost:4130/oauth/discord/callback
Upstream Token Endpoint
https://discord.com/api/v10/oauth2/token
Transaction Lifetime
10 minutes (McpOAuthTransaction TTL in taicket_mcp)
CSRF / Session Binding
SHA-256 hashed HttpOnly, SameSite=Lax, Secure cookie matched against state parameter
Upstream Discord authorization redirecthttp
HTTP/1.1 302 Found
Location: https://discord.com/oauth2/authorize?client_id=1423500000000000000&response_type=code&redirect_uri=https%3A%2F%2Fmcp.taicket.xyz%2Foauth%2Fdiscord%2Fcallback&scope=identify%20guilds&state=txn_7c9a4e1b2d8053f6&prompt=none
Set-Cookie: mcp_oauth_txn=opaque_token_value; Path=/oauth; HttpOnly; Secure; SameSite=Lax; Max-Age=600

AES-256-GCM Discord Token Vault

After exchanging the upstream Discord authorization code, Taicket encrypts both the Discord access token and Discord refresh token before persisting them to McpOAuthTransaction or McpOAuthGrant inside the physically isolated taicket_mcp database.

  • Authenticated encryption:: Uses AES-256-GCM keyed by MCP_TOKEN_ENCRYPTION_KEY (256-bit secret) with a freshly generated 96-bit random IV and 128-bit GCM authentication tag per encrypted value.
  • Strict internal usage:: Decrypted Discord user tokens are used solely inside server-side guild discovery (/users/@me/guilds) when refreshing the caller server list. They are never serialized into MCP tool responses, OAuth responses, browser HTML, or audit logs.
  • Zero cross-user sharing:: Each encrypted Discord token record is bound to a single userId and grantId, and is purged or invalidated whenever the grant expires or is revoked.

Related documentation