Read-only Discord access for Claude Code (factory-215.4)

Goal: a Claude Code agent on Rufus' Mac can read DataHub community Discord channel history for context. It must never post, edit, react, or DM.

Recommendation

  1. Create a dedicated Discord bot with only View Channels + Read Message History (permission integer 66560). No Send Messages, no Manage anything. Message Content intent is required, otherwise message text comes back empty.
  2. Prefer a periodic export over a live MCP. Run DiscordChatExporter (DCE) with the bot token on a schedule, writing JSON into a gitignored cache (for example .cache/discord/). Claude then reads local files with Read/Grep. The agent never holds a Discord tool that can send, so posting is impossible by construction.
  3. Only if live queries are needed: a bot-token MCP such as atrumcore/discordmcp, but it exposes send-message and the docs offer no way to disable it, so you would have to fork and delete that tool. Not recommended as the first step.
  4. Do not use user-token tools (elyxlz/discord-mcp, any self-bot). See section 4.

Why the bot is safe for a single server: the bot is in one guild, far below the 100-guild verification threshold, so no Discord review is needed. Discord says apps under 10,000 unique users can enable privileged intents directly in the Developer Portal.

Owner setup steps (server admin)

  1. Go to https://discord.com/developers/applications, click New Application, name it something like factory-reader.
  2. Open the Bot tab and click Reset Token. Copy it once into a password manager. Do not paste it into chat, a repo file, or a commit.
  3. Still on the Bot tab, under Privileged Gateway Intents, turn on Message Content Intent. Leave Presence and Server Members off.
  4. Open OAuth2 > URL Generator. Tick scope bot only. Under Bot Permissions tick View Channels and Read Message History only. The URL should show integer 66560.
  5. Open the generated URL, pick the DataHub community server, and authorize. You need the Manage Server permission on that server.
  6. In Discord, create or pick a role for the bot that has no Send Messages permission. If a channel should stay hidden, deny View Channel for the bot there.
  7. Verify: in a test channel the bot should appear in the member list, and its permissions panel should show no Send Messages.
  8. Store the token outside the repo, for example ~/.config/factory/discord.env with chmod 600, containing DISCORD_BOT_TOKEN=.... Keep the file out of git.
  9. Once approved, install DCE from its GitHub releases (not run in this task) and add .cache/discord/ to .gitignore.
  10. Schedule an export (launchd or cron) that runs DCE with --bot token from the env file, for example exportguild with JSON format, into .cache/discord/. Rotate the token if it ever leaks.

Options

OptionRead-only?SetupToken typeMaintenance signalToSVerdict
Bot with View + Read History, periodic DCE export to JSON cacheYes, no send tool exposed to agentOwner creates app, invites bot, one-timeBotDCE: 12k+ stars, active project (not re-verified today)Compliant (bot account)Recommended
atrumcore/discordmcp (live MCP)No: send-message tool exists, no disable switchOwner creates bot, .env token, client configBotWeak: 4 commits, 0 stars, MITCompliantFallback only, needs fork to remove send
elyxlz/discord-mcp (live MCP)No: send_message tool existsEmail + password in envUser account (scraping)Unclear; 19 commits, no releasesViolates ToSReject
DCE CLI with a user tokenYes (export only)Login token in CLIUser accountActiveViolates ToS (DCE README warns)Reject
Ask admin to paste exports manuallyYesNone for agentNonen/aFineGood interim fallback

4. Discord ToS constraint: self-bots

Automating a normal user account with its user token (a "self-bot") is prohibited. Discord's support article says automation must use the bot account type created through the Developer Portal and authenticated with a bot token. Community Guidelines also list self-bots. Consequence: any MCP or exporter that asks for a user email/password or user token is out. Flagged, not recommended. Also note that a bot can only see channels it is invited to and can read, so private channels stay private.

Open items

  • DCE's JSON export flags were not verified against its current CLI help. Run DiscordChatExporter.Cli export --help after install before writing the script.
  • Discord's current Developer Policy text was not fetched; re-check before deploying.
  • Whether the DataHub server owner wants the bot visible to members is a policy call.

Sources

Built with LogoFlowershow