Discord-Notify-MCP(注:此处“MCP”可能代表特定的模块、配置或功能,具体含义需根据上下文确定,直译为“MCP通知Discord”可能不够准确,但在此保留原样以体现原文的特定性)
discord-notify-mcp 这是一个MCP(模型上下文协议)服务器,它通过标准输入输出暴露了一个Discord通知工具。运行它时 bunx将您的MCP兼容客户端指向该进程,并直接从您的自动化流程或工作流中触发webhook消息。
特点/特性
- Discord通知工具 – 发布一个
notifyMCP工具,用于向通过(某方式)配置的Discord webhook发送消息DISCORD_WEBHOOK_URL。 - 用户提及支持 – 当
DISCORD_USER_ID设置完成后,该工具会在消息前加上@提及,以便指定的用户收到通知。 - 自动分块 – 将超过2000个字符的有效载荷拆分成连续的消息,以遵守Discord的内容限制。
要求
- Bun 版本 1.2 或更高版本
DISCORD_WEBHOOK_URL包含有效Discord Webhook URL的环境变量- (可选)
DISCORD_USER_ID用于自动提及用户 - (可选)
DISCORD_NOTIFY_USER_NAME覆盖Discord中显示的用户名
安装
bun install通过您的shell配置所需的环境变量, .env,或者是一个进程管理器:
export DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks//"
# Optional
export DISCORD_USER_ID=""
# Optional
export DISCORD_NOTIFY_USER_NAME="notify-bot"运行服务器
在开发过程中:
bun run dev克劳德代码配置
claude mcp add \
--env DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks//" \
--env DISCORD_USER_ID="" \
--env DISCORD_NOTIFY_USER_NAME="notify-bot" \
notify -- bunx discord-notify-mcp@latestCodex CLI 配置
[mcp_servers.notify]
command = "bunx"
args = ["discord-notify-mcp@latest"]
[mcp_servers.notify.env]
DISCORD_WEBHOOK_URL = "https://discord.com/api/webhooks//"
DISCORD_USER_ID = "discord-user-id"
DISCORD_NOTIFY_USER_NAME = "notify-bot"该进程保持连接到标准输入(STDIN)/标准输出(STDOUT),等待MCP流量。一旦您的客户端发送 initialize,该 notify 工具现已可用。
调用该工具
从您的MCP客户端发送一个工具调用,类似于以下有效载荷:
{
"type": "tool",
"toolName": "notify",
"arguments": {
"title": "Deployment complete ✅",
"body": "Release Bot confirmed that all services are healthy.",
"username": "Release Bot"
}
}如果 DISCORD_USER_ID 一旦配置完成,第一行会自动变为 **title**,以及工具套装 allowed_mentions.users 因此,Discord 在执行提及操作时会防止意外的大规模提醒。
项目脚本
# Format files in-place with Biome
bun run format
# Verify formatting only
bun run format:check
# Type-check with TypeScript
bun run typecheck
# Lint with Biome rules
bun run lint
# Run all Vitest suites
bun run test
# CI aggregate: format:check → typecheck → lint → test
bun run ci目录布局
src/
config.ts Environment validation and caching helpers
discord.ts Lightweight Discord webhook client
notification-action.ts MCP notification tool implementation
server.ts MCP server bootstrap and tool registration
main.ts bunx entry point
tests/
*.test.ts Vitest suites covering config, client, action, server, and style rules故障排除
- 启动时进程失败\
再检查一下以确保 DISCORD_WEBHOOK_URL 以……开始 https://discord.com/api/webhooks/ 并且没有多余的空白字符。
- 消息未送达\
MCP 工具会将 Discord 的 HTTP 错误传播回客户端。请检查错误以确认是否存在速率限制或权限问题。
- 风格测试失败\
tests/conventions.test.ts 确保 class 和 function 声明缺失。在添加新代码时,请使用箭头函数。
许可证
麻省理工学院(MIT)许可证。详见 LICENSE 详情见下。
