MCP-Discord 是一个 Discord MCP(模型上下文协议)服务器,可让 AI 助手与 Discord 平台进行交互,实现如登录机器人、管理频道、处理消息等多种功能。
MCP-Discord 提供了与 Discord 相关的丰富功能,包括但不限于:
message_content、messages 和 guilds使用 npm 安装 MCP-Discord:
# 使用 npm 安装 MCP-Discord
npm install mcp-discord
在你的项目根目录中创建或编辑 .env 文件,并添加以下内容:
DISCORD_TOKEN=your_discord_bot_token_here
MCP_ENDPOINT=https://mcp.discord.com
在你的主文件中导入并初始化 MCP-Discord:
const { Discord } = require('mcp-discord');
async function main() {
const discord = new Discord({
token: 'your_discord_bot_token',
endpoint: 'https://mcp.discord.com'
});
// 处理消息事件
discord.onMessage((message) => {
console.log(`收到消息:${message.content}`);
});
}
main().catch(console.error);
discord.login(): 登录到 Discord 机器人。discord.logout(): 注销登录的 Discord 机器人。discord.getServerInfo(guildId): 获取指定服务器的信息。discord.createChannel(guildId, channelName, type): 在指定服务器中创建新频道。discord.deleteChannel(channelId): 删除指定的频道。discord.getChannels(guildId): 获取指定服务器中的所有频道。discord.createForumPost(threadId, content): 在指定的论坛线程中创建新的帖子。discord.replyToThread(threadId, replyContent): 在指定的论坛线程中回复消息。discord.deleteForumPost(postId): 删除指定的论坛帖子。discord.sendMessage(channelId, message): 向指定频道发送消息。discord.getMessage(messageId, channelId): 获取指定频道中的特定消息。discord.addReaction(messageId, channelId, emoji): 在指定的消息上添加表情反应。discord.createWebhook(webhookName, guildId, channelId): 为指定频道创建新的网钩。discord.sendWebhookMessage(webhookId, webhookToken, message): 使用网钩向指定频道发送消息。discord.deleteWebhook(webhookId): 删除指定的网钩。在开发模式下启动:
# 开发模式启动
npm run dev
本项目采用 MIT License。