Skip to main content
Glama

@devli13/mcp-discord

npm License: MIT

一个用于 Discord 的 MCP 服务器。通过 Claude Code、Paperclip 代理、Gemini CLI 或任何兼容 MCP 的客户端,发送消息、进行审核、管理频道、检查服务器。

纯 REST 封装。无网关。无数据库。 仅将 Discord v10 API 封装为 26 个文档齐全的工具,并提供按路由的速率限制和结构化的错误结果。


为什么选择它

Discord 的 API 非常庞大,且通过原始 curl 调用时对代理不友好。代理经常遇到速率限制、无法处理 429 错误、搞砸审计日志原因、忘记分页游标。此 MCP 一次性解决了这些问题,让代理可以专注于意图:“删除那条垃圾消息”、“将每日摘要发布到 #mod-log”、“禁言 @user 一小时”。

它也非常适合人类使用。连接到 Claude Code 后,你可以说*“总结我在 Discord #dev 频道中的最后 50 条消息”*,Claude 就能直接完成。


Related MCP server: Discord Bridge MCP Server

安装

npm install -g @devli13/mcp-discord

或者通过 npx(无需安装):

DISCORD_BOT_TOKEN=<your-token> npx -y @devli13/mcp-discord

设置

1. 创建一个 Discord 机器人

  1. 前往 https://discord.com/developers/applications → New Application

  2. 为应用程序添加一个 Bot

  3. 复制机器人令牌 — 这就是你的 DISCORD_BOT_TOKEN

  4. 使用 OAuth2 URL 生成器(范围:bot)将机器人邀请到你的服务器。根据你需要 MCP 执行的操作选择权限(例如:管理消息以进行删除,管理成员以进行禁言)

2. 将其连接到你的 MCP 客户端

Claude Code:

claude mcp add discord \
  --env DISCORD_BOT_TOKEN=<your-token> \
  -- npx -y @devli13/mcp-discord

Paperclip mcp-gateway (.mcp.json):

{
  "mcpServers": {
    "discord": {
      "command": "npx",
      "args": ["-y", "@devli13/mcp-discord"],
      "env": {
        "DISCORD_BOT_TOKEN": "<your-token>"
      }
    }
  }
}

Gemini CLI (~/.gemini/config.json):

{
  "mcpServers": {
    "discord": {
      "command": "npx",
      "args": ["-y", "@devli13/mcp-discord"]
    }
  }
}

3. (可选) 启用特权意图

如果你想列出服务器成员 (discord_list_members) 或将此 MCP 与配套插件一起用于入站事件,请在机器人的开发者门户设置中启用 Server Members Intent 和 Message Content Intent。大多数 MCP 操作不需要这些权限 — 仅特定端点需要。


工具参考

所有工具均以 discord_* 为前缀,并返回 JSON 数据块(成功时)或格式化的错误消息(失败时)。没有任何工具会抛出异常 — 每个工具都会返回一个可用的字符串结果。

消息 (8)

工具

用途

discord_send_message

发送到频道。支持嵌入、回复、提及控制

discord_edit_message

编辑机器人自己的消息

discord_delete_message

删除一条消息(由机器人或其他用户发送,需“管理消息”权限)

discord_bulk_delete_messages

一次调用删除 2-100 条消息(小于 14 天)

discord_get_message

通过 ID 获取单条消息

discord_list_messages

分页频道历史记录(before/after/around 游标)

discord_pin_message / discord_unpin_message

管理置顶消息

反应 (3)

工具

用途

discord_add_reaction

机器人添加反应

discord_remove_reaction

移除机器人或用户的反应

discord_get_reactions

列出使用特定表情符号做出反应的用户

频道与线程 (5)

工具

用途

discord_list_channels

服务器中的所有频道

discord_get_channel

单个频道详情

discord_create_thread

创建新线程(公开或私有,锚定或独立)

discord_list_active_threads

服务器中的所有活跃线程

discord_send_typing

触发“机器人正在输入...”指示器

审核 (6)

工具

用途

discord_get_member

成员资料(角色、加入日期、禁言状态)

discord_list_members

分页成员列表(需要 Server Members 意图)

discord_timeout_user

通过 communication_disabled_until 进行禁言(最长 28 天,0 为清除)

discord_kick_user

将用户从服务器移除

discord_add_role / discord_remove_role

角色管理

服务器信息 (4)

工具

用途

discord_list_guilds

机器人所在的所有服务器

discord_get_guild

单个服务器详情

discord_list_roles

所有角色,按位置排序

discord_get_audit_log

最近的审计日志条目(按用户、操作等过滤)

未包含(有意为之):

  • ban/unban — 刻意为之。请使用 Discord UI;不可逆的操作不应通过一次代理调用完成

  • 频道创建/删除/编辑 — 影响范围太大,请使用 UI

  • Webhook CRUD — 大多数代理流程不需要;可在未来版本中添加

  • 语音操作、贴纸/表情符号管理 — 超出 v0.1 的范围


