Skip to main content
Glama
Discord D&D MCP

Discord D&D MCP

by Closeplanet2

Discord D&D MCP

A local stdio MCP server that lets Codex read configured Discord servers and manage messages only in the D&D server. Codex starts server.py when it connects. A separate changelog_bot.py process logs D&D server message activity to its private #changelog channel.

Setup

  1. Create a Discord bot, invite it to each server, and enable Message Content Intent in the Discord Developer Portal. In the portal's OAuth2 → URL Generator, select the bot scope. Give it message write permissions in the D&D server and only View Channel and Read Message History in other servers.

  2. Put DISCORD_BOT_TOKEN, comma-separated DISCORD_GUILD_IDS, DISCORD_WRITE_GUILD_ID (the D&D server), and DISCORD_CHANGELOG_CHANNEL_ID (its private changelog) in .env. Never commit .env.

  3. Install Python 3.11+ and run python -m venv .venv, then .\.venv\Scripts\python.exe -m pip install -r requirements.txt.

  4. Register the stdio server with Codex, using dotenv.exe -f <absolute .env path> run -- <absolute python.exe path> <absolute server.py path> as the command and arguments. Restart Codex or start a new chat after changing the tool catalog.

The current local Codex configuration already has a discord_dnd entry pointing at this project. The MCP Inspector is optional for testing and is not part of the connection.

Adding another server

Invite the same bot to the new Discord server with read permissions only. Check its effective permissions in each channel: inherited @everyone or channel overrides can still grant posting even when the invite requested only read access. Remove Send Messages, Send Messages in Threads, Add Reactions, Manage Messages, Manage Channels, and Administrator outside the D&D server. Add the new server ID to .env, while keeping the D&D server as the sole write target and sole changelog destination:

DISCORD_GUILD_IDS=DND_GUILD_ID,OTHER_GUILD_ID
DISCORD_WRITE_GUILD_ID=DND_GUILD_ID
DISCORD_CHANGELOG_CHANNEL_ID=DND_CHANGELOG_CHANNEL_ID

Keep the existing DISCORD_BOT_TOKEN value. DISCORD_GUILD_IDS controls which servers can be read. DISCORD_WRITE_GUILD_ID names the only server where MCP message changes are allowed. Restart the listener and Codex's MCP connection after changing .env. For more read-only servers, append their IDs to DISCORD_GUILD_IDS. No changelog channel is needed in those servers.

Related MCP server: MCP-Discord

Project skills

Codex can discover the repository skills in .agents/skills/: discord-server-research for read-only lore and format research, and discord-dnd-edit for D&D message changes. Start a new Codex session to load newly added skills. You can also invoke them explicitly as $discord-server-research and $discord-dnd-edit.

Changelog listener

The D&D server's private #changelog channel should be readable by its administrators and the bot. The listener logs new messages, text edits, attachment changes, pins, deletes, bulk deletes, and reaction changes from D&D channels the bot can access. It ignores activity in all other servers. Entries link to the source message and include up to 500 characters of text. Changelog entries themselves are excluded to prevent a loop. Mentions and link previews are disabled in log posts.

Run the listener separately from the MCP server, and keep it running:

cd G:\Closeplanet2\Discord-MCP
.\.venv\Scripts\python.exe changelog_bot.py

The listener receives events only while connected. Discord does not supply the old content of an uncached edit or deleted message, so those entries may say the previous text is unavailable. It does not backfill events missed while offline. Give the bot View Channel, Read Message History, and Send Messages in channels you want covered, and enable Message Content Intent in the Developer Portal. Run it via Task Scheduler or a service if it must survive a reboot.

Tools

Read: discord_status, list_guilds, message_permissions, list_channels, list_forum_threads, search_messages, channel_history, get_message, list_reactions, list_pins.

Write: send_message (including replies and embeds), edit_message, delete_message, bulk_delete_messages, crosspost_message, add_reaction, remove_reaction, clear_reactions, pin_message, unpin_message.

Use list_guilds to see configured servers. Pass guild_id to list_channels and guild-wide search_messages when multiple servers are configured; searches limited to a channel_id infer its server. Other tools infer the server from the channel ID. Read tools accept channels in any configured server. All write tools reject channels outside DISCORD_WRITE_GUILD_ID. Discord also enforces the bot's permissions, so remove write permissions from its role in other servers. Message content can only be edited by its author; deleting other users' messages and clearing their reactions require Manage Messages. Posting in threads requires Send Messages in Threads. Pins require Pin Messages. message_permissions(channel_id) reports the bot's effective permissions in a channel.

Mentions and reply pings are disabled by default when sending or editing. Set allow_mentions=true only when notifications are intended. Bulk deletion is restricted by Discord to 2–100 messages no older than 14 days. Forum parents hold posts as threads: call list_forum_threads, then use a returned thread ID with message tools.

search_messages searches accessible messages locally because Discord's guild search endpoint returned 403 for this bot. It is bounded and reports incomplete=true when it stops before covering everything; narrow by channel_id or increase its scan limits for deeper searches.

Test

Run .\.venv\Scripts\python.exe -m unittest discover -s tests -v. The tests mock all mutating Discord requests and do not post to the server.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants to interact with the Discord platform, including sending and searching messages, managing channels, categories, forums, threads, roles, members, reactions, and webhooks. It works with a configured Discord bot token over stdio or streamable HTTP transports.
      3,822 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants to interact with the Discord platform through a bot, covering server info and member management, channel, forum, and role administration, message search and editing, reactions, and webhooks. It supports both stdio and streamable HTTP transports with token-based authentication.
      3,822 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants to interact with the Discord platform, including listing servers and members, managing channels, categories, forums and roles, sending, searching, editing and deleting messages, handling reactions, permissions and webhooks, and operating through either stdio or streamable HTTP transports.
      3,822 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants to interact with the Discord platform, covering bot login, server and member inspection, channel, category and forum management, message reading, sending, editing and deletion, reactions, roles, and webhooks. Supports both stdio and streamable HTTP transports with token-based configuration.
      3,822 npm
      MIT