[bug] Discord MCP plugin intermittently loses gateway connection, reply fails with 'not allowlisted'

Resolved 💬 3 comments Opened Mar 23, 2026 by tjvjbtwbnk-star Closed Mar 23, 2026

Description

The Discord MCP plugin (discord@claude-plugins-official) intermittently loses its Discord gateway connection during long-running Claude Code sessions (tmux-based, persistent). When this happens, outbound tools (reply, fetch_messages) fail with:

channel <id> is not allowlisted — add via /discord:access

The access.json file on disk is correct (user is in allowFrom, dmPolicy is allowlist). The issue is that fetchAllowedChannel() in server.ts (line ~392) calls client.channels.fetch(id), which returns a stale or incomplete DMChannel object where recipientId is not properly resolved — causing the allowFrom.includes(ch.recipientId) check to fail.

Reproduction

  1. Start Claude Code in a tmux session with the Discord plugin enabled
  2. Use Discord DMs normally — works fine for hours
  3. After an extended idle period (variable, sometimes 30 min, sometimes hours), attempt to send a reply
  4. Fails with the "not allowlisted" error
  5. Inbound messages from Discord may still arrive (gateway partially alive)
  6. Running /mcp and reconnecting the plugin fixes the issue immediately

Environment

  • Claude Code on Ubuntu Linux (headless, tmux)
  • Plugin version: 0.0.1 (from claude-plugins-official)
  • discord.js 14.25.1
  • bun 1.3.11
  • Session uptime: typically 12+ hours

Suggested Fix

The Discord.js client's gateway connection likely drops silently during idle periods. Options:

  1. Add heartbeat/keepalive logic to detect and auto-reconnect the gateway
  2. Add retry logic in fetchAllowedChannel() — if recipientId is falsy, attempt client.channels.fetch(id, { force: true }) to bypass cache
  3. Add a periodic health check that tests the gateway connection and reconnects if stale

Workaround

Manual /mcp reconnect from the Claude Code REPL restores functionality immediately.

---
Filed by an ai (Claude Opus 4.6) on behalf of a user running a persistent tmux-based Claude Code session with Discord as the primary communication channel.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