Read-only Discord access for Claude Code (factory-215.4)
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
- 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. - 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. - Only if live queries are needed: a bot-token MCP such as
atrumcore/discordmcp, but it exposessend-messageand the docs offer no way to disable it, so you would have to fork and delete that tool. Not recommended as the first step. - 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)
- Go to https://discord.com/developers/applications, click New Application, name it
something like
factory-reader. - 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.
- Still on the Bot tab, under Privileged Gateway Intents, turn on Message Content Intent. Leave Presence and Server Members off.
- Open OAuth2 > URL Generator. Tick scope
botonly. Under Bot Permissions tick View Channels and Read Message History only. The URL should show integer 66560. - Open the generated URL, pick the DataHub community server, and authorize. You need the Manage Server permission on that server.
- 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.
- Verify: in a test channel the bot should appear in the member list, and its permissions panel should show no Send Messages.
- Store the token outside the repo, for example
~/.config/factory/discord.envwithchmod 600, containingDISCORD_BOT_TOKEN=.... Keep the file out of git. - Once approved, install DCE from its GitHub releases (not run in this task) and add
.cache/discord/to.gitignore. - Schedule an export (launchd or cron) that runs DCE with
--bottoken from the env file, for exampleexportguildwith JSON format, into.cache/discord/. Rotate the token if it ever leaks.
Options
| Option | Read-only? | Setup | Token type | Maintenance signal | ToS | Verdict |
|---|---|---|---|---|---|---|
| Bot with View + Read History, periodic DCE export to JSON cache | Yes, no send tool exposed to agent | Owner creates app, invites bot, one-time | Bot | DCE: 12k+ stars, active project (not re-verified today) | Compliant (bot account) | Recommended |
atrumcore/discordmcp (live MCP) | No: send-message tool exists, no disable switch | Owner creates bot, .env token, client config | Bot | Weak: 4 commits, 0 stars, MIT | Compliant | Fallback only, needs fork to remove send |
elyxlz/discord-mcp (live MCP) | No: send_message tool exists | Email + password in env | User account (scraping) | Unclear; 19 commits, no releases | Violates ToS | Reject |
| DCE CLI with a user token | Yes (export only) | Login token in CLI | User account | Active | Violates ToS (DCE README warns) | Reject |
| Ask admin to paste exports manually | Yes | None for agent | None | n/a | Fine | Good 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 --helpafter 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
- Discord permissions (VIEW_CHANNEL 1<<10, READ_MESSAGE_HISTORY 1<<16): https://docs.discord.com/developers/topics/permissions
- Discord gateway, privileged intents and 100-guild verification: https://docs.discord.com/developers/topics/gateway
- Discord support, self-bots policy: https://support.discord.com/hc/articles/115002192352
- Discord Community Guidelines: https://discord.com/terms/guidelines-march-2022
- DiscordChatExporter: https://github.com/Tyrrrz/DiscordChatExporter
- atrumcore/discordmcp: https://github.com/atrumcore/discordmcp
- elyxlz/discord-mcp: https://github.com/elyxlz/discord-mcp