article
README
🚀 Discord 原始 API MCP 服务器
本 MCP 服务器借助灵活工具,为用户提供对 Discord 原始 API 的访问能力。它支持 REST API 调用以及 Slash 命令语法,能满足多样化的使用需求。
🚀 快速开始
本 Discord 原始 API MCP 服务器能让你便捷地使用 Discord 原始 API,支持 REST API 调用和 Slash 命令语法。下面为你介绍详细的安装、配置和使用方法。
✨ 主要特性
- 提供灵活的 Discord 原始 API 访问途径。
- 支持 REST API 调用和 Slash 命令语法。
📦 安装指南
通过 Smithery 安装
若要借助 Smithery 自动为 Claude Desktop 安装 Discord 原始 API,可使用以下命令:
npx -y @smithery/cli install @hanweg/mcp-discord-raw --client claude
手动安装
- 设置 Discord 机器人:
- 前往 Discord 开发者控制台 创建一个新应用。
- 为该应用创建一个机器人用户,并获取其令牌。
- 安装依赖项并设置项目结构:
git clone https://github.com/yourusername/mcp-discord-raw.git
cd mcp-discord-raw
npm install
- 配置 Discord API 的环境变量:
- 创建一个
.env文件,并添加以下内容(需将YOUR_DISCORD_TOKEN替换为你自己的令牌):
- 创建一个
DISCORD_TOKEN=your_discord_token_here
- 运行服务器:
npm start
🛠️ 配置
在 config.json 文件中,添加以下配置以启用 Discord 原始 API 支持:
{
"apiEndpoints": {
"discord": {
"url": "https://discord.com/api/v9"
}
},
"botConfig": {
"token": "your_discord_token_here",
"prefix": "/"
}
}
💻 使用示例
基础用法
REST API 风格
使用 raw 命令与 Discord API 进行交互:
{
"command": "raw",
"endpoint": "/users/{user_id}",
"method": "GET",
"headers": {
"Authorization": "Bearer your_discord_token_here"
}
}
Slash Command 风格
使用 slash 命令创建和管理 Slash 命令:
{
"command": "slash",
"name": "ping",
"description": "测试机器人是否正常运行。",
"options": []
}
高级用法
创建频道
使用以下 JSON 请求创建一个新频道:
{
"command": "raw",
"endpoint": "/guilds/{guild_id}/channels",
"method": "POST",
"headers": {
"Authorization": "Bearer your_discord_token_here"
},
"body": {
"name": "new-channel-name",
"type": 0
}
}
发送消息
使用以下 JSON 请求向指定频道发送消息:
{
"command": "raw",
"endpoint": "/channels/{channel_id}/messages",
"method": "POST",
"headers": {
"Authorization": "Bearer your_discord_token_here"
},
"body": {
"content": "Hello, Discord!"
}
}
📚 详细文档
推荐内容
- 保存 ID:创建请求返回的 ID 以便后续使用。
- Unicode 表情符号:直接在消息中包含 Unicode 表情符号(如
\:champagne_glass:)可能会导致 Claude Desktop 挂起,请告知模型使用 Discord 表情符号。 - 频道类型:0 = 文本,2 = 语音,4 = 类别,13 = 舞台
- 角色颜色:以十进制格式表示(非十六进制)
- 大多数修改端点:使用 PATCH 方法
- 空有效负载:应为
{}而不是null
📄 许可证
本项目采用 MIT License 进行许可。
微信扫一扫