示例:通过 Claude Code 总结频道

User: Summarize the last 30 messages in the #dev channel of my Discord server, guild ID 1234...

Claude (calls discord_list_channels → finds #dev → calls discord_list_messages → writes summary)

示例:Paperclip 代理每日摘要

// From an agent's prompt:
"Post the daily digest to channel 1234. Summarize the last 24h of activity
using discord_list_messages with limit=100, then format as an embed via
discord_send_message."

错误处理

每个工具都会返回一个可用的文本结果。出错时:

Error (DISCORD_50001, HTTP 403): Missing Access
Details: [...]
(This error is transient and may succeed on retry.)

该 MCP 已在内部处理了 429(速率限制)和 5xx(服务器错误)的重试,并带有指数退避策略。


速率限制

Discord 有两层速率限制:

  1. 按路由 — 每个 API 端点都有独立的桶。此 MCP 会按(方法 + 路由模板)序列化请求,以防止超过 429 限制。

  2. 全局 — 每个机器人,跨所有端点。此 MCP 全局遵循 Retry-After 标头。

你不需要考虑这些。如果你反复触及全局限制,你可能正在做一些需要人工介入的事情。


安全性

  • 永远不要提交你的机器人令牌。 此 MCP 在启动时从 DISCORD_BOT_TOKEN 环境变量中读取它。

  • 使用最小权限的邀请 URL。 如果你只需要“管理消息”,就不要给机器人“管理员”权限。

  • 审计日志原因 — 所有审核工具都接受一个 reason 参数,该参数会出现在 Discord 的审计日志中。请使用它。


开发

git clone https://github.com/devli13/mcp-discord.git
cd mcp-discord
npm install
npm test           # smoke tests (no live Discord calls)
npm run lint       # syntax check all files
npm start          # boot server over stdio (needs DISCORD_BOT_TOKEN)

配套项目 — 入站事件

此 MCP 处理出站 REST 调用(发送、删除、审核)。它不持有 Discord 网关 WebSocket,因此无法响应入站事件(用户 @提及机器人、私信、新成员加入)。

对于 Paperclip 设置中的入站 Discord 事件,请使用 @devli13/paperclip-plugin-discord — 它是 @mvanhorn/paperclip-plugin-discord 的一个分支,具有自由格式的 @提及路由、私信支持、序列化的每上下文消息队列以及停机期间的提及补发功能。

这两个项目旨在协同工作:插件接收事件并调用你的代理;代理使用此 MCP 进行响应和审核。根据你的设置,可以使用其中一个或两个。

归属

请参阅 ATTRIBUTION.md。简而言之:与 @mvanhorn 的 paperclip-plugin-discord 分支一起构建,其网关处理方式启发了此处的架构模式。

许可证

MIT — 请参阅 LICENSE。

Available Tools

26 tools
discord_add_reactionA

Add a reaction from the bot to a message. Emoji can be a unicode glyph (e.g. "👍") or custom-emoji string ("name:id"). Requires Add Reactions + Read Message History.

Inputs: channel_id (required), message_id (required), emoji (required).

discord_add_roleA

Add a role to a guild member. Requires Manage Roles and the target role must be below the bot's highest role.

Inputs: guild_id (required), user_id (required), role_id (required), reason.

discord_bulk_delete_messagesA

Bulk delete 2-100 messages from a channel. All messages must be less than 14 days old. Useful for raid cleanup. Requires Manage Messages permission.

Inputs: channel_id (required), message_ids (required), reason.

discord_create_threadA

Create a thread. If message_id is provided, creates a thread from that message; otherwise creates a standalone thread in the channel. auto_archive_duration is in minutes: 60, 1440, 4320, or 10080.

Inputs: channel_id (required), name (required), message_id, auto_archive_duration, +2 more.

discord_delete_messageA

Delete a single message. Requires Manage Messages for other users' messages; bot can always delete its own.

Inputs: channel_id (required), message_id (required), reason.

discord_edit_messageA

Edit a message the bot previously sent. Can edit content and embeds. Cannot edit other users' messages.

Inputs: channel_id (required), message_id (required), content, embeds.

discord_get_audit_logA

Fetch recent audit log entries. Filter by action_type (Discord AuditLogEvent enum integer) and/or user_id. Requires View Audit Log permission.

Inputs: guild_id (required), user_id, action_type, before, +1 more.

discord_get_channelB

Fetch details about a single channel — name, type, permission overwrites, parent category, rate limit, etc.

Inputs: channel_id (required).

discord_get_guildC

Fetch details for a single guild — name, icon, owner, member count, features, etc.

Inputs: guild_id (required), with_counts.

discord_get_memberC

Fetch a guild member — nickname, joined_at, roles, communication_disabled_until (timeout), etc.

Inputs: guild_id (required), user_id (required).

discord_get_messageB

Fetch a single message by ID. Useful for reading context before acting.

Inputs: channel_id (required), message_id (required).

discord_get_reactionsA

List users who reacted with a specific emoji on a message. Paginated (default 25, max 100).

Inputs: channel_id (required), message_id (required), emoji (required), limit, +1 more.

discord_kick_userA

Remove a user from the guild. They can rejoin via invite. Requires Kick Members permission.

Inputs: guild_id (required), user_id (required), reason.

discord_list_active_threadsA

List all active (non-archived) threads in a guild.

Inputs: guild_id (required).

discord_list_channelsB

List all channels in a guild (server). Includes text, voice, category, thread channels.

Inputs: guild_id (required).

discord_list_guildsA

List all guilds (servers) the bot is a member of. Useful for multi-server setups.

Inputs: limit.

discord_list_membersA

List members of a guild. Paginate with after cursor (last user ID). Requires the Server Members privileged intent on the bot.

Inputs: guild_id (required), limit, after.

discord_list_messagesA

Fetch recent messages from a channel. Paginate with before/after/around cursors. Default limit is 50, max 100.

Inputs: channel_id (required), limit, before, after, +1 more.

discord_list_rolesA

List all roles in a guild. Returns role objects sorted by position (highest first).

Inputs: guild_id (required).

discord_pin_messageA

Pin a message in a channel. Requires Manage Messages. Channels max 50 pinned messages.

Inputs: channel_id (required), message_id (required), reason.

discord_remove_reactionA

Remove a reaction. Without user_id, removes the bot's own reaction. With user_id, removes a specific user's reaction (requires Manage Messages).

Inputs: channel_id (required), message_id (required), emoji (required), user_id.

discord_remove_roleC

Remove a role from a guild member.

Inputs: guild_id (required), user_id (required), role_id (required), reason.

discord_send_messageA

Send a new message to a Discord channel. Supports plain text, embeds, replies, and allowed_mentions control. Returns the created message object including its ID.

Inputs: channel_id (required), content, embeds, reply_to_message_id, +2 more.

discord_send_typingA

Trigger the "bot is typing…" indicator in a channel for about 10 seconds. Useful before sending a long-form response so users know the bot is working.

Inputs: channel_id (required).

discord_timeout_userA

Timeout a user — they cannot send messages, react, or join voice. Up to 28 days. Pass duration_seconds=0 to remove an existing timeout. Requires Moderate Members permission.

Inputs: guild_id (required), user_id (required), duration_seconds (required), reason.

discord_unpin_messageC

Unpin a previously pinned message.

Inputs: channel_id (required), message_id (required), reason.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 26 tools

    Disambiguation4/5

    Most tools have distinct purposes targeting specific Discord resources and actions, such as send_message vs. edit_message or kick_user vs. timeout_user. However, some overlap exists: add_reaction and remove_reaction are clear, but get_reactions could be confused with list_messages for reading message content, and list_active_threads vs. create_thread might cause minor ambiguity in thread management scenarios.

    Naming Consistency5/5

    All tools follow a consistent snake_case naming pattern with a clear verb_noun structure, such as discord_send_message, discord_get_channel, and discord_list_members. The naming is predictable and uniform across all 26 tools, making it easy for agents to understand and select the appropriate tool.

    Tool Count3/5

    With 26 tools, the count is on the higher side for a Discord bot server, which may feel heavy and potentially overwhelming for agents. While Discord's API is feature-rich, this many tools could lead to decision paralysis or misselection, though it does cover a broad range of functionalities from messaging to moderation.

    Completeness4/5

    The tool set provides comprehensive coverage for core Discord bot operations, including CRUD for messages, roles, and members, as well as moderation actions like kick and timeout. Minor gaps exist, such as no tools for editing roles or managing invites, but agents can still handle most common workflows effectively without significant dead ends.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      An MCP server that allows Claude to interact with Discord by providing tools for sending/reading messages and managing server resources through Discord's API.
      19
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      An MCP server that provides native Discord tools for Claude Code, enabling bidirectional communication with remote agents or humans via the Discord REST API. It allows users to send messages, read channel history, and manage reactions directly from their local environment.
      6
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Comprehensive Discord MCP server with 66 tools that provides rich message context including emoji reactions, thread indicators, and attachment metadata inline. Enables AI assistants to interact with Discord servers for messaging, moderation, roles, channels, and more.
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A comprehensive Discord MCP server enabling AI assistants to run a Discord community through 111 tools for messaging, moderation, roles, channels, forums, webhooks, and more, plus a raw REST API passthrough for full Discord API access.
      MIT