Discord MCP Server
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
A Model Context Protocol (MCP) server that enables LLMs to interact with Discord channels, allowing them to send and read messages through Discord's API. Using this server, LLMs like Claude can directly interact with Discord channels 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
- The bot must be invited to your server with proper permissions:
- Read Messages/View Channels
- Send Messages
- Read Message History
Setup
1. Clone this repository:
2. Install dependencies:
3. Create a .env file in the root directory with your Discord bot token:
4. Build the server:
Usage with Claude for Desktop
1. Open your Claude for Desktop configuration file:
- macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
- Windows: %APPDATA%\Claude\claude_desktop_config.json
2. Add the Discord MCP server configuration:
3. Restart Claude for Desktop
Available Tools
send-message
Sends a message to a specified Discord channel.
Parameters:
- server (optional): Server name or ID (required if bot is in multiple servers)
- channel: Channel name (e.g., "general") or ID
- message: Message content to send
Example:
read-messages
Reads recent messages from a specified Discord channel.
Parameters:
- server (optional): Server name or ID (required if bot is in multiple servers)
- channel: Channel name (e.g., "general") or ID
- limit (optional): Number of messages to fetch (default: 50, max: 100)
Example:
Development
1. Install development dependencies:
2. Start the server in development mode:
Testing
You can test the server using the MCP Inspector:
Examples
Here are some example interactions you can try with Claude after setting up the Discord MCP server:
1. "Can you read the last 5 messages from the general channel?"
2. "Please send a message to the announcements channel saying 'Meeting starts in 10 minutes'"
3. "What were the most recent messages in the development channel about the latest release?"
Claude will use the appropriate tools to interact with Discord while asking for your approval before sending any messages.
Security Considerations
- The bot requires proper Discord permissions to function
- All message sending operations require explicit user approval
- Environment variables should be properly secured