[bug] Discord MCP plugin intermittently loses gateway connection, reply fails with 'not allowlisted'
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
- Start Claude Code in a tmux session with the Discord plugin enabled
- Use Discord DMs normally — works fine for hours
- After an extended idle period (variable, sometimes 30 min, sometimes hours), attempt to send a
reply - Fails with the "not allowlisted" error
- Inbound messages from Discord may still arrive (gateway partially alive)
- Running
/mcpand 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:
- Add heartbeat/keepalive logic to detect and auto-reconnect the gateway
- Add retry logic in
fetchAllowedChannel()— ifrecipientIdis falsy, attemptclient.channels.fetch(id, { force: true })to bypass cache - 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.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