Discord MCP Server

by v-3
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Enables interaction with Discord channels, allowing for sending messages and reading recent message history through Discord's API.

Discord MCP 服务器

一个模型上下文协议 (MCP) 服务器,使 LLM 能够与 Discord 频道交互,允许他们通过 Discord 的 API 发送和读取消息。使用此服务器,像 Claude 这样的 LLM 可以直接与 Discord 频道交互,同时保持用户的控制权和安全性。

特征

  • 向 Discord 频道发送消息
  • 阅读频道中的最新消息
  • 自动服务器和频道发现
  • 支持频道名称和 ID
  • 正确的错误处理和验证

先决条件

  • Node.js 16.x 或更高版本
  • Discord 机器人令牌
  • 必须以适当的权限邀请机器人加入您的服务器:
    • 阅读消息/查看频道
    • 发送消息
    • 阅读消息历史记录

设置

  1. 克隆此存储库:
git clone https://github.com/yourusername/discordmcp.git cd discordmcp
  1. 安装依赖项:
npm install
  1. 使用您的 Discord 机器人令牌在根目录中创建一个.env文件:
DISCORD_TOKEN=your_discord_bot_token_here
  1. 构建服务器:
npm run build

与 Claude 桌面版一起使用

  1. 打开您的 Claude for Desktop 配置文件:
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. 添加 Discord MCP 服务器配置:
{ "mcpServers": { "discord": { "command": "node", "args": ["path/to/discordmcp/build/index.js"], "env": { "DISCORD_TOKEN": "your_discord_bot_token_here" } } } }
  1. 重启 Claude 桌面版

可用工具

发送消息

向指定的 Discord 频道发送消息。

参数:

  • server (可选):服务器名称或 ID(如果机器人位于多个服务器中则为必需)
  • channel :频道名称(例如“general”)或 ID
  • message :要发送的消息内容

例子:

{ "channel": "general", "message": "Hello from MCP!" }

阅读消息

从指定的 Discord 频道读取最新消息。

参数:

  • server (可选):服务器名称或 ID(如果机器人位于多个服务器中则为必需)
  • channel :频道名称(例如“general”)或 ID
  • limit (可选):要获取的消息数量(默认值:50,最大值:100)

例子:

{ "channel": "general", "limit": 10 }

发展

  1. 安装开发依赖项:
npm install --save-dev typescript @types/node
  1. 以开发模式启动服务器:
npm run dev

测试

您可以使用 MCP 检查器测试服务器:

npx @modelcontextprotocol/inspector node build/index.js

示例

设置 Discord MCP 服务器后,您可以尝试与 Claude 进行以下一些示例交互:

  1. “您能读取普通频道的最后5条消息吗?”
  2. “请向公告频道发送一条消息,说明‘会议将在 10 分钟后开始’”
  3. “开发频道中关于最新版本的最新消息是什么?”

克劳德将使用适当的工具与 Discord 进行交互,同时在发送任何消息之前征求您的批准。

安全注意事项

  • 该机器人需要适当的 Discord 权限才能运行
  • 所有消息发送操作均需要用户明确批准
  • 环境变量应得到妥善保护
  • 令牌永远不应该提交到版本控制
  • 频道访问仅限于机器人被授予访问权限的频道

贡献

  1. 分叉存储库
  2. 创建你的功能分支( git checkout -b feature/amazing-feature
  3. 提交您的更改( git commit -m 'Add some amazing feature'
  4. 推送到分支( git push origin feature/amazing-feature
  5. 打开拉取请求

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。

支持

如果您遇到任何问题或有疑问:

  1. 查看 GitHub 问题部分
  2. 请参阅https://modelcontextprotocol.io上的 MCP 文档
  3. 开启新问题并附上详细的复现步骤
-
security - not tested
F
license - not found
-
quality - not tested

通过 Discord 的 API 发送和读取消息,使 LLM 能够与 Discord 频道进行交互,重点是维护用户控制和安全。

  1. Features
    1. Prerequisites
      1. Setup
        1. Usage with Claude for Desktop
          1. Available Tools
            1. send-message
            2. read-messages
          2. Development
            1. Testing
              1. Examples
                1. Security Considerations
                  1. Contributing
                    1. License
                      1. Support
                        ID: ppamx796eb