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 // 示例:60秒超时
}