codex-discord-mcp
Provides tools for interacting with Discord, enabling AI agents to send messages, read message history, add reactions, edit messages, download attachments, and manage a local queue of Discord messages for processing.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@codex-discord-mcpfetch the last 10 messages from #general"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
codex-discord-mcp
A local-first Discord bridge for Codex CLI.
Use it in three ways:
Discord -> Codex: mention or DM your bot, run
codex exec --json, and post the final answer back to Discord.Codex -> Discord: expose Discord tools to Codex through MCP, including
reply,fetch_messages,react,edit_message, anddownload_attachment.Hybrid workflow: receive Discord messages into a local queue, then let Codex inspect and respond through MCP tools.
This is not an official OpenAI plugin. It is a local bridge designed around Codex CLI, MCP, and Discord bot APIs.
Which Mode Should I Use?
Goal | Use |
DM Codex from Discord |
|
Let Codex send Discord replies |
|
Let Codex read recent Discord messages |
|
Queue Discord messages for Codex to inspect |
|
Fully automatic Discord -> Codex -> Discord |
|
Related MCP server: Discord Bridge MCP Server
Security Model
This bridge treats Discord as untrusted input.
Discord users cannot:
approve pairings
allow users
allow channels
change bridge policy
read bridge state files
bypass Codex sandbox or approval settings
Only local terminal commands can change access policy. MCP tools can read and reply through allowlisted Discord channels, but they cannot modify the allowlist or approve pairings.
Default safety posture:
Default sandbox:
read-onlyDefault approval policy:
never, becausebotmode is non-interactiveRecommended first run:
read-onlyUse
workspace-writeonly in an isolated repository or disposable worktreeNever use
danger-full-accessfor a public Discord channel
When bot mode starts with CODEX_SANDBOX=workspace-write or CODEX_SANDBOX=danger-full-access and CODEX_APPROVAL_POLICY=never, the bridge prints a runtime warning. Set CODEX_DISCORD_ASSUME_YES=true to suppress the warning in controlled automation.
Requirements
Node.js 20 or newer.
Codex CLI installed and authenticated for
botmode.A Discord application with a bot token.
Discord bot privileged Message Content Intent enabled.
Install
Global install:
npm install -g codex-discord-mcp
codex-discord-mcp doctor
codex-discord-mcp initRun through npx without a global install:
npx -y codex-discord-mcp doctorLocal development install:
npm install
npm run build
node ./dist/cli.js --helpDiscord Bot Setup
Create a Discord application in the Discord Developer Portal.
Add a bot and copy its token.
Enable Message Content Intent for the bot.
Invite the bot to a server if you want guild channels.
Useful bot permissions:
View Channels
Send Messages
Send Messages in Threads
Read Message History
Attach Files
Add Reactions
Print an invite URL:
codex-discord-mcp invite-url <client-id>Store the token locally:
codex-discord-mcp configureThe token is written to ~/.codex/discord/.env by default. Override the state directory with CODEX_DISCORD_STATE_DIR.
You can also read the token from an existing environment variable:
codex-discord-mcp configure --token-env DISCORD_BOT_TOKENQuick Start
Interactive setup:
codex-discord-mcp initCheck local configuration:
codex-discord-mcp doctor
codex-discord-mcp doctor --jsonMode 1: Discord To Codex Relay
Run:
codex-discord-mcp botDefault behavior:
Unknown DM users receive a one-hour pairing code.
Pair locally with
codex-discord-mcp access pair <code>.After pairing, each DM message triggers
codex exec --json.The final Codex message is posted as a Discord reply.
Useful environment variables:
export CODEX_WORKDIR="/path/to/repo"
export CODEX_SANDBOX="read-only"
export CODEX_APPROVAL_POLICY="never"
export CODEX_RESUME_BY_CHANNEL="true"
codex-discord-mcp botFor unattended relay mode, keep CODEX_APPROVAL_POLICY=never and use the least permissive sandbox that fits the channel.
Mode 2: Codex MCP Tools
Print a local config snippet:
codex-discord-mcp print-configPrint an npx based config snippet:
codex-discord-mcp print-config --npxAdd the snippet to ~/.codex/config.toml or a trusted project .codex/config.toml. A typical npx config looks like:
[mcp_servers.discord]
command = "npx"
args = ["-y", "codex-discord-mcp", "mcp"]
startup_timeout_sec = 20
tool_timeout_sec = 60Then start Codex and run /mcp to confirm the Discord tools are loaded.
Available MCP tools:
Tool | Risk | Notes |
| Low | Reads recent allowlisted channel history |
| Low | Reads local queue entries |
| Low | Reads local bridge status |
| Low | Adds a reaction |
| Medium | Sends a Discord message |
| Medium | Sends a Discord message |
| Medium | Edits a message previously sent by the bot |
| Medium | Downloads Discord attachments into the local inbox |
| Medium | Mutates local queue state |
Access Control
Access is managed by local CLI commands, not MCP tools.
codex-discord-mcp access show
codex-discord-mcp access policy allowlist
codex-discord-mcp access allow-user 123456789012345678
codex-discord-mcp access allow-channel 234567890123456789
codex-discord-mcp access allow-channel 234567890123456789 --no-mentionDM policy values:
pairing: unknown DM users get a one-hour pairing code. This is the default.allowlist: unknown DM users are silently ignored.disabled: all DMs are ignored.
Guild channels are opt-in by channel ID. By default, the bot only responds in an allowed guild channel when it is mentioned or when the user replies to a recent bot message. Use --no-mention only for dedicated bot channels.
Attachment Safety
The bridge refuses to attach its own state files, except files downloaded into the inbox. It also blocks attachment paths outside the configured attachment roots.
Attachment uploads are restricted by default to:
the bridge process working directory
CODEX_WORKDIRthe bridge inbox
To allow generated files from other roots, set CODEX_DISCORD_ATTACHMENT_ROOTS using your platform path delimiter:
export CODEX_DISCORD_ATTACHMENT_ROOTS="/path/to/repo:/path/to/exports"On Windows PowerShell:
$env:CODEX_DISCORD_ATTACHMENT_ROOTS="C:\path\to\repo;C:\path\to\exports"Configuration Reference
Variable | Default | Meaning |
| required | Discord bot token |
|
| Bridge state directory |
|
| Codex executable |
| process cwd | Working directory for Codex |
|
| Codex sandbox mode |
|
| Codex approval policy for non-interactive bot mode |
| unset | Override Codex model |
| unset | Use a Codex profile |
|
| Resume one Codex thread per Discord channel |
|
| Codex process timeout in milliseconds |
| unset | Extra arguments passed to Codex |
|
| Pass |
| cwd, workdir, inbox | Allowed outbound file roots |
|
| Suppress writable unattended bot warning |
Troubleshooting
codex-discord-mcp doctor
codex-discord-mcp access showIf the bot receives empty message content, enable Message Content Intent in the Discord Developer Portal.
If bot mode cannot launch Codex, set CODEX_COMMAND to the full executable path or run the bridge from the same shell where codex exec "hello" works.
If MCP tools do not appear, run:
codex-discord-mcp print-config --npxThen add the printed snippet to Codex config and restart Codex.
Development
npm install
npm run typecheck
npm test
npm run buildDevelopment commands:
npm run dev:mcp
npm run dev:botRelease
The package is prepared for npm publishing with:
binentry:codex-discord-mcpfileswhitelist for published package contentsprepublishOnlyvalidation: typecheck, tests, buildLinux and Windows GitHub Actions CI
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Openclaw-Metis/codex-discord-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server