MCP 中继服务器可实现 Claude 向 Discord 频道发送消息与提示,并接收相应反馈,为信息交互提供便利。
send - message 工具,可发送不同类型的消息。⚠️ 重要提示
请务必妥善保管此令牌,切勿公开分享。
服务器需要在你的 MCP 设置文件中进行配置。在你的配置文件中添加以下内容:
{
"mcpServers": {
"discord-relay": {
"command": "node",
"args": [
"/ABSOLUTE/PATH/TO/MCP Relay/build/index.js"
],
"env": {
"DISCORD_TOKEN": "your_bot_token_here",
"DISCORD_CHANNEL_ID": "your_channel_id_here"
}
}
}
}
替换:
/ABSOLUTE/PATH/TO/MCP Relay 为你的 MCP 中继项目的实际路径。your_bot_token_here 为你自己的 Discord 机器人令牌。your_channel_id_here 为你自己的 Discord 频道 ID。⚠️ 重要提示
请确保在配置中使用绝对路径。
服务器提供了一个名为 send - message 的工具,接受以下参数:
{
type: 'prompt' | 'notification', // 消息类型
title: string, // 消息标题
content: string, // 消息内容
actions?: Array<{ // 可选操作按钮
label: string, // 按钮标签
value: string // 点击时返回的值
}>,
timeout?: number // 可选超时时间(以毫秒为单位)
}
简单的不需要回复的消息:
{
"type": "notification",
"title": "你好",
"content": "这是一个通知"
}
等待回复的消息:
{
"type": "prompt",
"title": "问题",
"content": "你想要继续吗?",
"actions": [
{ "label": "是", "value": "yes" },
{ "label": "否", "value": "no" }
],
"timeout": 60000 // 可选:1 分钟超时
}
⚠️ 重要提示
- 提示可以由点击操作按钮或发送文本消息来回答。
- 每个提示仅接受一个响应。
- 如果设置了超时,提示将在超时后失败。
- 通知不会等待回复并立即返回。