使用说明
discord-mcp-server
A Model Context Protocol (MCP) server that exposes Discord operations as tools for AI assistants.
这是什么?
不和谐mcp服务器 允许任何兼容MCP的AI客户端(Claude Desktop、Cursor、Windsurf等)与Discord交互——发送消息、管理频道、创建Webhook、分配角色等。
特性
| 类别 | 工具 |
|---|---|
| 🏠 察看连接信息 | list_servers, get_server_info |
| 📢 频道 | list_channels, find_channel, create_text_channel, create_voice_channel, delete_channel, create_category, list_categories, move_channel |
| 💬 消息 | send_message, read_messages, edit_message, delete_message, add_reaction, remove_reaction |
| 🔗 网络钩子 | list_webhooks, create_webhook, delete_webhook, send_webhook_message, edit_webhook |
| 🎭 角色 | list_roles, create_role, edit_role, delete_role, assign_role, remove_role |
| 🧵 线程 | list_threads, create_thread, reply_to_thread, get_thread |
31工具 涵盖了最常见的Discord操作。论坛帖子支持通过 create_thread.
先决条件
创建Discord Bot
- 去 Discord开发者门户
- 点击 新应用程序 → 给它起个名字
- 首选 机器人 → click 重置令牌 → 复制令牌
- 在...之下 特权网关意图,启用:
- ✅ 消息内容意图
- ✅ 服务器成员意图
- 首选 OAuth2 → URL生成器
- 范围:
bot - 机器人权限:
Administrator(或樱桃采摘权限)
- 范围:
- 复制生成的URL并打开它以邀请机器人到您的服务器
快速开始
选项1:npx(推荐)
npx @ncodelife/discord-mcp-server --token YOUR_BOT_TOKEN
选项2:全局安装
npm install -g @ncodelife/discord-mcp-server
discord-mcp-server --token YOUR_BOT_TOKEN
选项3:Docker
docker build -t discord-mcp-server .
docker run -e DISCORD_TOKEN=YOUR_BOT_TOKEN discord-mcp-server
MCP客户端配置
克劳德桌面
添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"discord": {
"command": "npx",
"args": ["@ncodelife/discord-mcp-server", "--token", "YOUR_BOT_TOKEN"]
}
}
}
光标/风帆
添加到MCP设置中:
{
"discord": {
"command": "npx",
"args": ["@ncodelife/discord-mcp-server", "--token", "YOUR_BOT_TOKEN"]
}
}
史密瑟里
通过Smithery安装以进行自动配置。
配置
| 选项 | CLI标志 | 环境变量 | 默认值 |
|---|---|---|---|
| 机器人令牌 | --token |
DISCORD_TOKEN |
必需的 |
| 默认公会ID | --guild-id |
DISCORD_GUILD_ID |
— |
| 运输 | --transport |
MCP_TRANSPORT |
stdio |
| HTTP端口 | --port |
MCP_PORT |
8080 |
使用a .env 文件
DISCORD_TOKEN=your-bot-token-here
DISCORD_GUILD_ID=your-server-id
运输方式
stdio(默认)
标准I/O传输——由Claude Desktop、Cursor和大多数MCP客户端使用。
discord-mcp-server --token YOUR_TOKEN
HTTP流
对于基于web的集成和远程访问:
discord-mcp-server --token YOUR_TOKEN --transport http --port 8080
关于构建目标的说明: npm包是用
--target node所以npx到处工作。Docker镜像使用--target bun为本地Bun表演。两者功能齐全。
发展
# Clone the repo
git clone https://github.com/ngoctranfire/discord-mcp-server.git
cd discord-mcp-server
# Install dependencies
bun install
# Run in development
bun run dev
# Type-check
bun run typecheck
# Lint
bun run lint
# Test with MCP Inspector
bun run inspect
建筑
src/
├── index.ts # Entry point — FastMCP server setup
├── config.ts # CLI args + env var merging
├── discord.ts # Discord.js client factory
├── utils.ts # Shared utilities (error handling, formatting)
└── tools/
├── server-info.ts # Server listing & details
├── channels.ts # Channel CRUD operations
├── messages.ts # Message send/read/edit/delete + reactions
├── webhooks.ts # Webhook management
├── roles.ts # Role CRUD + assignment
└── threads.ts # Thread & forum operations
贡献
看 贡献.md 有关设置、开发和提交pull请求的指南。