discord-mcp

discord-mcp

Enables LLMs to read and send Discord messages, list servers and channels, and monitor unread messages via a selfbot that uses a user token (violates Discord ToS).

Category
访问服务器

README

discord-mcp

Discord selfbot MCP server — read & send Discord messages from Claude Code or OpenClaw.

⚠️ Selfbot Warning: This uses your Discord user token, which violates Discord's ToS. Your account may be banned. Use at your own risk.

What it does

Exposes 6 Discord tools via MCP (Model Context Protocol):

Tool Description
discord_list_guilds List all servers you're in
discord_list_channels List text channels in a server
discord_get_messages Fetch recent messages from a channel
discord_get_dms List your open DM conversations
discord_send_message Send a message (channel or DM)
discord_get_unread Get messages you haven't seen yet

A background daemon maintains a persistent WebSocket to the Discord Gateway, ingesting messages into a local SQLite database so discord_get_unread works even while Claude isn't running.

Setup

1. Install & configure

npx @tensakulabs/discord-mcp setup

This will:

  1. Show you how to extract your Discord token from the desktop app
  2. Save it securely to your OS keychain (macOS: uses built-in security CLI — no native module required)
  3. Start the background daemon via launchd (macOS) or systemd (Linux)
  4. Auto-register the MCP server in Claude's config

2. Token extraction (step shown during setup)

Open Discord desktop app → Press Ctrl+Shift+I (or Cmd+Option+I on Mac) → Network tab → Send any message in Discord → filter requests by messages → click any request → Headers tab → find the Authorization header → copy its value.

3. Restart Claude

Restart Claude Code. You'll see Discord tools available.

Verify it's working

npx @tensakulabs/discord-mcp status
# ✅ Connected as: yourname#0

Manual MCP config (if auto-config fails)

Add to ~/.claude/settings.json:

{
  "mcpServers": {
    "discord": {
      "command": "npx",
      "args": ["-y", "@tensakulabs/discord-mcp"]
    }
  }
}

Usage with Claude

Once registered, Claude can use Discord tools directly:

"What did I miss in the #general channel of the Tensaku server?"
→ Claude calls discord_list_guilds, discord_list_channels, discord_get_unread

"Reply to Alex saying I'll be there at 5pm"
→ Claude calls discord_send_message with replyToMessageId

Hooks

Fire shell commands or HTTP webhooks when Discord events occur. Configure in ~/.config/discord-mcp/config.json:

{
  "hooks": {
    "on_mention": [
      {
        "type": "command",
        "enabled": true,
        "command": "osascript -e 'display notification \"{content}\" with title \"Mention from {author}\"'"
      }
    ],
    "on_everyone": [],
    "on_here": [],
    "on_message": []
  }
}

Hook types

Hook Fires when
on_mention Someone directly @username mentions you
on_everyone Someone uses @everyone in a server you're in
on_here Someone uses @here in a server you're in
on_message Any non-bot message (use sparingly — fires a lot)

Hook config fields

Field Values Description
type "command" | "http" Shell command or HTTP POST
enabled true | false Toggle without removing
command string Shell command (type: command)
url string Endpoint to POST to (type: http)

Template variables

Available in command strings and HTTP POST body:

Variable Value
{author} Username of message sender
{content} Message text
{channel} Channel ID
{guild} Guild/server ID (or "dm" for DMs)
{is_dm} true or false

HTTP hook payload

{
  "author": "username",
  "content": "message text",
  "channel": "channel-id",
  "guild": "guild-id",
  "is_dm": false
}

OpenClaw integration

Add to OpenClaw's MCP config:

{
  "mcp": {
    "servers": [{
      "name": "discord",
      "transport": "stdio",
      "command": "npx",
      "args": ["-y", "@tensakulabs/discord-mcp"]
    }]
  }
}

Security

  • Token stored in OS keychain (macOS: security CLI — no native module compilation needed; Linux: keytar; fallback: AES-256-CBC encrypted file)
  • Token never written to config files or logs
  • Local files at ~/.config/discord-mcp/: messages.db, config.json, token.enc (fallback only), daemon.log

Architecture

discord-mcp/
├── src/
│   ├── index.ts          MCP server entry — registers 6 tools
│   ├── cli.ts            setup + status commands
│   ├── daemon.ts         Discord Gateway WebSocket → SQLite ingestion + hooks
│   ├── auth.ts           keychain token storage (macOS security CLI / keytar / encrypted file)
│   ├── hooks.ts          hook runner — shell commands and HTTP webhooks
│   ├── config.ts         config loader (~/.config/discord-mcp/config.json)
│   ├── db.ts             SQLite schema + queries
│   ├── ratelimit.ts      429 backoff + Discord headers
│   ├── state.ts          per-channel last-seen state
│   ├── purge.ts          scheduled message retention cleanup
│   └── tools/
│       ├── list_guilds.ts
│       ├── list_channels.ts
│       ├── get_messages.ts
│       ├── get_dms.ts
│       ├── send_message.ts
│       └── get_unread.ts

All Discord API calls go through rateLimitedFetch — automatic backoff on 429.

The daemon runs as a launchd service (com.discord-mcp.daemon) on macOS, connecting to wss://gateway.discord.gg and storing all messages locally for fast unread queries.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选