discordmcp
by: v-3
Discord MCP Server for Claude Integration
📌Overview
Purpose: To enable Large Language Models (LLMs) to interact with Discord channels by sending and reading messages through the Discord API while ensuring user control and security.
Overview: The Discord MCP Server implements a Model Context Protocol (MCP) to facilitate communication between LLMs and Discord. It provides straightforward integration for sending and receiving messages, thereby enhancing the functionality of LLMs like Claude within Discord environments.
Key Features:
-
Message Sending: Enables bots to send messages directly to specified Discord channels, facilitating real-time interaction.
-
Message Reading: Allows LLMs to read recent messages from channels, providing context for better responses and communication.
-
Automatic Discovery: Automatically discovers available servers and channels for seamless integration without manual configuration.
-
Channel Identification: Supports both channel names and IDs, offering flexibility in referencing channels.
-
Error Handling: Includes proper error handling and validation to ensure smooth operation and troubleshooting.
Discord MCP Server
A Model Context Protocol (MCP) server that enables LLMs to interact with Discord channels via Discord's API, allowing for message sending and reading while maintaining user control and security.
Features
- Send messages to Discord channels
- Read recent messages from channels
- Automatic server and channel discovery
- Support for both channel names and IDs
- Proper error handling and validation
Prerequisites
- Node.js 16.x or higher
- A Discord bot token with the following permissions:
- Read Messages/View Channels
- Send Messages
- Read Message History
Setup
-
Clone the repository:
git clone https://github.com/yourusername/discordmcp.git cd discordmcp
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory and add your Discord bot token:DISCORD_TOKEN=your_discord_bot_token_here
-
Build the server:
npm run build
Usage with Claude for Desktop
-
Open your Claude for Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
Add the Discord MCP server configuration:
{ "mcpServers": { "discord": { "command": "node", "args": ["path/to/discordmcp/build/index.js"], "env": { "DISCORD_TOKEN": "your_discord_bot_token_here" } } } }
-
Restart Claude for Desktop.
Available Tools
send-message
- Sends a message to a specified Discord channel.
Parameters:
server
(optional): Server name or ID (required for multiple servers)channel
: Channel name (e.g., "general") or IDmessage
: Message content to send
Example:
{
"channel": "general",
"message": "Hello from MCP!"
}
read-messages
- Reads recent messages from a specified Discord channel.
Parameters:
server
(optional): Server name or ID (required for multiple servers)channel
: Channel name (e.g., "general") or IDlimit
(optional): Number of messages to fetch (default: 50, max: 100)
Example:
{
"channel": "general",
"limit": 10
}
Development
-
Install development dependencies:
npm install --save-dev typescript @types/node
-
Start the server in development mode:
npm run dev
Testing
Test the server using the MCP Inspector:
npx @modelcontextprotocol/inspector node build/index.js
Examples
Try these interactions with Claude after setting up the server:
- "Can you read the last 5 messages from the general channel?"
- "Please send a message to the announcements channel saying 'Meeting starts in 10 minutes'"
- "What were the most recent messages in the development channel about the latest release?"
Claude will request user approval before sending any messages.
Security Considerations
- Ensure the bot has the proper Discord permissions.
- All message sending operations require explicit user approval.
- Secure environment variables properly.
- Never commit tokens to version control.
- Limit channel access to channels the bot has access to.
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter issues or have questions:
- Check the GitHub Issues section.
- Consult the MCP documentation at https://modelcontextprotocol.io.
- Open a new issue with detailed reproduction steps.