Skip to main content
Glama
hevji

Discord MCP Server

by hevji

Discord MCP Server

直接从你的 AI 编程助手中管理 Discord 服务器。创建频道、分类、角色,设置权限,分配角色,以及更多操作——全部通过自然语言完成。

virustotal: https://www.virustotal.com/gui/file/56fafed35e2734debed600e585741c53f456148da257065e9ea8c9fcb62c798d

工具

工具

描述

create_category

创建新的分类频道

create_channel

在分类下创建文字或语音频道

create_role

创建具有颜色、独立显示、可提及属性的新角色

edit_role

编辑角色的名称、颜色、独立显示或可提及属性

delete_role

删除角色(非托管,且位于机器人层级之下)

assign_role

按用户名将角色分配给成员

remove_role

按用户名移除成员的角色

restrict_channel

设置频道权限(允许/拒绝角色、只读模式、帖子控制)

create_role_restricted_channel

一次调用即可创建频道并设置限制

rename_channel

重命名文字或语音频道

delete_category

删除分类频道

delete_channel

删除文字或语音频道

list_channels

列出所有频道及其名称、类型和分类

list_roles

列出所有角色及其名称、颜色和成员数量

create_webhook

在文字频道中创建 Webhook

send_webhook_message

通过现有 Webhook 发送消息

set_slowmode

设置文字频道的慢速模式延迟(秒)

Related MCP server: discord-mcp

设置

1. 创建 Discord 机器人

  1. 前往 https://discord.com/developers/applications

  2. 点击新建应用 → 为其命名 → 创建

  3. 转到机器人 → 添加机器人

  4. 在特权网关意图下,启用:

    • Server Members Intent

    • Message Content Intent

  5. 复制令牌

  6. 转到 OAuth2 → URL 生成器

    • 作用域:bot

    • 机器人权限:Administrator(或手动选择:管理频道、管理角色、踢出成员、管理 Webhook、发送消息、读取消息、查看频道)

  7. 在浏览器中打开生成的 URL,将机器人邀请到你的服务器

2. 配置环境

cp .env.example .env

编辑 .env 并粘贴你的机器人令牌:

DISCORD_TOKEN=your_token_here

可选:按名称将机器人固定到特定服务器(默认为 Monolith)。所有工具仅在此服务器上运行:

DISCORD_GUILD_NAME=Monolith

3. 安装依赖

pip install -r requirements.txt

MCP 主机配置

opencode

将以下内容添加到项目根目录的 opencode.json 中:

{
  "mcp": {
    "discord": {
      "type": "local",
      "command": ["python", "/absolute/path/to/discord_mcp_server.py"]
    }
  }
}

重启 opencode 以加载服务器。

Claude Desktop

编辑 claude_desktop_config.json(文件 → 设置 → 开发者 → 编辑配置):

{
  "mcpServers": {
    "discord": {
      "command": "python",
      "args": ["/absolute/path/to/discord_mcp_server.py"],
      "env": {
        "DISCORD_TOKEN": "your_token_here"
      }
    }
  }
}

Claude Code

将以下内容添加到 ~/.claude.json 或项目中的 .mcp.json:

{
  "mcpServers": {
    "discord": {
      "command": "python",
      "args": ["/absolute/path/to/discord_mcp_server.py"],
      "env": {
        "DISCORD_TOKEN": "your_token_here"
      }
    }
  }
}

Cursor

在项目根目录创建 .cursor/mcp.json(或全局使用 ~/.cursor/mcp.json):

{
  "mcpServers": {
    "discord": {
      "command": "python",
      "args": ["/absolute/path/to/discord_mcp_server.py"],
      "env": {
        "DISCORD_TOKEN": "your_token_here"
      }
    }
  }
}

Windsurf

将以下内容添加到 ~/.codeium/windsurf/mcp_config.json:

{
  "mcpServers": {
    "discord": {
      "command": "python",
      "args": ["/absolute/path/to/discord_mcp_server.py"],
      "env": {
        "DISCORD_TOKEN": "your_token_here"
      }
    }
  }
}

Codex CLI

将以下内容添加到 ~/.codex/config.toml:

[mcp_servers.discord]
command = "python"
args = ["/absolute/path/to/discord_mcp_server.py"]

[mcp_servers.discord.env]
DISCORD_TOKEN = "your_token_here"

或通过 CLI 添加:

codex mcp add discord -- python /absolute/path/to/discord_mcp_server.py

Antigravity (Google)

将以下内容添加到 ~/.gemini/config/mcp_config.json:

{
  "mcpServers": {
    "discord": {
      "command": "python",
      "args": ["C:\\path\\to\\discord_mcp_server.py"],
      "env": {
        "DISCORD_TOKEN": "your_token_here"
      }
    }
  }
}

打开 Antigravity → Agent 面板 → ... → MCP 服务器 → 管理 MCP 服务器 → 查看原始配置。

注意: 如果使用 .env 文件而不是内联的 env,请省略 env 块,并确保脚本中的 load_dotenv() 能找到你的 .env(工作目录取决于主机)。

工作原理

该脚本通过 stdio 运行一个 MCP 服务器,通过机器人令牌连接到 Discord。它在启动时注册所有工具,你的 AI 助手可以按需调用这些工具。Discord 机器人只需要在一个服务器中——它会在登录时自动选择第一个服务器。

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    F
    maintenance
    Control your Discord server with AI. Lets you manage channels, roles, members, messages, and more through natural language.
    131 npm
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Enables AI clients to manage Discord servers, including channels, messages, roles, members, permissions, threads, invites, events, webhooks, and emoji, through natural language commands.
    55
    131 npm
    1
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables AI assistants to interact with Discord by managing servers, channels, roles, members, messages, forum posts, reactions, webhooks, and permissions.
    1,016 npm
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables AI assistants to interact with the Discord platform for managing servers, channels, messages, roles, members, forums, and webhooks through natural language.
    1,016 npm
    MIT