PD

pasympa/discord-mcp

Developer tools
38 stars 21 forks Quality 88 Trend 21MIT

MCP server to control Discord — messages, channels, roles, permissions, members, and moderation

Overview

Manage your entire Discord server from , , , , or any MCP-compatible client. Messages, channels, roles, permissions, moderation, forums, webhooks, all through natural language. - : messages, channels, roles, permissions, moderation, forums, webhooks, scheduled events, invites, DMs, embeds, and more - : works across multiple servers, no GUILD_ID lock-in - : TypeScript + Node.js, ~70kB package, ~73MB Docker image (vs 400MB+ for Java alternatives) - : clean architecture, easy to extend with new tools - : npm or Docker, your choice Add this to your MCP client config and replace YOUR_TOKEN_HERE with your bot token: No install needed, npx handles everything. Don't have a bot yet? See Creating Your Discord Bot. Add the config above to your claude_desktop_config.json: - : ~/Library/Application Support/Claude/claude_desktop_config.json - : %APPDATA%\Claude\claude_desktop_config.json Add the config above to ~/.cursor/mcp.json. See Cursor MCP docs for details.

README

discord-mcp connects Claude, Codex, Cursor, VS Code and any other MCP client to your Discord server through your own bot. Ask in plain language: your assistant reads channels, answers, moderates, and manages roles, channels, forums and events, with 100 tools behind it.

See it in action

Watch the full one-minute demo: a channel recap, a bug forum, the spam cleanup and an event.

Calls made live with Claude Code on a demo server; the panel summarizes their results. The Discord window shows real captures, except that the spot of each new message or post stays blank until it appears.

What you can ask

You want to Ask your assistant
Catch up on a busy channel “Summarize what’s going on in #support and post a recap in #mod-log.”
Turn feedback into a tracker “Open a bug-tracker forum and file the two open bugs from the recap.”
Stop a spam raid safely “A spam raid just hit #general. Preview the cleanup, then remove it.”
Run community events “Schedule a community call next Friday at 8 PM and announce it in #announcements.”
Audit permissions “Show me every permission overwrite in the server.”
Welcome people “Create an invite to #welcome that expires in 24 hours.”
Automate notifications “Create a webhook on #deploys and post the release notes as an embed.”

Quick start

  1. Create a bot. In the Discord Developer Portal, create an application, open Bot, then Reset Token and copy it. On the same page, enable Server Members Intent and Message Content Intent.

  2. Invite it to your server. Replace YOUR_CLIENT_ID with the Application ID from General Information, then open the link:

    https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot&permissions=2270827458424055
    

    It requests the permissions the tools use. Remove the ones you do not need in the authorization screen.

  3. Add it to your client. Use a button above, or paste this into your client’s MCP config:

    {
      "mcpServers": {
        "discord": {
          "command": "npx",
          "args": ["-y", "@pasympa/discord-mcp"],
          "env": {
            "DISCORD_TOKEN": "YOUR_BOT_TOKEN"
          }
        }
      }
    }
    

npx downloads and runs the server (Node.js 22 or later); nothing else to install. Per-client instructions are under Clients.

Expose only what you need

The full set of 100 tools costs about 35k tokens of context when a client loads them all. Most assistants need a fraction of it: set DISCORD_MCP_TOOLSETS to the toolsets you want.

Profile DISCORD_MCP_TOOLSETS Tools Context
Everything (default) unset 100 ~35k tokens
Chat assistant discovery,messages 25 ~10k tokens
Community manager discovery,messages,forums,scheduled_events 42 ~17k tokens
Moderator discovery,members,moderation,roles,permissions 31 ~10k tokens
Audit and stats discovery,stats,moderation 6 ~2k tokens
"env": {
  "DISCORD_TOKEN": "YOUR_BOT_TOKEN",
  "DISCORD_MCP_TOOLSETS": "discovery,messages"
}

