SecurityDiscord API v10

Discord Authorization

Live Discord REST API v10 permission verification, universal cross-guild channel checks, and role delegation safety with dangerous permission bitmask blocking.

Live Discord API permission verification

During OAuth sign-in, Taicket MCP requests only the minimum Discord scopes needed (identify guilds) to identify the user and list candidate servers on the consent screen. However, runtime authorization on /mcp never relies solely on cached OAuth guild snapshots.

Whenever Taicket is installed in the target guild, mcp/src/security/permissions.ts verifies the caller in real time against Discord REST API v10 (fetchGuildDetails, fetchGuildMember, and fetchGuildRoles). If a user loses their Administrator or Manage Server role in Discord, their MCP write access terminates as soon as the short-lived permission cache expires (45 seconds maximum), even if their OAuth token has not expired.

Fallback behavior before bot installation

When the Taicket bot has not yet been invited to a server, live member lookup is unavailable. Only discovery flows such as get_discord_servers fall back to the verified Discord OAuth user guilds list to generate an invite link. Configuration tools require the bot to be installed in the target guild.

Universal cross-guild channel and category checks

Every channel, category, forum, voice, or announcement snowflake passed to any of the 29 modules is validated against live fetchGuildChannels(guildId) before writing configuration or deploying a panel. If a channel ID belongs to another Discord server or does not exist in the target guild, the request fails with CROSS_GUILD_RESOURCE.

CROSS_GUILD_RESOURCE error returned on foreign channel referencejson
{
  "ok": false,
  "error": {
    "code": "CROSS_GUILD_RESOURCE",
    "message": "One or more selected channels or categories do not belong to this Discord server.",
    "details": {
      "field": "transcriptChannelId",
      "guildId": "123456789012345678"
    }
  }
}
  • Category type enforcement:: Fields expecting Discord categories strictly verify ChannelType.GuildCategory (type 4) in addition to guild ownership.
  • Deployment target validation:: deploy_discord_panel verifies that the target channel belongs to guildId and supports message posting before calling Discord REST APIs.

Universal role delegation safety (isRoleSafeForDelegation)

Any module that causes Taicket to automatically assign a Discord role to members (Verification, Greetings human/bot auto-roles, Leveling rewards, Economy store items and crafting recipes, Reaction Roles, and Component Builder role buttons) must pass isRoleSafeForDelegation with isOwner set to false.

CheckCondition BlockedSecurity Rationale
Everyone rolerole.id === guildIdThe default @everyone role cannot be assigned or toggled via bots.
Managed / bot rolesrole.managed === trueIntegration, Nitro Booster, and bot-owned roles cannot be delegated by Taicket.
Role hierarchyrole.position >= botHighestRolePositionPrevents configuring roles Taicket cannot manage and avoids privilege boundary errors.
Dangerous permissions(BigInt(role.permissions) & DANGEROUS_ROLE_PERMS_MASK) !== 0nBlocks self-assignable or reward roles that grant administrative or moderation powers.
DANGEROUS_ROLE_PERMS_MASK bitmask (matches dashboard/src/lib/security.js)typescript
// Administrator | ManageGuild | ManageRoles | ManageChannels |
// BanMembers | KickMembers | ManageWebhooks | ModerateMembers
export const DANGEROUS_ROLE_PERMS_MASK =
  0x8n |
  0x20n |
  0x10000000n |
  0x10n |
  0x4n |
  0x2n |
  0x20000000n |
  0x10000000000n;

export function isRoleSafeForDelegation(
  role: DiscordRole,
  guildId: string,
  botHighestPosition: number
): boolean {
  if (role.id === guildId || role.managed) return false;
  if (role.position >= botHighestPosition) return false;
  const perms = BigInt(role.permissions || '0');
  return (perms & DANGEROUS_ROLE_PERMS_MASK) === 0n;
}

Related documentation