MCP Discord
Enable AI agents to read and send messages in Discord channels via a bot integration.
- Package:
@iqai/mcp-discord - Provider: Discord
Overview
The Discord MCP server lets your agent interact with Discord — reading messages from channels, sending responses, and monitoring server activity. It is useful for building agents that moderate communities, answer questions, or summarize discussions on Discord.
Bot Token Security
Your Discord bot token grants full access to your bot account. Never expose it in client-side code or commit it to source control.
Getting Started
Install the package:
pnpm add @iqai/mcp-discordUse the server in your agent:
import { McpDiscord } from "@iqai/adk";
const toolset = McpDiscord({
env: {
DISCORD_TOKEN: process.env.DISCORD_TOKEN,
},
});
const tools = await toolset.getTools();import { McpToolset } from "@iqai/adk";
const toolset = new McpToolset({
name: "Discord MCP Client",
description: "Client for Discord bot interactions",
transport: {
mode: "stdio",
command: "npx",
args: ["-y", "@iqai/mcp-discord"],
env: {
DISCORD_TOKEN: process.env.DISCORD_TOKEN,
PATH: process.env.PATH || "",
},
},
});
const tools = await toolset.getTools();{
"mcpServers": {
"discord-mcp-server": {
"command": "npx",
"args": ["-y", "@iqai/mcp-discord"],
"env": {
"DISCORD_TOKEN": "your_discord_bot_token"
}
}
}
}Environment Variables
| Variable | Required | Description |
|---|---|---|
DISCORD_TOKEN | Yes | Your Discord bot token |
Credentials
To create a Discord bot and get your token:
- Go to the Discord Developer Portal
- Click New Application, name it, and go to the Bot tab
- Click Reset Token and copy your bot token
- Under OAuth2 → URL Generator, select the
botscope and the permissions your agent needs - Use the generated URL to invite the bot to your server
Available Tools
discord_create_categoryguildId:stringname:stringposition:numberreason:string
discord_create_categoryDescription
Creates a new category in a Discord server.
discord_edit_categorycategoryId:stringname:stringposition:numberreason:string
discord_edit_categoryDescription
Edits an existing Discord category (name and position).
discord_delete_categorycategoryId:stringreason:string
discord_delete_categoryDescription
Deletes a Discord category by ID.
discord_logintoken:string
discord_loginDescription
Logs in to Discord using the configured token
discord_sendchannelId:stringmessage:string
discord_sendDescription
Sends a message to a specified Discord text channel
discord_get_forum_channelsguildId:string
discord_get_forum_channelsDescription
Lists all forum channels in a specified Discord server (guild)
discord_create_forum_postforumChannelId:stringtitle:stringcontent:stringtags:array
discord_create_forum_postDescription
Creates a new post in a Discord forum channel with optional tags
discord_get_forum_postthreadId:string
discord_get_forum_postDescription
Retrieves details about a forum post including its messages
discord_reply_to_forumthreadId:stringmessage:string
discord_reply_to_forumDescription
Adds a reply to an existing forum post or thread
discord_create_text_channelguildId:stringchannelName:stringtopic:string
discord_create_text_channelDescription
Creates a new text channel in a Discord server with an optional topic
discord_delete_channelchannelId:stringreason:string
discord_delete_channelDescription
Deletes a Discord channel with an optional reason
discord_read_messageschannelId:stringlimit:number
discord_read_messagesDescription
Retrieves messages from a Discord text channel with a configurable limit
discord_get_server_infoguildId:string
discord_get_server_infoDescription
Retrieves detailed information about a Discord server including channels and member count
discord_add_reactionchannelId:stringmessageId:stringemoji:string
discord_add_reactionDescription
Adds an emoji reaction to a specific Discord message
discord_add_multiple_reactionschannelId:stringmessageId:stringemojis:array
discord_add_multiple_reactionsDescription
Adds multiple emoji reactions to a Discord message at once
discord_remove_reactionchannelId:stringmessageId:stringemoji:stringuserId:string
discord_remove_reactionDescription
Removes a specific emoji reaction from a Discord message
discord_delete_forum_postthreadId:stringreason:string
discord_delete_forum_postDescription
Deletes a forum post or thread with an optional reason
discord_delete_messagechannelId:stringmessageId:stringreason:string
discord_delete_messageDescription
Deletes a specific message from a Discord text channel
discord_create_webhookchannelId:stringname:stringavatar:stringreason:string
discord_create_webhookDescription
Creates a new webhook for a Discord channel
discord_send_webhook_messagewebhookId:stringwebhookToken:stringcontent:stringusername:stringavatarURL:stringthreadId:string
discord_send_webhook_messageDescription
Sends a message to a Discord channel using a webhook
discord_edit_webhookwebhookId:stringwebhookToken:stringname:stringavatar:stringchannelId:stringreason:string
discord_edit_webhookDescription
Edits an existing webhook for a Discord channel
discord_delete_webhookwebhookId:stringwebhookToken:stringreason:string
discord_delete_webhookDescription
Deletes an existing webhook for a Discord channel
Integration Example
import { AgentBuilder, McpDiscord } from "@iqai/adk";
import * as dotenv from "dotenv";
dotenv.config();
async function main() {
// Initialize McpDiscord toolset
const toolset = McpDiscord({
env: {
DISCORD_TOKEN: process.env.DISCORD_TOKEN,
},
});
// Get available McpDiscord tools
const discordTools = await toolset.getTools();
// Create agent with McpDiscord tools
const { runner } = await AgentBuilder.create("discord_agent")
.withModel("gemini-2.5-flash")
.withDescription(
"A Discord community agent that summarizes and responds to messages",
)
.withTools(...discordTools)
.build();
const response = await runner.ask(
"Read the last 20 messages in channel 123456789 and summarize what the community is discussing",
);
console.log(response);
}
main().catch(console.error);