Context sizes are measured on the tools/list response (bytes divided by 4). Toolsets: discovery, messages, channels, permissions, members (includes kick, ban and timeout), roles, moderation (the audit log), screening, stats, forums, webhooks, scheduled_events, invites, dm. A toolset brings its whole module, destructive tools included; an unknown name stops the server at startup instead of exposing everything.

Set DISCORD_MCP_READ_ONLY=true to keep only the 35 tools annotated readOnlyHint: true, about 14k tokens. It narrows DISCORD_MCP_TOOLSETS instead of replacing it: discovery,messages then exposes 11 tools, about 5k tokens. A selection with no read-only tool left, such as channels alone, stops the server at startup.

Safety

  • Your bot, your permissions. The server can only do what the bot’s Discord permissions allow.
  • Preview before mass actions. discord_bulk_delete_messages, discord_bulk_ban, discord_prune_members and discord_delete_channel run as a dry run by default and report what would happen. Pass dry_run: false to apply.
  • Stay in your servers. DISCORD_ALLOWED_GUILDS restricts every call to the guilds you list, whether the target is addressed by guild, channel, thread, webhook or invite.
  • Clear annotations. Every tool declares readOnlyHint, and every write tool declares destructiveHint, so clients can approve reads automatically and ask before destructive calls.
  • Read-only mode. With DISCORD_MCP_READ_ONLY=true, the server lists only the tools that declare readOnlyHint: true. A call to any other tool fails as an unknown tool. Two reads stay sensitive. discord_list_webhooks returns webhook tokens, and a token lets anyone post through its webhook without this server. discord_read_dms reads the bot’s direct messages with a user. To hide both, leave webhooks and dm out of DISCORD_MCP_TOOLSETS.
  • Keep the token out of files. Prefer your client’s secret prompt (the VS Code button asks for the token) over a config file you might commit.

Clients

Remote clients over HTTP

The OpenAI Responses API, Codex and n8n can reach an MCP server by URL instead of starting it. For them, the server can run as a Streamable HTTP endpoint, protected by a static bearer token:

export DISCORD_TOKEN=YOUR_BOT_TOKEN
export DISCORD_MCP_HTTP_TOKEN="$(openssl rand -hex 32)"
DISCORD_MCP_TRANSPORT=http npx -y @pasympa/discord-mcp

The endpoint is http://127.0.0.1:3000/mcp. Every request must carry Authorization: Bearer . Toolsets, read-only mode and DISCORD_ALLOWED_GUILDS apply as on stdio.

The token is static: there is no OAuth, so this mode sits outside the MCP authorization spec. ChatGPT connectors need OAuth 2.1 or OpenAI’s Secure MCP Tunnel, so this mode is not for ChatGPT.

In Docker, the server must listen on 0.0.0.0 inside the container. Publish the port on the host loopback only:

docker run --rm -p 127.0.0.1:3000:3000 \
  -e DISCORD_TOKEN -e DISCORD_MCP_HTTP_TOKEN \
  -e DISCORD_MCP_TRANSPORT=http -e DISCORD_MCP_HTTP_HOST=0.0.0.0 \
  pasympa/discord-mcp:latest

Security over HTTP

  • Bind address. The default, 127.0.0.1, accepts connections from this machine only. Use 0.0.0.0 only inside a container, with the port published on 127.0.0.1.
  • Token. Use at least 32 characters: openssl rand -hex 32 gives 64. Anyone who holds it acts as your bot, with the same toolsets, read-only mode and allow-list. To rotate it, restart the server with a new value.
  • HTTPS. The server speaks plain HTTP. To reach it from another machine, put it behind a reverse proxy or a tunnel that terminates TLS. Never publish the port on the Internet: the token would travel in clear text.
  • Allowed hosts. A request needs a Host of localhost, 127.0.0.1, [::1] or a name in DISCORD_MCP_HTTP_ALLOWED_HOSTS. Any request with an Origin header is refused, so a web page cannot reach the server, even through DNS rebinding. nginx forwards its upstream address by default, which passes. Caddy forwards the public hostname: list it.
  • Stateless. Each POST to /mcp stands alone, and GET and DELETE answer 405. If a client drops the connection during a call, the Discord action still completes, so a retry can repeat a write.

