discord-mcp
MCP server for interacting with Discord via REST API, enabling guild, channel, and message operations using a bot token.
README
discord-mcp
MCP server that wraps a subset of the Discord REST API v10 using a bot token.
Security
- Never commit the bot token. Pass
DISCORD_BOT_TOKENonly via your MCP clientenvblock (seeexamples/). - If a token was pasted into chat or committed anywhere, reset it in the Discord Developer Portal and use the new token locally.
Tools
| Tool | Description |
|---|---|
verify |
GET /users/@me |
list_guilds |
GET /users/@me/guilds |
get_guild |
GET /guilds/{id} |
list_guild_channels |
GET /guilds/{id}/channels |
get_channel |
GET /channels/{id} |
list_channel_messages |
GET /channels/{id}/messages |
create_channel_message |
POST /channels/{id}/messages |
Gateway intents (Presence, Server Members, Message Content) apply to the Gateway websocket. This MCP uses HTTP only; channel permissions still apply (e.g. Read Message History, Send Messages).
Reply bot (auto-replies on Discord)
The MCP alone cannot listen for messages. For DMs and @mentions (and replies to the bot when Discord fills the reference), run the optional Gateway bot:
- In the Developer Portal → your app → Bot, enable Message Content Intent (Privileged Gateway Intents).
- Install extras and start the process (keep this terminal open, or run under
tmux/ a process manager):
cd projects/discord-mcp
source .venv/bin/activate
pip install -e ".[reply-bot]"
export DISCORD_BOT_TOKEN='…' # same token as MCP
python -m discord_mcp.reply_bot
# or: discord-reply-bot
uvx のデフォルトでは reply-bot 用の discord.py は入りません。リポジトリを clone しない場合は例えば次でも可です。
pip install "discord-mcp[reply-bot] @ git+https://github.com/taka392/discord-mcp.git"
DISCORD_BOT_TOKEN='…' discord-reply-bot
Behavior:
CURSOR_AGENT_GATEWAY_URLが未設定: DM → 短文の確認エコー。サーバー → @メンション/ボットへの返信で「返信テスト」エコーのみ。CURSOR_AGENT_GATEWAY_URLを設定(cursor-cli-homelabのagent-gateway、POST /v1/promptと同じ): 上記と同じトリガで、プロンプトをゲートウェイ経由でagent -pに渡し、標準出力を Discord に返信します(長文は自動で分割)。.env:CURSOR_AGENT_GATEWAY_URL,GATEWAY_TOKEN(ゲートウェイでトークン必須のとき)、CURSOR_GATEWAY_TRUST_WORKSPACE,CURSOR_GATEWAY_TIMEOUT_SEC, 任意でCURSOR_GATEWAY_PROMPT_PREFIX。- ゲートウェイ側に
CURSOR_API_KEYが必要です。CLI の MCP を確認なしで通したいときはゲートウェイの環境にAGENT_APPROVE_MCPS=true(--approve-mcps)を設定。Agent 既定(-p、IDE の Ask モードではない)で動きますが、「Auto」と完全同一ではなくツール許可/サンドボックス次第です。
- DM と サーバー(@またはボットへの返信) の両方でゲートウェイ連携あり。
Docker(Proxmox 上の VM / LXC など)
docker compose は discord-reply-bot と agent-gateway の 2 サービスです(agent_gateway/ は cursor-cli-homelab のゲートウェイと手動で同期)。
CURSOR_AGENT_GATEWAY_URLは既定サンプルのとおりhttp://agent-gateway:9888。同一 Compose のブリッジ内で名前解決するため、192.168.11.xxの 別ホストに向ける必要はありません(向けていてそこでゲートウェイが止まっていると「接続できません」になります)。- ホストに
9888を公開するので、Mac の MCP でCURSOR_HOMELAB_URL=http://<この VM の LAN IP>:9888とすれば、cursor-homelab-mcpもこのゲートウェイを共有可能です。 .envは両コンテナに読み込まれるので、DISCORD_BOT_TOKEN・CURSOR_API_KEY・GATEWAY_TOKENは Git に載せないこと。
ゲスト側の手順例:
git clone https://github.com/taka392/discord-mcp.git
cd discord-mcp
./scripts/homelab_docker_up.sh
# 初回は .env が無いので .env.example がコピーされる → DISCORD_BOT_TOKEN / CURSOR_API_KEY / GATEWAY_TOKEN 等を編集して再度
手動でも同じです。
cp .env.example .env
# edit .env (必須: DISCORD_BOT_TOKEN, CURSOR_API_KEY …)
docker compose up -d --build
docker compose logs -f
停止・更新:
docker compose down
docker compose up -d --build
restart: unless-stopped なのでゲスト再起動後もコンテナが戻る(Docker が起動時に有効な前提)。
Proxmox QEMU VM(ゲストエージェント経由)
Mac などから Proxmox API + QEMU Guest Agent で VM 内に clone・.env 同期・docker compose up -d --build まで一括できます(VM に Docker / git / agent が入っていること)。
- Cursor の
~/.cursor/mcp.jsonにmcpServers.discord.env.DISCORD_BOT_TOKENを用意する(または環境変数DISCORD_BOT_TOKEN)。 proxmox-mcpと同じPROXMOX_*をシェルにエクスポートする。- リポジトリで実行:
cd projects/discord-mcp
python3 scripts/deploy_guest_exec.py --vmid 100
ゲストが root のみ(ubuntu ユーザーなし)の場合は既定で /root/discord-mcp に置きます。cloud-init で ubuntu がある場合は
--unix-user ubuntu --repo-dir /home/ubuntu/discord-mcp を付けてください。初回 Docker ビルドが長いときは --timeout 900 など。
Mac などから homelab へ SSH でデプロイ
scripts/deploy_remote.sh は次まで一気に実行します: リモートで git pull → ローカルの Cursor mcp.json からトークンを読む → scp でリモートの .env を上書き → homelab_docker_up.sh(Docker)。
- デフォルトで
~/.cursor/mcp.jsonのmcpServers.discord.env.DISCORD_BOT_TOKENを使う。 - 別ファイルなら
export MCP_JSON_PATH='/path/to/mcp.json'。 mcp.jsonを使わず一時的に上書きしたいだけならexport DISCORD_BOT_TOKEN='…'(その場合は mcp.json は読まない)。
cd /path/to/discord-mcp # clone 済みのどこでも可
export HOMELAB_SSH='you@192.168.x.x' # 必須
# optional: export HOMELAB_REPO_DIR='/srv/discord-mcp'
# optional: export HOMELAB_SSH_OPTS='-i ~/.ssh/id_ed25519'
# optional: export MCP_JSON_PATH="$HOME/.cursor/mcp.json"
./scripts/deploy_remote.sh
注意: デプロイのたびにリモートの .env はローカル設定と同期される(トークンを homelab だけで管理したい場合はサーバー上で homelab_docker_up.sh だけ使う)。
Discord から 「ゲートウェイが利用できません (503)」 と出るときは、コンテナ内で CURSOR_API_KEY が空なことが多いです(Headless CLI の API キーを homelab の .env に入れる)。
Mac から Proxmox で VM100 に流し込む例::
export CURSOR_API_KEY='crsr_...' # Cursor ダッシュボードで発行
export PROXMOX_BASE_URL=... PROXMOX_TOKEN_ID=... PROXMOX_TOKEN_SECRET=... PROXMOX_VERIFY_TLS=false
python3 scripts/push_gateway_env_guest_exec.py --vmid 100
Local check
cd projects/discord-mcp
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
DISCORD_BOT_TOKEN='your token' python -m discord_mcp.check
Cursor registration
After publishing to GitHub, merge the snippet from examples/cursor_mcp_config.example.json into ~/.cursor/mcp.json and reload Cursor.
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.