MCP Discord流
](https://www.npmjs.com/package/@yangyifei/mcp-discord-stream) 
Discord MCP(模型上下文协议)服务器 无限制的消息流、论坛归档和时间范围过滤功能。
分叉通知: 这是一个增强的fork barryyip0625/mcp不一致 添加了流媒体功能,可读取无限的Discord历史记录。
概述
MCP Discord Stream提供全面的Discord集成,具有强大的流媒体功能:
🆕 流媒体功能(新增!)
- 无限制的消息历史记录 -阅读来自频道/论坛的所有消息(不限于100条消息)
- 时间范围过滤 -从特定日期范围获取消息(默认值:过去10天)
- 论坛存档 -将包含所有帖子和消息的整个论坛存档
- 批量操作 -同时从多个渠道/论坛流式传输
- 进度跟踪 -长时间运行期间的实时进度更新
- 费率限制处理 -优雅地处理部分数据返回的不一致率限制
标准功能
- 登录Discord机器人
- 列出机器人所属的服务器
- 获取服务器信息
- 在服务器中搜索邮件
- 读取/删除频道消息
- 向指定频道发送消息
- 检索论坛频道列表
- 创建/删除/回复论坛帖子
- 创建/删除文本频道
- 添加/删除消息反应
- 创建/编辑/删除/使用webhooks
目录
- 🆕 流媒体工具 - 基本功能 - 渠道管理 - 论坛功能 - 信息和反应 - Webhook管理
先决条件
- Node.js(v18.0.0或更高版本)
- npm(v7.0.0或更高版本)
- 具有适当权限的Discord机器人
- Bot令牌(可从 Discord开发者门户) - 消息内容意图已启用 (必填!) - 服务器成员意图已启用 - 已启用存在意图
- Discord服务器中所需的权限:
#### 最简单的设置
- 管理员(建议用于快速设置和完整功能)
#### 或者,仅选择所需的权限:
- 查看频道 - 读取消息历史 (流媒体播放需要!) - 发送消息 - 创建公共线程 - 在线程中发送消息 - 管理邮件 - 管理线程 - 管理渠道 - 管理Webhooks - 添加反应
- 将您的Discord机器人添加到您的服务器
- 要将您的Discord机器人添加到服务器,请使用以下邀请链接之一(替换 INSERT_CLIENT_ID_HERE 使用您的机器人客户端ID): - 管理员(完全访问权限): https://discord.com/oauth2/authorize?client_id=INSERT_CLIENT_ID_HERE&scope=bot&permissions=8 - 自定义权限(最低要求): https://discord.com/oauth2/authorize?client_id=INSERT_CLIENT_ID_HERE&scope=bot&permissions=52076489808
重要提示: 根据Discord的安全模型,机器人只能访问其明确添加到的服务器上的信息。 通过“读取消息历史”权限,机器人可以读取在添加到服务器之前发送的消息!
安装
通过NPM安装
npm install -g @yangyifei/mcp-discord-stream或者直接通过npx使用:
npx @yangyifei/mcp-discord-stream --config ${DISCORD_TOKEN}手动安装
# Clone the repository
git clone https://github.com/Yv3s-y4ng/mcp-discord-stream.git
cd mcp-discord-stream
# Install dependencies
npm install
# Compile TypeScript
npm run build配置
正常操作需要Discord机器人令牌。服务器支持两种传输方式:stdio和流式HTTP。
运输方式
- 标准 (默认)
- 用于基本用途的传统stdio传输 - 适用于简单的集成
- 可流式传输HTTP
- 用于更高级场景的基于HTTP的传输 - 支持无状态操作 - 可配置的端口号
配置选项
您可以通过两种方式提供配置:
- 环境变量:
DISCORD_TOKEN=your_discord_bot_token- 使用命令行参数:
# For stdio transport (default)
node build/index.js --config "your_discord_bot_token"
# For streamable HTTP transport
node build/index.js --transport http --port 3000 --config "your_discord_bot_token"使用Claude/Cursor
克劳德桌面版
- 使用stdio传输:
{
"mcpServers": {
"discord": {
"command": "npx",
"args": [
"@yangyifei/mcp-discord-stream",
"--config",
"your_discord_bot_token"
]
}
}
}- 使用流式HTTP传输:
{
"mcpServers": {
"discord": {
"command": "npx",
"args": [
"@yangyifei/mcp-discord-stream",
"--transport",
"http",
"--port",
"3000",
"--config",
"your_discord_bot_token"
]
}
}
}光标
- 使用stdio传输:
{
"mcpServers": {
"discord": {
"command": "cmd",
"args": [
"/c",
"npx",
"@yangyifei/mcp-discord-stream",
"--config",
"your_discord_bot_token"
]
}
}
}用法示例
示例1:从频道流式传输所有消息
// Fetch last 30 days of messages (unlimited)
discord_read_messages_stream({
channelId: "123456789",
afterDate: "2024-01-01T00:00:00Z" // Optional: start from this date
})示例2:存档整个论坛
// Archive all forum threads with messages from last 60 days
discord_archive_forum_stream({
forumChannelId: "987654321",
afterDate: "2024-01-01T00:00:00Z",
includeArchived: true
})示例3:批量存档多个论坛
// Archive 3 forums at once
discord_archive_multiple_forums({
forumChannelIds: ["111", "222", "333"],
afterDate: "2024-01-01T00:00:00Z"
})工具文档
🆕 流媒体工具(新!)
discord_read_messages_stream
通过不受限制的历史记录和时间范围过滤从Discord频道流式传输消息。
参数:
channelId(string,必填)-要读取的通道的IDafterDate(字符串,可选)-ISO 8601日期字符串(例如“2024-01-01T00:00:00Z”)-仅获取此日期之后的消息beforeDate(字符串,可选)-ISO 8601日期字符串-仅获取此日期之前的消息
违约: 如果没有提供日期范围,则获取过去10天的消息。
退货:
- 流事件包括
batch,progress,rate_limited,以及complete事件 - 每批最多包含100条消息,其中包含完整的消息数据(内容、作者、时间戳、附件等)
discord_read_multiple_channels
按顺序从多个通道流式传输消息。
参数:
channelIds(string\[\],必填)-要读取的通道ID数组afterDate(字符串,可选)-ISO 8601日期字符串beforeDate(字符串,可选)-ISO 8601日期字符串
退货: 所有通道的汇总结果,每个通道都有成功/错误状态。
discord_get_channel_list
使用可选类型筛选列出Discord服务器中的所有频道。
参数:
guildId(string,必填)-Discord服务器的IDchannelTypes(number\[\],可选)-要过滤的Discord ChannelType数字数组
- 0 =文本频道 - 2 =语音通道 - 4 =类别 - 15 =论坛频道 - 完整通道类型列表
退货: 带有id、名称、类型和parentId的频道列表。
discord_get_forum_post_stream
流式传输来自单个论坛帖子/线程的所有消息,历史记录不受限制。
参数:
threadId(string,必填)-论坛线程的IDafterDate(字符串,可选)-ISO 8601日期字符串beforeDate(字符串,可选)-ISO 8601日期字符串
退货: 将事件与来自线程的所有消息一起流式传输。
discord_archive_forum_stream
通过流式传输所有帖子及其消息来存档整个论坛频道。
参数:
forumChannelId(string,必填)-论坛频道的IDafterDate(字符串,可选)-ISO 8601日期字符串beforeDate(字符串,可选)-ISO 8601日期字符串includeArchived(布尔值,可选,默认值:true)-是否包含存档线程
退货:
threads_found具有总线程数的事件thread_progress正在处理的每个线程的事件- 来自所有线程的消息批处理
complete或partial_complete事件摘要
discord_archive_multiple_forums
同时归档多个论坛频道。
参数:
forumChannelIds(string\[\],必填)-论坛频道ID数组afterDate(字符串,可选)-ISO 8601日期字符串beforeDate(字符串,可选)-ISO 8601日期字符串includeArchived(布尔值,可选,默认值:true)-包括已存档的线程
退货: 所有论坛的汇总结果。
______________________________________________________________________
基本功能
discord_login:使用配置的令牌登录Discorddiscord_list_servers:列出机器人所属的所有Discord服务器discord_send:向指定频道发送消息(支持频道ID和频道名称)discord_get_server_info:获取Discord服务器信息
渠道管理
discord_create_text_channel:创建文本频道discord_delete_channel:删除频道discord_create_category:创建频道类别discord_edit_category:编辑类别discord_delete_category:删除类别
论坛功能
discord_get_forum_channels:获取论坛频道列表discord_create_forum_post:创建论坛帖子discord_get_forum_post:获取论坛帖子(限制为10条消息-使用discord_get_forum_post_stream了解更多)discord_list_forum_threads:列出论坛中的所有帖子discord_reply_to_forum:回复论坛帖子discord_delete_forum_post:删除论坛帖子
信息和反应
discord_search_messages:在服务器中搜索邮件discord_read_messages:阅读频道消息(限制为100条-使用discord_read_messages_stream了解更多)discord_add_reaction:在消息中添加反应discord_add_multiple_reactions:在消息中添加多个反应discord_remove_reaction:从消息中删除反应discord_delete_message:从频道中删除特定消息
Webhook管理
discord_create_webhook:为Discord频道创建新的webhookdiscord_send_webhook_message:使用webhook向Discord频道发送消息discord_edit_webhook:编辑Discord频道的现有webhookdiscord_delete_webhook:删除Discord频道的现有webhook
流媒体功能详解
时间范围过滤
所有流媒体工具都支持通过ISO 8601日期字符串进行时间范围过滤:
// Fetch messages from a specific time range
{
afterDate: "2024-01-01T00:00:00Z", // Start date (inclusive)
beforeDate: "2024-12-31T23:59:59Z" // End date (inclusive)
}
// Fetch messages from last X days (omit both dates to use default 10 days)
{
afterDate: "2024-01-15T00:00:00Z" // Last 10+ days
}
// Fetch ALL messages (no time limit - use with caution!)
{
afterDate: "2015-01-01T00:00:00Z" // Discord's founding year
}流事件类型
流媒体工具返回不同的事件类型以提供实时反馈:
progress-在提取过程中定期更新进度batch-包含消息数据(每批最多100条消息)threads_found-(仅限论坛)发现的线程总数thread_progress-(仅限论坛)当前正在处理的线程rate_limited-达到故障率限制,包括重试等待时间complete-已成功获取所有数据partial_complete-返回部分数据(例如,由于速率限制或错误)
费率限制处理
当达到Discord速率限制时:
- 工具返回a
rate_limited具有等待时间的事件 - 已获取的数据返回为
partial_complete - 您可以在等待期后重试请求
性能提示
- 使用特定日期范围 -时间范围窄=响应更快
- 按顺序处理通道 -使用
discord_read_multiple_channels而不是并行请求 - 监控速率限制 -Discord具有每个通道和全局速率限制
- 非高峰时段存档 -服务器活动较低时,大型档案最有效
发展
# Install dependencies
npm install
# Development mode with auto-reload
npm run dev
# Run tests
npm test
# Build for production
npm run build
# Run built version
npm start贡献
欢迎投稿!请随时提交拉取请求。
- 分叉存储库
- 创建功能分支(
git checkout -b feature/amazing-feature) - 提交您的更改(
git commit -m 'Add some amazing feature') - 推到分支(
git push origin feature/amazing-feature) - 打开拉取请求
许可证
致谢
这个项目是 barryyip0625/mcp不一致 显著增强了无限消息流和归档功能。
特别感谢:
- Barry Yip(@barryyip0625)为最初的MCP Discord实现
- 模型上下文协议的Anthropic团队
- Discord.js社区提供优秀的Discord API库
