discord-mcp
This server provides a set of MCP tools for interacting with the Discord REST API, enabling a Claude agent to perform read-only and write operations on guilds, channels, roles, and members.
Read-only tools (always available):
list_channels– List all channels (text, voice, category, etc.) in a guild.list_roles– List all roles in a guild.list_categories– List only category channels (filtered client-side).get_channel_permission_overwrites– Retrieve permission overwrites for a channel.get_member_roles– Get the roles assigned to a guild member.
Write tools (gated behind
DISCORD_MCP_ENABLE_WRITE=1):create_channel– Create a text, voice, or category channel.edit_channel– Rename, change topic, re-parent, or reorder a channel.create_role– Create a new role (with optional color, hoist, permissions).edit_role– Edit an existing role's name, color, hoist, or permissions.edit_guild– Update guild name, icon, banner, or description.delete_channel– Permanently delete a channel (destructive).create_message– Post a plain-text message (max 2000 characters) with local content validation.
Error handling: All tools return structured responses with typed errors (auth, permission, rate limit, validation, etc.) instead of raw exceptions.
Security: Write tools refuse locally if not enabled; input IDs validated to prevent injection; message content validated before network call.
Provides tools for interacting with the Discord REST API, enabling AI agents to manage channels, roles, guilds, and messages in a Discord guild.
discord-mcp
An MCP server over the real Discord REST API
-- so a Claude agent calls list_channels(guild_id="...") instead of
hand-rolling an authenticated httpx request. Built to the
github-mcp/bus-mcp
standard in this portfolio (own pyproject, fastmcp server, typed errors, real
test suite, honest README) -- fifth flagship, first over Discord.
5 read-only tools, always on + 7 write tools, gated OFF by default
behind DISCORD_MCP_ENABLE_WRITE=1 -- see "Write tools" below.
Quickstart (60 seconds)
python -m venv .venv
.venv/Scripts/python.exe -m pip install -e ".[test]"Add to your Claude Desktop/Code MCP config:
{
"mcpServers": {
"discord-mcp": {
"command": "python",
"args": ["C:/path/to/discord-mcp/run_server.py"],
"env": { "DISCORD_BOT_TOKEN": "your-bot-token-here" }
}
}
}Without DISCORD_BOT_TOKEN set, every tool call still returns a clean
structured error (Discord's own 401) instead of crashing -- see "Typed
errors" below. Write tools also need DISCORD_MCP_ENABLE_WRITE=1 in the same
env block, or they refuse locally with policy_refusal -- see "Write
tools" below.
Related MCP server: fluency-discord-mcp
What this is / is not
This is a reference portfolio implementation demonstrating an MCP server
over a real external SaaS API (Discord) -- it is NOT an official Discord
MCP server, and it is not affiliated with Discord Inc. It started from an
earlier, separate sibling project's HttpDiscordClient, a stdlib-urllib
Discord transport built and verified against a real live guild for that
project's own server-provisioning tooling. This repo hand-adapts that
client's request-building, header construction (including its deliberately
descriptive User-Agent -- see below), and error handling onto httpx
(matching this fleet's other MCP servers) as its own standalone client with
no dependency on that sibling project. discord-mcp does not import from or
depend on that other package at all.
Started as 5 read-only tools with no write capability at all; now ships a
7-tool write group, off by default, mirroring the *_MCP_ENABLE_WRITE-style
gate already shipped in github-mcp/bus-mcp/desktop-mcp in this same
portfolio -- see "Write tools" below.
Tools
Read (always on, no gate)
Tool | Discord endpoint | Purpose |
|
| All channels (every type) in a guild |
|
| All roles in a guild |
|
| Category channels only (Discord type 4) -- Discord has no dedicated categories-only endpoint, so this filters the same channels payload client-side |
|
| Role/member allow+deny bitfields set on one channel |
|
| Role ids currently assigned to one guild member |
Write (gated behind DISCORD_MCP_ENABLE_WRITE=1, default OFF)
Tool | Discord endpoint | Purpose |
|
| Create a text/voice/category channel |
|
| Rename/re-topic/re-parent/reorder an existing channel |
|
| Create a role |
|
| Edit an existing role |
|
| Update guild-level identity (name/icon/banner/description) |
|
| Destructive. Delete a channel |
|
| Post a message to a text channel ( |
Write tools
Seven write tools were added on top of the original 5 read-only tools,
mirroring the exact write-gate pattern already shipped in this portfolio
(github-mcp's GITHUB_MCP_ENABLE_WRITE, desktop-mcp's
DESKTOP_MCP_ENABLE_*, and most closely bus-mcp's BUS_MCP_ENABLE_WRITE +
gated_write decorator, copied as the reference template). create_message
was added a night later than the other 6, once it became clear that none of
create_channel/edit_channel/create_role/edit_role/edit_guild/delete_channel
can actually post content to a channel -- it reuses the exact same gate and
the post() helper create_channel/create_role already added to
client.py, no new HTTP plumbing.
Off by default. Set
DISCORD_MCP_ENABLE_WRITE=1(ortrue/yes/on) in the server's environment to enable the write group. Unset (or any other value) means every write tool call refuses locally, with zero Discord API calls attempted, returning a structuredpolicy_refusalerror:{"ok": false, "error": {"type": "policy_refusal", "message": "Tool group 'write' is disabled. Set DISCORD_MCP_ENABLE_WRITE=1 in the server's environment to enable it.", "group": "write", "tool": "create_channel", "required_env": "DISCORD_MCP_ENABLE_WRITE"}}Enforced at the route layer, not just the MCP-tool layer. The
@config.gated_writedecorator wraps each write function directly indiscord_mcp/routes.py(not merely the@mcp.toolwrapper inserver.py), so the gate is unit-testable without spinning up fastmcp or a real transport, and can't be bypassed by any alternate calling path intoroutes.py.Read fresh from the environment on every call, never cached at import time -- an operator can arm/disarm the write group without restarting the server process, and tests can monkeypatch it per-test.
delete_channelgets no separate or lower bar. Despite being genuinely destructive/irreversible against a real guild, it is gated behind the exact sameDISCORD_MCP_ENABLE_WRITEenv var as the other write tools -- confirmed by dedicated tests intest_routes.py(setting plausible-but-wrong var names likeDISCORD_MCP_ENABLE_DELETEdoes not arm it).Same auth path as the read tools. Write calls reuse the exact same
_headers()/pooledhttpx.AsyncClientconstruction inclient.pyas every read tool -- there is only one auth code path in this repo.create_messagevalidates content locally, not just via Discord's own 400.contentmust be a non-empty string of at most 2000 characters (Discord's real message-length limit) -- checked byclient.validate_message_contentbefore any request is built, same "never even attempt the call" discipline as the snowflake-id checks. A violation returnsvalidation_error, not a raw Discord 400.
icon_base64/banner_base64 on edit_guild -- a flagged assumption
Discord's docs describe PATCH /guilds/{id}'s icon/banner fields as an
"image data" string -- a full data URI (data:image/png;base64,<base64>),
not a bare base64 payload. edit_guild accepts either:
a full
data:...;base64,...URI, passed through unchanged, orraw base64 bytes, which are assumed to be PNG and wrapped as
data:image/png;base64,<value>.
This PNG assumption is not verified against a real Discord response --
this repo has not confirmed whether Discord accepts, rejects, or silently
mis-renders a non-PNG image (JPEG, animated GIF for boosted-server icons,
etc.) sent under an image/png label. If you have a non-PNG image, pass a
full data:image/...;base64,... URI yourself rather than relying on the
default. Flagged here rather than guessed silently.
Typed errors, never a raw crash
Every tool returns {"ok": true, ...} on success or {"ok": false, "error": {...}} on failure -- never an unhandled exception or stack trace.
network_error-- connection refused, timeout, DNS failure, or a malformed request URL. Discord's API wasn't reachable at all.auth_error(401) -- missing or invalid bot token.permission_error(403, with Discord's own JSON error body, e.g.{"message": "Missing Access", "code": 50001}) -- the bot lacks the permission/scope for this call, or isn't in the guild.cloudflare_blocked(403, with no JSON error body) -- Discord's API docs ask for a descriptiveUser-Agent; without one, a client's default UA is a well-known bot fingerprint that Discord's Cloudflare edge can reject with a bare 403 before the request ever reaches route-level permission checks. This is otherwise indistinguishable from a realpermission_error403 -- Discord's real permission-denied responses always carry a JSON body, so absence of a JSON body on a 403 is the signal this type is built on. This is a best-effort heuristic, not a certainty: a proxy, load balancer, or future Discord change that strips the body on a different kind of 403 would also land here. discord-mcp sends the same descriptiveUser-Agentthis heuristic exists to explain (seeclient.py's_headers()), so in practice this type should rarely fire from this server's own calls -- see "Honest limitations" below.not_found(404) -- bad/unknown guild, channel, role, or member id.rate_limited(429) -- Discord's rate limit. Carriesretry_after_s, parsed straight from Discord's own JSON body (retry_after, in seconds). This server does not auto-retry -- it surfaces the limit as a structured error immediately and leaves any backoff/retry decision to the caller.decode_error-- a 2xx response whose body isn't valid JSON (should not happen against the real API; guards against a malformed proxy/mock).discord_api_error-- any other 4xx/5xx not covered above.policy_refusal(write tools only) -- the write group is disabled; see "Write tools" above. No Discord API call is attempted.invalid_id-- a guild/channel/role/member id failed snowflake-shape validation before any request was built (defense against path injection).validation_error(create_messageonly) --contentwas empty or exceeded Discord's real 2000-character message limit, caught before any request was built.
Internally, discord_mcp/client.py raises typed DiscordUnreachable /
DiscordApiError (with a DiscordDecodeError subclass for the 2xx-non-JSON
case) exceptions; discord_mcp/routes.py catches both and normalizes to the
dict shape above before a tool ever returns. Tests exercise both layers for
every error type, across every HTTP verb (GET/POST/PATCH/DELETE).
Honest limitations
The
cloudflare_blockedvs.permission_errorsplit is a heuristic (JSON-body-present-or-not), not something Discord documents or guarantees. It is accurate for the specific failure mode it was written to explain (an edge reject due to a missing/generic User-Agent) but a 403 with a stripped body from an unrelated cause (e.g. a misbehaving proxy in between) would also be classified ascloudflare_blocked.get_channel_permission_overwritesandget_member_roleswere not exercised against every possible real-world edge case (e.g. a member with zero roles, a channel with zero overwrites) via the live smoke test -- only via respx-mocked unit tests. The live smoke test only callslist_channels/list_roles; it does not exercise any write tool.No pagination is implemented anywhere.
list_channels/list_rolesare single-request, unpaginated Discord endpoints (Discord doesn't paginate either of these), so this is a non-issue for the tools in scope -- but a guild large enough to need member-list pagination is out of scope entirely (there is nolist_memberstool here).The
icon_base64/banner_base64"assumed PNG" default onedit_guildhas not been verified against a real Discord response -- see "Write tools" above.No write tool has been exercised against the real Discord API at all (by design -- this task's constraints require zero real network calls; the live smoke test remains read-only-only). This includes
create_message-- it has never posted a real message to a real live guild as part of this repo's own build/test process; that remains a deliberate, separate operator action.
Env vars
Var | Default | Purpose |
| unset | Bot token, sent as |
| unset (OFF) | Set to |
|
| Per-request timeout (seconds) |
| unset | Set to |
| unset | Guild id the live smoke test targets. Test skips cleanly if unset. |
| unset | Path to an external |
DISCORD_API_BASE (https://discord.com/api/v10) is a fixed constant, not
env-overridable -- unlike bus-mcp's self-hosted BUS_MCP_BASE_URL, Discord's
REST API has exactly one real base URL.
Usage examples
Once connected in a Claude session, an agent can:
list_channels(guild_id="123456789012345678")
list_roles(guild_id="123456789012345678")
list_categories(guild_id="123456789012345678")
get_channel_permission_overwrites(channel_id="...")
get_member_roles(guild_id="123456789012345678", member_id="...")With DISCORD_MCP_ENABLE_WRITE=1 set:
create_channel(guild_id="...", name="general", type=0)
edit_channel(channel_id="...", name="renamed", position=3)
create_role(guild_id="...", name="Mod", color=1752220, hoist=True)
edit_role(guild_id="...", role_id="...", name="Senior Mod", permissions="8")
edit_guild(guild_id="...", name="New Server Name")
delete_channel(channel_id="...")
create_message(channel_id="...", content="hello from discord-mcp")Testing
.venv/Scripts/python.exe -m pytest -q163 tests: 162 unit tests (respx-mocked, zero real network) + 1 live smoke
(gated, see below). All 12 tools' happy paths are covered, every error type
above is exercised at both the client layer (test_client.py) and the
routes-normalization layer (test_routes.py), and test_server.py actually
asyncio.run()s each @mcp.tool async wrapper function against a
monkeypatched routes module -- not just introspects list_tools() -- so an
arg-name mismatch or dropped kwarg between server.py and routes.py would
be caught.
Write-tool coverage specifically (test_config.py + test_routes.py):
gate-off refusal for each of the 7 write tools with len(respx.calls) == 0
asserted (proving no Discord call is even attempted), gate-on success paths
with mocked Discord responses (including request-body assertions), gate-on
Discord-API-error passthrough (permission/not-found/rate-limit/network/5xx),
and delete_channel specifically double-checked -- both that it refuses
identically to the other write tools, and that no plausible-but-wrong env
var name (DISCORD_MCP_ENABLE_DELETE, etc.) accidentally arms it.
create_message additionally gets dedicated content-length boundary tests
(test_client.py/test_routes.py): exactly 2000 characters is accepted (1
respx call), 2001 characters and an empty string are both rejected locally
as validation_error with zero respx calls.
Live smoke test
tests/test_live_smoke.py::test_live_list_channels_and_roles_against_a_real_guild
is gated behind DISCORD_MCP_LIVE=1 and DISCORD_MCP_SMOKE_GUILD_ID (unset
by default -- both must be set to run) and calls the real Discord API's
list_channels/list_roles against that guild. It sources
DISCORD_BOT_TOKEN from this process's own environment if already set,
otherwise, if DISCORD_MCP_SMOKE_ENV_PATH points at an external .env
file, loads it from there (once, without ever printing or logging the
value) -- this repo has no .env of its own and never will; the real token
lives in a separate operator-controlled location. It remains
read-only-only -- no write tool has a live smoke test.
DISCORD_MCP_LIVE=1 DISCORD_MCP_SMOKE_GUILD_ID=<your-guild-id> \
DISCORD_MCP_SMOKE_ENV_PATH=<path-to-.env-with-token> \
.venv/Scripts/python.exe -m pytest tests/test_live_smoke.py -vVerified passing against a real guild at the time of writing: real channels, roles, and categories all returned as non-empty lists.
Install / connect
python -m venv .venv
.venv/Scripts/python.exe -m pip install -e ".[test]"Register in ~/.claude.json under mcpServers.discord-mcp as a stdio
server invoking run_server.py by absolute path (no cwd needed -- the
entrypoint adds its own directory to sys.path). env: {} in the real
registration -- the real bot token is never baked into ~/.claude.json;
set DISCORD_BOT_TOKEN in whatever process actually launches the server if
you want authenticated calls, and DISCORD_MCP_ENABLE_WRITE=1 if you want
the write group armed. Arming the write gate in the real registration is a
deliberate, separate operator action -- not part of this repo's default
config.
Handshake check
.venv/Scripts/python.exe scripts/list_tools.pyPrints the twelve registered tool names with no transport started -- pure introspection, useful for verifying the server wires up cleanly after any change.
Out of scope
Pagination /
list_members(see "Honest limitations" above).Retrying rate-limited (429) requests -- surfaced as a structured error, left to the caller.
Distinguishing every possible cause of a body-less 403 with certainty (see the
cloudflare_blockedheuristic's honest limitation above).Any write operation beyond the 7 tools above (e.g. member role assignment/kick/ban, message edit/delete, embeds/attachments/reactions, webhook management) --
create_messagecovers plain-textcontentonly, no embeds/files/reactions. A broader, differently shaped write-capable project exists elsewhere in this author's portfolio with anapply_server_structure-style tool, out of scope here.
Commercial support
Maintained by Jaimen Bell. For production MCP integrations, custom servers, or agent-reliability work, see jaimenbell.dev.
Building your own MCP server? The MCP Starter Kit has templates, a build playbook, and packaging war-stories from shipping this one.
mcp-name: io.github.jaimenbell/discord-mcp
Available Tools
12 toolscreate_channelA
[WRITE, gated behind DISCORD_MCP_ENABLE_WRITE=1] Create a channel (text/voice/category -- any Discord-valid type int) in a guild.
Inputs: name (required), type (required), guild_id (required), topic, +1 more. Returns: object
create_messageA
[WRITE, gated behind DISCORD_MCP_ENABLE_WRITE=1] Post a message to a text channel. content must be a non-empty string of at most 2000 characters (Discord's real message content limit).
Inputs: content (required), channel_id (required). Returns: object
create_roleB
[WRITE, gated behind DISCORD_MCP_ENABLE_WRITE=1] Create a role in a guild.
Inputs: name (required), guild_id (required), color, hoist, +1 more. Returns: object
delete_channelA
[WRITE, gated behind DISCORD_MCP_ENABLE_WRITE=1] Delete a channel. Genuinely destructive and irreversible against a real guild -- gated behind the exact same write gate as every other write tool, no separate/lower bar.
Inputs: channel_id (required). Returns: object
edit_channelA
[WRITE, gated behind DISCORD_MCP_ENABLE_WRITE=1] Rename/re-topic/re-parent/reorder an existing channel. Only the fields explicitly passed are changed.
Inputs: channel_id (required), name, topic, position, +1 more. Returns: object
edit_guildA
[WRITE, gated behind DISCORD_MCP_ENABLE_WRITE=1] Update guild-level identity (name/icon/banner/description). icon_base64/banner_base64 are base64-encoded image bytes (assumed PNG unless already a full data: URI) -- see README's honest-limitations section.
Inputs: guild_id (required), name, description, icon_base64, +1 more. Returns: object
edit_roleA
[WRITE, gated behind DISCORD_MCP_ENABLE_WRITE=1] Edit an existing role. Only the fields explicitly passed are changed.
Inputs: role_id (required), guild_id (required), name, color, +2 more. Returns: object
get_channel_permission_overwritesA
Get the permission overwrites (role/member allow+deny bitfields) set on a single channel.
Inputs: channel_id (required). Returns: object
get_member_rolesA
Get the role ids currently assigned to one guild member.
Inputs: guild_id (required), member_id (required). Returns: object
list_categoriesA
List only the category channels (Discord channel type 4) in a guild -- filtered client-side, since Discord has no dedicated categories-only endpoint.
Inputs: guild_id (required). Returns: object
list_channelsA
List all channels (every type, including categories and voice channels) in a Discord guild.
Inputs: guild_id (required). Returns: object
list_rolesB
List all roles in a Discord guild.
Inputs: guild_id (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Most tools target distinct resources and actions, but list_channels and list_categories overlap as the latter is a filtered subset of the former. get_member_roles and list_roles could also be mildly confused, though descriptions clarify scope.
Consistent verb_noun pattern: list_* for collections, get_* for specific sub-resources, create_/edit_/delete_ for mutations. All snake_case with predictable naming.
12 tools is a well-scoped set for a Discord guild management server, fitting the 3-15 range.
Core channel lifecycle is covered (list/create/edit/delete) plus role create/edit, but delete_role is missing and there's no way to assign roles to members or edit permission overwrites, creating notable gaps.
Maintenance
Related MCP Connectors
- Discortics - Discord BotDeprecatedcom.discortics
Set up and manage your Discord server from MCP: channels, roles, verification, tickets and security.
Discord MCP server for ChatGPT, Claude and any AI agent: list servers and channels, read channel messages, search messages, send message, reply to message, send DM, read mentions and assign role in your own Discord account. Cotlet works in the account through your Cloud Browser, a real Chrome where you sign in to Discord yourself; Cotlet does not store your password and you need no Discord API key. About the official Discord API: Yes, Discord has an official API for bots and OAuth2 apps, but it acts as a bot that a server manager adds, not as you, and Discord has no official MCP server for it (checked 5 Nov 2026). The MCP server on Discord's docs site only searches documentation. Setup and FAQ: https://cotlet.dev/integrations/discord-api-mcp-server
MCP server for progressive tool usage at any scale (see https://klavis.ai)
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
Related MCP Servers
- AlicenseAqualityCmaintenanceMCP server for Discord bot API that exposes five tools to search, inspect, and call stable Discord HTTP endpoints using bot-token authentication, with automatic schema refresh and strict safety filtering.5MIT
- FlicenseNot gradedqualityCmaintenanceEnables MCP clients to read, post to, and moderate a Discord server through the Discord REST API, with opt-in guardrails and dry-run safeguards.-
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients to control a logged-in Discord account through 70+ tools: browsing guilds and channels, sending and reacting to messages, moderating members, managing channels, roles, emojis, and webhooks, plus searching and analyzing captured message history stored in SQLite. Authenticates using tokens already cached by the local Discord client, requiring no bot account or manual token setup.MIT
- AlicenseAqualityBmaintenanceEnables MCP clients to interact with the Discord REST API through tools for messages, reactions, threads, channels, webhooks, guilds, members, roles, moderation, events, invites, and file transfer. It supports guild allowlists, read-only mode, toolset selection, and approval before destructive actions.40123 npmMIT