Skip to main content
Glama
discord-mcp

discord-mcp

by etak64n

discord-mcp

Codex から Discord の指定チャンネルやスレッドを検索し、元発言のリンクをたどって前後を読める、読み取り専用のローカル MCP サーバーです。Python の公式 MCP SDK と stdio を使います。履歴の照合はローカルプロセスで行い、Codex に渡す発言数と本文の長さを制限します。

Discord Bot の準備

  1. Discord Developer Portal で Application を作り、Bot ページでトークンを発行します。同じページの Message Content Intent を有効にします。通常の会話の本文を取得するために必要です。

  2. Guild Install の OAuth2 スコープで bot を選び、自分が管理できるサーバーにインストールします。対象のテキストチャンネルで Bot の実効権限を View Channel と Read Message History に絞ります。ロールや @everyone から継承する権限も確認してください。プライベートスレッドは Bot をメンバーに追加します。

  3. Discord のユーザー設定で開発者モードを有効にし、対象チャンネルまたはスレッドの ID をコピーします。スレッドを読むにはそのスレッド自体の ID を登録します。フォーラム投稿には投稿のスレッド ID を使います。

この MCP はメッセージを取得するときだけ Discord REST API に接続します。ローカルに履歴を保存する機能はありません。検索結果や前後の本文は接続した Codex に渡ります。

Related MCP server: mcp-discord

Codex で使う

uv と Git を用意します。Codex を起動する環境に次の変数を設定してください。

環境変数

値

DISCORD_BOT_TOKEN

Bot ページで発行したトークン本体

DISCORD_CHANNEL_IDS

許可するチャンネル・スレッドの ID をカンマで区切ったもの

例えば zsh では次のように入力します。トークンの入力は画面に表示されず、シェル履歴にも入りません。

read -rs 'DISCORD_BOT_TOKEN?Discord Bot token: ' && echo
export DISCORD_BOT_TOKEN
read 'DISCORD_CHANNEL_IDS?Allowed channel/thread IDs: '
export DISCORD_CHANNEL_IDS

~/.codex/config.toml に以下を追加します。uvx が公開タグからパッケージを取得して起動します。初回は依存関係のダウンロードがあるため、起動の待ち時間を長めに設定しています。

[mcp_servers.discord]
command = "uvx"
args = ["--from", "git+https://github.com/etak64n/discord-mcp.git@v0.1.0", "discord-mcp"]
env_vars = ["DISCORD_BOT_TOKEN", "DISCORD_CHANNEL_IDS"]
startup_timeout_sec = 120

同じシェルで codex を起動し、/mcp で find_messages と read_context を確認します。Codex から uvx が見つからない場合は command -v uvx の出力を command に指定してください。Codex の MCP 設定

利用例(ID は架空):

チャンネル 222 の直近100件から「公開日」を探して。最新の該当発言の前後2件を読み、決まったことを元発言リンク付きで教えて。

ツール

ツール

入力

初期値と上限

find_messages

channel_id と query。任意で since(含む)、until(含まない)、続きの before_id を指定。日時はタイムゾーン付き ISO 8601

調査件数 scan_limit は100件(最大1,000)、結果 limit は5件(最大20)、抜粋 chars は240文字(最大1,000)

read_context

message_url に Discord の「メッセージリンクをコピー」で得た URL、または検索結果の url を指定

before と after は各2件(各0〜10)、本文 chars は400文字(最大1,000)

検索は指定先の表示可能な履歴を新しい順に調べ、大文字・小文字を区別せず本文の部分一致を探します。対象は本文のみです。長い本文でも該当箇所が抜粋に入ります。各結果に投稿者名、日時、本文の省略有無、元発言の URL が含まれます。

scanned は実際に照合した件数、newest_at と oldest_at はその範囲です。stop の読み方は次のとおりです。

stop

意味

result_limit / scan_limit

結果件数または調査件数の上限に到達。返された next_before_id を次回の before_id に指定すると、同じ検索条件で続きを確認できます。境界の直後に履歴が残っているかは次回判明する場合があります。

time_boundary

指定した期間・カーソルの境界に到達。

visible_history_end

Discord がこの範囲の履歴を返し終えました。履歴閲覧権限が不足していても空の結果になることがあります。

empty_text は調査したうち本文が空だった件数です。添付のみの発言などでも増えます。通常の発言まで空になる場合は Message Content Intent を確認してください。

前後取得は同じチャンネルまたはスレッドの発言を古い順に返します。anchor_index は元発言の位置(0始まり)、more_before と more_after は返した範囲の外側に発言を確認できたかを表します。

開発と検証

uv run --locked python -m unittest discover -s tests -v

テストは架空の履歴、模擬 HTTP 応答、実際の stdio クライアントを使用します。Discord の認証情報は不要です。実サーバーでの確認は、設定後に許可したチャンネルの既知の発言を検索し、返された URL と前後の本文を照合してください。

MIT License

Available Tools

2 tools
find_messagesA
Read-onlyIdempotent

Search literal text, case-insensitively, newest first in one channel/thread. since is inclusive and until exclusive (ISO 8601 with timezone). Continue with next_before_id as before_id and the same filters. chars bounds each excerpt.

Inputs: query (required), channel_id (required), chars, limit, +4 more.

read_contextB
Read-onlyIdempotent

Read a guild message and its immediate neighbors in chronological order. Supply the canonical Discord message URL. anchor_index is zero-based.

Inputs: message_url (required), after, chars, before.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 2 tools

    Disambiguation4/5

    find_messages is a text search over a channel/thread, while read_context reads a neighborhood around a specific message URL; the purposes are largely distinct. There is mild overlap since both read messages, but the descriptions make the boundary clear.

    Naming Consistency5/5

    Both tools follow a clean verb_noun pattern (find_messages, read_context) in snake_case with no deviation. Names are predictable and readable.

    Tool Count2/5

    Only two tools for a Discord server is very thin; the surface covers just two narrow read operations. It feels like a partial slice of a much larger intended toolset.

    Completeness2/5

    There is no way to send or edit messages, list channels/guilds/threads, or fetch reactions, and no pagination/list primitive beyond next_before_id. Agents will hit dead ends for any write or discovery workflow.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Read-only MCP server for finding Discord messages. It enables searching guild messages, locating messages from jump URLs, and reading context around results.
      7
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that enables searching Discord messages using Discord's native search API. Designed for use with Claude Code to find project decisions and communications in Discord.
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables local AI agents to securely search and read Discord messages and channels visible to the current client, without requiring a bot or user token.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP clients to read a Discord server’s text history through per-member Discord OAuth approval, with read-only channel, thread, message retrieval, and bounded search tools that enforce current member and bot permissions on every read.
      MIT