This guide provides detailed instructions for setting up the Discord MCP (Model Context Protocol) server with MassGen and Claude Code. The Discord MCP server enables AI assistants to interact with Discord platform features including sending messages, managing channels, handling reactions, and more.
- Node.js: Version 16.0.0 or higher
- npm: Version 7.0.0 or higher
- Operating System: Windows, macOS, or Linux
- Navigate to Discord Developer Portal
- Click "New Application" button
- Enter a name for your application (e.g., "MCP Bot")
- Click "Create"
- In your application, go to the "Bot" section in the left sidebar
- Click "Add Bot"
- Customize your bot's username and avatar if desired
- In the Bot section, scroll down to "Privileged Gateway Intents"
- Enable the following intents:
- Message Content Intent: Required to read message content
- Server Members Intent: Required to access member information
- Presence Intent: Required to track user presence
- In the Bot section, click "Reset Token"
- Copy the token immediately (you won't be able to see it again)
- Store this token securely - never share it publicly
- Go to "OAuth2" → "URL Generator" in the left sidebar
- Under "Scopes", select:
botapplications.commands(if using slash commands)
- Under "Bot Permissions", select the permissions your bot needs:
- Send Messages
- Read Messages/View Channels
- Manage Messages
- Add Reactions
- Manage Channels (if needed)
- Manage Webhooks (if needed)
- Copy the generated URL and open it in your browser
- Select the server you want to add the bot to
- Click "Authorize"
Create a new YAML configuration file or use the provided example:
agent:
id: "claude_code_discord_mcp"
backend:
type: "claude_code"
cwd: "claude_code_workspace_discord_mcp"
permission_mode: "bypassPermissions"
# Discord MCP server configuration
mcp_servers:
discord:
type: "stdio"
command: "npx"
args: ["-y", "mcp-discord", "--config", "YOUR_DISCORD_BOT_TOKEN_HERE"]
allowed_tools:
- "Read"
- "Write"
- "Bash"
- "LS"
- "WebSearch"
# MCP Discord tools will be auto-discovered
ui:
display_type: "rich_terminal"
logging_enabled: trueReplace YOUR_DISCORD_BOT_TOKEN_HERE with your actual Discord bot token obtained earlier.
Once configured, the following Discord tools will be available:
mcp__discord__send_message: Send messages to channelsmcp__discord__read_messages: Read messages from channelsmcp__discord__delete_message: Delete messages
mcp__discord__create_channel: Create new channelsmcp__discord__delete_channel: Delete channelsmcp__discord__list_channels: List available channels
mcp__discord__create_forum_post: Create forum postsmcp__discord__delete_forum_post: Delete forum posts
mcp__discord__add_reaction: Add reactions to messagesmcp__discord__remove_reaction: Remove reactions from messages
mcp__discord__create_webhook: Create webhooksmcp__discord__delete_webhook: Delete webhooks
# Navigate to MassGen directory
cd /path/to/MassGen
# Run with Discord MCP configuration
uv run python -m massgen.api --config massgen/configs/claude_code_discord_mcp_example.yaml "YOUR TASK"# Send a message to a Discord channel
uv run python -m massgen.api --config massgen/configs/claude_code_discord_mcp_example.yaml "Send a message saying 'Hello from MCP!' to the general channel"
# Read recent messages
uv run python -m massgen.api --config massgen/configs/claude_code_discord_mcp_example.yaml "Read the last 10 messages from the announcements channel"
# Create a new channel
uv run python -m massgen.api --config massgen/configs/claude_code_discord_mcp_example.yaml "Create a new text channel called 'mcp-testing'"- Never commit tokens to version control: Add config files with tokens to
.gitignore - Rotate tokens regularly: Regenerate bot tokens periodically
- Limit bot permissions: Only grant necessary permissions to your bot
- Only enable intents that your bot actually needs
- Regularly review and audit bot permissions
- Use role-based permissions in Discord servers
Symptoms: Bot can't connect or authenticate Solutions:
- Verify the bot token is correct and hasn't been regenerated
- Check if the bot is properly invited to your server
- Ensure required intents are enabled in Discord Developer Portal
Symptoms: Bot can't perform certain actions Solutions:
- Review bot role permissions in Discord server settings
- Check OAuth2 permissions used when inviting the bot
- Verify the bot's role is high enough in the server hierarchy
Symptoms: MCP server fails to initialize Solutions:
- Ensure Node.js and npm are installed:
node --versionandnpm --version - Check internet connectivity for npx to download packages
- Try installing globally:
npm install -g mcp-discord - Clear npm cache:
npm cache clean --force
Symptoms: Commands stop working after multiple uses Solutions:
- Discord API has rate limits per endpoint
- Implement delays between bulk operations
- Check Discord's rate limit documentation
Symptoms: Bot can't read message content or see members Solutions:
- Enable Message Content Intent in Discord Developer Portal
- Enable Server Members Intent if accessing member data
- Restart the bot after changing intents
- GitHub Repository: https://github.com/barryyip0625/mcp-discord
- Discord Developer Portal: https://discord.com/developers/applications
- Discord.js Documentation: https://discord.js.org/
- Discord API Documentation: https://discord.com/developers/docs/intro
- MCP Protocol Specification: https://modelcontextprotocol.io/
For issues specific to:
- mcp-discord: Open an issue at GitHub Issues
- MassGen: Check the MassGen documentation or repository
- Discord API: Refer to Discord Developer Support