Skip to main content
Glama

Discord MCP

FastMCP Version Ruff Linted with Biome Built with Just

仓库: github.com/sandraschi/discord-mcp

FastMCP 3.1 Discord MCP 服务器,具备采样(服务器端 Ollama / OpenAI 兼容或客户端 LLM)、代理工作流 (discord_agentic_workflow)、技能 (SkillsDirectoryProvider + skill:///SKILL.md)、提示词以及2026 舰队风格仪表板(React + Vite + Tailwind,深色玻璃质感界面)。

端口

  • 后端: 10756 REST (/api/v1/) + MCP 流式 HTTP,位于 /mcp

  • 前端: 10757

Related MCP server: Discord Notifications MCP Server

设置

  1. Discord 开发者门户 创建一个机器人。复制机器人令牌。

  2. 将机器人邀请到您的服务器(使用 OAuth2 URL 生成器,范围:bot)。

  3. .env.example 复制到 仓库根目录下的 .env (discord-mcp/.env) 并设置 DISCORD_TOKEN=...(无需引号)。后端在启动时加载此文件 (python-dotenv)。更改 .env 后请重启服务器。如果令牌已在系统环境变量或 Cursor MCP env 中设置,则该值优先(.env 不会覆盖现有变量)。

  4. 对于本地代理采样(当 MCP 主机不提供采样时):运行 Ollama,并可选择设置 DISCORD_SAMPLING_BASE_URL / DISCORD_SAMPLING_MODEL。如果您希望由主机 LLM 进行采样,仅将服务器处理程序作为后备,请设置 DISCORD_SAMPLING_USE_CLIENT_LLM=1

运行

  • Web 应用(后端 + 仪表板):从仓库根目录运行 .\start.ps1start.bat,或者从 webapp/ 目录运行:.\start.ps1

  • 仅后端uv run python -m discord_mcp.server --mode dual --port 10756

  • Stdio(仅 MCP)uv run python -m discord_mcp.server --mode stdio

Cursor MCP

  • 将此仓库作为工作区根目录.cursor/mcp.json 注册了 discord-mcp (stdio)。请在该文件的 env 中设置 DISCORD_TOKEN,或依赖您的 shell 环境变量。编辑后请重新加载 MCP / 重启 Cursor。

  • 全局 / 多根合并:将 discord-mcp 代码块从 cursor-config-template.json 复制到您的用户 MCP JSON 中(Windows: %USERPROFILE%\.cursor\mcp.json)。如果您没有使用默认的 D:/Dev/repos/discord-mcp,请调整 cwd 为您的克隆路径。

MCP HTTP (远程 / Inspector)

  • 端点:http://localhost:10756/mcp (流式 HTTP, FastMCP 3.1.0)

  • 发现 / 清单:GET /api/v1/meta

  • 健康检查:GET /api/v1/health (包含采样状态)

工具

  • discord(operation=) 组合工具:list_guilds, list_channels, send_message, get_messages, get_guild_stats, create_channel, create_guild, create_invite, list_invites, revoke_invite, list_members, get_member, list_active_threads, rag_ingest, rag_querycreate_guild 需要用户 OAuth2 (机器人权限为 403)。list_members / get_member 需要 GUILD_MEMBERS 意图。

  • discord_help(category=, topic=) 多级帮助。

  • discord_agentic_workflow(goal, ctx) 通过 ctx.sample + 工具实现的高级目标 (SEP-1577)。返回一个结构化的 字典 (success, message, recommendations 或错误字段)。

提示词 (已注册)

discord_quick_start, discord_diagnostics, discord_moderation_playbook, discord_rag_workflow, discord_invite_operations

技能

打包在 src/discord_mcp/skills/<name>/SKILL.md 下,作为 MCP 资源 (skill://) 公开。在仪表板的“技能”页面以及通过 GET /api/v1/skills 列出。

资源

  • resource://discord-mcp/capabilities 客户端的功能简要摘要。

API (REST)

  • GET /api/v1/health 健康状态、token_set、速率限制、采样、mcp_http_path

  • GET /api/v1/meta 工具、提示词、资源、技能根目录、采样

  • GET /api/v1/skills 打包的技能预览(仪表板)

  • GET /api/v1/guilds 列出服务器(代理至工具)

  • GET /api/v1/guilds/{guild_id}/channels 列出频道

  • (完整列表请参阅 /docs 下的 OpenAPI 文档。)

Discord HTTP 429 (API 速率限制)

Discord 对 REST API 强制执行按路由限制。在遇到 HTTP 429 时,服务器现在会等待 retry_after(来自响应体或 Retry-After 标头),并重试同一请求最多 5 次,之后才会返回错误。如果在此之后仍然看到 429,请降低频率(例如减少并行消息获取、减小 RAG 摄入批次)或等待一分钟,特别是当 Discord 的响应中出现 "global": true 时(这种情况很少见,表示更广泛的限制)。

安全与速率限制 (反垃圾信息)

写入操作受到速率限制,以防止机器人被用作垃圾邮件发送工具:

  • 消息:全局每分钟最多 10 条,每个频道每分钟最多 3 条,发送间隔至少 5 秒(可配置)。

  • 频道:每分钟最多创建 5 个。

  • 邀请:每分钟最多创建 5 个 (DISCORD_RATE_LIMIT_INVITES_PER_MINUTE)。

  • 消息长度:上限为 2000(Discord 最大值);可通过 DISCORD_MAX_MESSAGE_LENGTH 覆盖。

环境变量:DISCORD_RATE_LIMIT_MESSAGES_PER_MINUTE, DISCORD_RATE_LIMIT_MESSAGES_PER_CHANNEL_PER_MINUTE, DISCORD_RATE_LIMIT_CHANNELS_PER_MINUTE, DISCORD_MAX_MESSAGE_LENGTH, DISCORD_MIN_MESSAGE_INTERVAL_SECONDS。当达到限制时,工具将返回 success: false, rate_limited: true 以及解释性的 error。当前配置可在 GET /api/v1/health 下的 rate_limit 中查看。

文档

标准

  • FastMCP 3.1.0:指令、采样处理程序、技能提供程序、严格验证、流式 HTTP 挂载。

  • Web 应用:start.ps1,端口 10756/10757,深色玻璃布局,顶部状态栏,活动日志,工具/技能/应用页面。

🛡️ 工业级技术栈

本项目遵循 SOTA 14.1 高保真代理编排的工业标准:

  • Python (核心):使用 Ruff 进行代码检查和格式化。核心处理程序中对 print 语句零容忍 (T201)。

  • Web 应用 (UI):使用 Biome 进行亚毫秒级代码检查。严格执行 noConsoleLog

  • 协议合规性:强化了 stdout/stderr 隔离,以确保抗崩溃的 JSON-RPC 通信。

  • 自动化:所有舰队操作均使用 Justfile 配方 (just lint, just fix, just dev)。

  • 安全性:通过 banditsafety 进行自动化审计。

Maintenance

ActivityActive
ResponsivenessUnresponsive

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to interact with Discord by sending notifications, creating channels, and managing interactive questions with support for two-way responses. It allows for streamlined communication through channel keys and supports various question types like multiple-choice and extended-answer modals.
    -
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI clients to manage Discord servers through natural language, offering tools for guilds, channels, messages, roles, members, webhooks, invites, and automations. Includes a conversational agent that responds to @mentions in Discord.
    8
    Apache 2.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to interact with Discord through the REST API and real-time events, supporting message management, user info, channel operations, and more with security controls.
    6
    1
    MIT