使用说明
不和谐mcp
使用AI控制您的Discord服务器。将此MCP服务器连接到Claude、Cursor、Copilot或任何兼容MCP的AI工具,并通过对话管理您的服务器——不需要Discord仪表板。
你能做什么
连接后,自然地问你的AI助手:
- 从头开始设置服务器 --以一致的布局和风格创建频道、类别和角色
- 管理成员 --搜索成员、分配角色、问题超时、取消或禁止用户、查看禁止列表
- 发送和管理消息 --发布到频道、编辑消息、固定重要帖子、添加反应、清除消息
- 自动调节 --创建和管理AutoMod规则以过滤内容
- 安排活动 --创建和管理计划事件、阶段实例和公告
- 组织渠道 --重新排序频道和类别,为每个角色设置权限,管理线程
- 自定义您的服务器 --更新服务器设置,管理表情符号、贴纸和音板声音
- 创建邀请和webhooks --生成邀请链接,设置用于集成的webhooks
- 评审活动 --阅读审计日志,查看谁做了什么以及何时做了什么
破坏性行为(删除频道、禁止成员、清除消息)在发生任何事情之前都需要明确确认。
需求
设置
1.安装依赖项
bun install
2.创建配置文件
cp .env.example .env
3.填写您的Discord凭据
打开 .env 并设置为最小值:
DISCORD_TOKEN=your_bot_token_here
DISCORD_APPLICATION_ID=your_app_id_here
确保您的机器人已被邀请到您的服务器,并具有必要的权限。
4.启动服务器
bun run start
MCP服务器现在正在运行 http://127.0.0.1:3456/mcp.
连接到您的AI工具
克劳德桌面
打开克劳德桌面设置→ MCP → 添加服务器:
- 网址:
http://127.0.0.1:3456/mcp - 运输: 可流式传输的HTTP
保存后重新启动Claude Desktop。
克劳德代码
claude mcp add --transport http discord-mcp http://127.0.0.1:3456/mcp
光标
创建 .cursor/mcp.json 在您的项目中(或 ~/.cursor/mcp.json 全球):
{
"mcpServers": {
"discord-mcp": {
"url": "http://127.0.0.1:3456/mcp"
}
}
}
重新启动Cursor,然后验证Agent聊天中是否有可用的工具。
VS代码(副驾驶/代理模式)
创建 .vscode/mcp.json 在您的项目中:
{
"servers": {
"discord-mcp": {
"type": "http",
"url": "http://127.0.0.1:3456/mcp"
}
}
}
然后运行 MCP: List Servers 从命令面板进行验证。
GitHub Copilot命令行界面
编辑 ~/.copilot/mcp-config.json:
{
"mcpServers": {
"discord-mcp": {
"type": "http",
"url": "http://127.0.0.1:3456/mcp",
"tools": ["*"]
}
}
}
安全
一些内置护栏:
- 帮派排外主义者 --set
DISCORD_GUILD_ALLOWLIST以逗号分隔的服务器ID列表来限制机器人可以触摸哪些服务器 - 干运行模式 --set
DISCORD_DRY_RUN=true在不进行任何更改的情况下预览会发生什么 - 需要确认 --删除和禁止操作需要
confirm: true执行
可选:保持您的机器人在线(网关模式)
默认情况下,服务器只使用Discord的REST API,没有持久连接。如果您希望机器人在线显示并启用状态功能,请将其添加到您的 .env:
DISCORD_GATEWAY_ENABLED=true
DISCORD_GATEWAY_INTENTS=Guilds
高级配置
所有可用的环境变量:
| 变量 | 默认值 | 描述 |
|---|---|---|
DISCORD_TOKEN |
必填 | 您的机器人令牌 |
DISCORD_APPLICATION_ID |
必填 | 您的应用程序ID |
DISCORD_BOT_ID |
可选 | 机器人用户ID |
DISCORD_GUILD_ALLOWLIST |
可选 | 逗号分隔的允许公会ID列表 |
DISCORD_DRY_RUN |
false |
阻止所有突变,返回预览 |
DISCORD_GATEWAY_ENABLED |
false |
启用实时网关连接 |
DISCORD_GATEWAY_INTENTS |
Guilds |
逗号分隔的意图名称或数字位字段 |
MCP_HTTP_HOST |
127.0.0.1 |
要绑定的主机 |
MCP_HTTP_PORT |
3456 |
要收听的端口 |
MCP_HTTP_PATH |
/mcp |
MCP端点的URL路径 |
MCP_SESSION_TTL_MS |
3600000 |
空闲会话的持续时间(毫秒) |
MCP_SESSION_CLEANUP_MS |
300000 |
清理过时会话的频率(毫秒) |
面向开发者
要在开发模式下运行并自动重新加载,请执行以下操作:
bun --watch run src/index.ts
类型检查和构建:
bun run check # type-check only
bun run build # compile to dist/
bun test src # run tests
健康检查:
curl http://127.0.0.1:3456/health
看 建筑.md 了解代码库的结构以及如何添加新工具。
Full tool list
公会: discord_list_guilds, discord_get_guild_settings, discord_update_guild_settings, discord_get_guild_preview, discord_get_guild_inventory, discord_get_guild_widget_settings, discord_update_guild_widget_settings, discord_get_guild_vanity_url, discord_get_guild_prune_count, discord_begin_guild_prune, discord_list_guild_integrations, discord_get_guild_welcome_screen, discord_update_guild_welcome_screen, discord_list_guild_templates, discord_create_guild_template, discord_sync_guild_template, discord_update_guild_template, discord_delete_guild_template, discord_list_guild_voice_regions, discord_list_voice_regions
频道: discord_create_channel, discord_update_channel, discord_delete_channel, discord_list_channel_permission_overwrites, discord_set_channel_permission_overwrite, discord_delete_channel_permission_overwrite, discord_modify_guild_channel_positions
角色: discord_create_role, discord_update_role, discord_delete_role, discord_get_role_member_counts, discord_modify_guild_role_positions
成员: discord_list_members, discord_search_members, discord_fetch_member, discord_edit_member, discord_set_member_timeout, discord_kick_member, discord_ban_member, discord_bulk_ban_members, discord_unban_member, discord_fetch_guild_ban, discord_list_guild_bans, discord_add_member_role, discord_remove_member_role, discord_set_current_member_voice_state, discord_set_member_voice_state
信息: discord_list_channel_messages, discord_list_pinned_messages, discord_fetch_message, discord_send_message, discord_edit_message, discord_crosspost_message, discord_pin_message, discord_unpin_message, discord_delete_message, discord_purge_messages, discord_add_reaction, discord_remove_own_reaction, discord_remove_user_reaction, discord_list_reaction_users, discord_clear_reactions, discord_clear_emoji_reactions, discord_end_poll, discord_list_poll_answer_voters
线程: discord_create_thread, discord_update_thread, discord_join_thread, discord_leave_thread, discord_lock_thread, discord_unlock_thread, discord_remove_thread_member, discord_delete_thread, discord_list_active_threads
Webhooks: discord_list_guild_webhooks, discord_list_channel_webhooks, discord_create_webhook, discord_update_webhook, discord_delete_webhook, discord_execute_webhook_by_token, discord_fetch_webhook_message_by_token, discord_edit_webhook_message_by_token, discord_delete_webhook_message_by_token
预定活动: discord_list_scheduled_events, discord_fetch_scheduled_event, discord_create_scheduled_event, discord_update_scheduled_event, discord_delete_scheduled_event, discord_list_scheduled_event_users
阶段: discord_create_stage_instance, discord_fetch_stage_instance, discord_update_stage_instance, discord_delete_stage_instance
邀请: discord_list_guild_invites, discord_create_channel_invite, discord_delete_invite, discord_get_invite_target_users, discord_get_invite_target_user_job_status, discord_update_invite_target_users
自动模式 : discord_list_automod_rules, discord_create_automod_rule, discord_update_automod_rule, discord_delete_automod_rule
表情符号和贴纸: discord_list_guild_emojis, discord_create_guild_emoji, discord_update_guild_emoji, discord_delete_guild_emoji, discord_list_guild_stickers, discord_create_guild_sticker, discord_update_guild_sticker, discord_delete_guild_sticker, discord_list_sticker_packs, discord_get_sticker_pack, discord_get_sticker, discord_list_application_emojis, discord_create_application_emoji, discord_update_application_emoji, discord_delete_application_emoji
音板: discord_list_guild_soundboard_sounds, discord_create_guild_soundboard_sound, discord_update_guild_soundboard_sound, discord_delete_guild_soundboard_sound
审核日志: discord_list_guild_audit_logs
存在(需要网关): discord_get_presence_state, discord_set_presence
网关: discord_get_gateway_info