Configuration

Variable Default Description
DISCORD_TOKEN none Required. Bot token.
DISCORD_MCP_TOOLSETS all Comma-separated toolsets to expose (see Expose only what you need). Unset, empty or all exposes every tool.
DISCORD_MCP_READ_ONLY false Set to true to expose only the tools annotated readOnlyHint: true. Accepts true/false, 1/0, yes/no or on/off; any other value stops the server at startup.
DISCORD_ALLOWED_GUILDS all Comma-separated guild IDs the server may act on. Calls that target any other guild are rejected, whether addressed by guild ID, channel ID, thread ID, webhook or invite code.
DISCORD_MESSAGE_CONTENT true Set to false to stop requesting the Message Content privileged intent at connect time.
DISCORD_GUILD_MEMBERS true Set to false to stop requesting the Server Members privileged intent at connect time.
DISCORD_MCP_TRANSPORT stdio stdio, or http to serve Streamable HTTP (see Remote clients over HTTP). Any other value stops the server at startup.
DISCORD_MCP_HTTP_TOKEN none Required in http mode. Bearer token every request must carry: at least 32 characters from the RFC 6750 b64token alphabet (letters, digits, -._~+/, trailing =), different from DISCORD_TOKEN.
DISCORD_MCP_HTTP_HOST 127.0.0.1 Address to listen on in http mode.
DISCORD_MCP_HTTP_PORT 3000 Port to listen on in http mode.
DISCORD_MCP_HTTP_ALLOWED_HOSTS none Comma-separated hostnames, without port, accepted in the Host header besides localhost, 127.0.0.1 and [::1], such as the public name a reverse proxy forwards.

The intent flags only change what the bot requests when it connects. Requesting a privileged intent that is not enabled in the Developer Portal closes the connection with code 4014; set the flag to false to connect anyway. What the tools can read is governed by the portal toggles: every message is fetched over the REST API, which Discord gates on the portal setting alone. With Message Content off in the portal, message bodies come back empty (content, embeds, attachments), except the bot’s own messages, DMs and messages that mention the bot; with Server Members off, member listing fails.

Tools

100 tools in 14 toolsets. Each one documents its permissions, side effects and return shape in its description.

Troubleshooting

  • Every call fails with close code 4014. The bot requests a privileged intent that is off in the Developer Portal. Enable Server Members and Message Content there, or set DISCORD_GUILD_MEMBERS=false / DISCORD_MESSAGE_CONTENT=false.
  • Messages come back with empty text. Message Content is off in the portal. Enable it; the flag alone does not change what the REST API returns.
  • A read fails with “lacks the Read Message History permission”. Without it, Discord returns an empty list rather than an error, so the read tools report the missing permission instead of an empty channel. Grant it in the channel, or in the parent channel of a thread.
  • Missing Access or Missing Permissions. The bot cannot see the channel, or the target role or member sits above the bot’s highest role. Check overwrites with discord_get_channel_permissions.
  • Finding IDs. Enable Developer Mode in Discord (Settings, Advanced), then right-click a server, channel or user and choose Copy ID.

Contributing

Contributions are welcome. CONTRIBUTING.md covers the module layout, the tool definition quality bar and the release flow. Report vulnerabilities as described in SECURITY.md.

License

MIT, see LICENSE. discord-mcp is an independent open-source project, not affiliated with or endorsed by Discord Inc.

VS Code and VS Code Insiders icons: Codicons © Microsoft Corporation, licensed under CC BY 4.0.

View the full README on GitHub

Install

npx -y @pasympa/discord-mcp
New to MCP? Start with the mcpskill.org guide →

Configuration

{ "mcpServers": { "discord": { "command": "npx", "args": ["-y", "@pasympa/discord-mcp"], "env": { "DISCORD_TOKEN": "YOUR_BOT_TOKEN" } } } }