Discord MCP Server
Enables interaction with Discord through the Model Context Protocol, providing access to all Discord features like channels, messages, threads, reactions, and roles. Supports secure Discord bot operations with rate limiting, caching, and comprehensive API coverage for OpenAI, LangChain, and other MCP clients.
README
Discord MCP Server
A comprehensive Model Context Protocol (MCP) server for Discord integration. This server exposes all Discord functionality as MCP tools, enabling seamless integration with AI assistants like OpenAI, LangChain, Cursor, and Claude.
π Features
- Complete Discord API Coverage: Channels, messages, threads, reactions, roles, webhooks, and more
- MCP Standard Compliance: JSON-RPC 2.0 based standardized API
- High Performance: Redis caching, rate limiting, automatic retries with exponential backoff
- Security First: Mention filtering, minimal permissions, audit logging
- Production Ready: Docker support, CI/CD pipeline, comprehensive monitoring
- Advanced AI Features: Message summarization, activity analysis, intelligent filtering
π Quick Start
Prerequisites
- Python 3.12+
- Discord Bot Token
- Redis 6.0+ (optional - uses in-memory cache if not available)
Installation
-
Clone the repository
git clone https://github.com/tristan-kkim/discord-mcp.git cd discord-mcp -
Install dependencies
pip install -r requirements.txt -
Configure environment
cp .env.example .env # Edit .env with your Discord Bot Token -
Run the server
python run.py
Docker Deployment
# Using Docker Compose (recommended)
export DISCORD_BOT_TOKEN=your_bot_token_here
docker-compose up -d
# Or using Docker directly
docker build -t discord-mcp .
docker run -d -p 8000:8000 -e DISCORD_BOT_TOKEN=your_token discord-mcp
π§ MCP Client Integration
Cursor IDE
- Open Cursor Settings β MCP Servers
- Add server:
http://localhost:8000/mcp - Start using Discord tools in your AI conversations
OpenAI ChatGPT
- Create a Custom GPT
- Add Action with URL:
http://your-server:8000/mcp - Configure with your Discord server details
Claude Desktop
Add to your MCP configuration:
{
"mcpServers": {
"discord-mcp": {
"command": "uvx",
"args": ["discord-mcp@latest"],
"env": {
"DISCORD_BOT_TOKEN": "your_bot_token"
}
}
}
}
π Available MCP Tools
Channel & Guild Management
discord.list_guilds- List all guilds the bot is member ofdiscord.list_channels- List channels in a guilddiscord.get_channel- Get channel informationdiscord.create_channel- Create a new channeldiscord.update_channel- Update channel settingsdiscord.delete_channel- Delete a channel
Message Management
discord.list_messages- List messages in a channeldiscord.get_message- Get specific messagediscord.send_message- Send a messagediscord.edit_message- Edit a messagediscord.delete_message- Delete a messagediscord.search_messages- Search messages with filters
Thread Management
discord.create_thread- Create a threaddiscord.list_threads- List active/archived threadsdiscord.archive_thread- Archive a threaddiscord.unarchive_thread- Unarchive a thread
Reactions, Pins & Webhooks
discord.add_reaction- Add reaction to messagediscord.remove_reaction- Remove reactiondiscord.list_reactions- List all reactionsdiscord.pin_message- Pin a messagediscord.unpin_message- Unpin a messagediscord.create_webhook- Create webhookdiscord.send_via_webhook- Send message via webhook
Role & Permission Management
discord.list_roles- List guild rolesdiscord.add_role- Assign role to memberdiscord.remove_role- Remove role from memberdiscord.get_permissions- Get permission information
Advanced AI Features
discord.summarize_messages- AI-powered message summarizationdiscord.rank_messages- Intelligent message rankingdiscord.sync_since- Delta synchronizationdiscord.analyze_channel_activity- Channel activity analysis
π API Reference
Endpoints
GET /- Server statusGET /health- Health checkGET /metrics- Prometheus-compatible metricsPOST /mcp- MCP JSON-RPC endpoint
Example Usage
# List available tools
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "mcp_list_tools", "id": 1}'
# Send a message
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "mcp_call_tool",
"params": {
"tool": "discord.send_message",
"params": {
"channel_id": "123456789",
"content": "Hello from MCP!"
}
},
"id": 1
}'
π Security
Bot Token Security
- Never expose your bot token - Treat it like a password
- Use environment variables - Never hardcode in source code
- Minimal permissions - Only grant necessary Discord permissions
Required Discord Permissions
Send Messages- Send messages to channelsRead Message History- Read message historyManage Messages- Edit/delete messagesAdd Reactions- Add reactions to messagesManage Channels- Create/modify channels (if needed)Manage Roles- Manage roles (if needed)
Built-in Security Features
- Automatic
@everyoneand@heremention filtering - Rate limiting with Discord API compliance
- Audit logging for all operations
- Input validation and sanitization
π Monitoring & Observability
Health Checks
curl http://localhost:8000/health
Metrics
curl http://localhost:8000/metrics
Logging
All logs are structured JSON with fields:
request_id- Unique request identifiertool- MCP tool being calledchannel_id- Discord channel contextlatency_ms- Response timesuccess- Operation success status
π Production Deployment
Environment Variables
| Variable | Description | Default | Required |
|---|---|---|---|
DISCORD_BOT_TOKEN |
Discord Bot Token | - | β |
REDIS_URL |
Redis connection URL | redis://localhost:6379 |
β |
LOG_LEVEL |
Logging level | INFO |
β |
RATE_LIMIT_ENABLED |
Enable rate limiting | true |
β |
CACHE_TTL |
Cache TTL in seconds | 300 |
β |
HOST |
Server host | 0.0.0.0 |
β |
PORT |
Server port | 8000 |
β |
Cloud Deployment
Heroku
heroku create your-discord-mcp
heroku config:set DISCORD_BOT_TOKEN=your_token
git push heroku main
Railway
railway login
railway init
railway add redis
railway deploy
AWS ECS/Fargate
# Use provided Dockerfile
docker build -t discord-mcp .
# Deploy to ECS with environment variables
π§ͺ Testing
# Install test dependencies
pip install pytest pytest-asyncio pytest-cov
# Run unit tests
pytest tests/test_tools/
# Run integration tests
pytest tests/test_integration/
# Run with coverage
pytest --cov=. --cov-report=html
π€ Contributing
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to 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.
π Documentation
- Wiki: Complete Documentation
- Installation Guide: Step-by-step Setup
- Quick Start: 5-minute Setup
- API Reference: Complete API Docs
- Security Guide: Best Practices
π Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
π Changelog
v1.0.0 (2024-10-29)
- π Initial release
- β Complete Discord API integration
- β MCP standard compliance
- β Docker support
- β Advanced AI features
- β Security enhancements
- β Comprehensive documentation
νκ΅μ΄ λ¬Έμ
Discord MCP μλ²
Discordμ ν΅μ νλ Model Context Protocol(MCP) μλ²μ λλ€. λͺ¨λ Discord κΈ°λ₯μ MCP Tool ννλ‘ λ ΈμΆνμ¬ OpenAI, LangChain, Cursor λ±μ MCP ν΄λΌμ΄μΈνΈμμ μμ νκ² μ¬μ©ν μ μμ΅λλ€.
π μ£Όμ κΈ°λ₯
- μμ ν Discord API μ§μ: μ±λ, λ©μμ§, μ€λ λ, 리μ‘μ , μν , μΉν λ± λͺ¨λ Discord κΈ°λ₯
- MCP νμ€ μ€μ: JSON-RPC 2.0 κΈ°λ°μ νμ€νλ API
- κ³ μ±λ₯: Redis μΊμ±, Rate limit κ΄λ¦¬, μ§μ λ°±μ€ν μ¬μλ
- 보μ μ°μ : λ©μ νν°λ§, μ΅μ κΆν, κ°μ¬ λ‘κ·Έ
- νλ‘λμ μ€λΉ: Docker μ§μ, CI/CD νμ΄νλΌμΈ, ν¬κ΄μ λͺ¨λν°λ§
- κ³ κΈ AI κΈ°λ₯: λ©μμ§ μμ½, νλ λΆμ, μ§λ₯ν νν°λ§
π λΉ λ₯Έ μμ
μ¬μ μꡬμ¬ν
- Python 3.12+
- Discord Bot Token
- Redis 6.0+ (μ νμ¬ν - μμΌλ©΄ λ©λͺ¨λ¦¬ μΊμ μ¬μ©)
μ€μΉ
-
μ μ₯μ ν΄λ‘
git clone https://github.com/tristan-kkim/discord-mcp.git cd discord-mcp -
μμ‘΄μ± μ€μΉ
pip install -r requirements.txt -
νκ²½ μ€μ
cp .env.example .env # .env νμΌμ Discord Bot Token μ€μ -
μλ² μ€ν
python run.py
Docker λ°°ν¬
# Docker Compose μ¬μ© (κΆμ₯)
export DISCORD_BOT_TOKEN=your_bot_token_here
docker-compose up -d
# λλ Docker μ§μ μ¬μ©
docker build -t discord-mcp .
docker run -d -p 8000:8000 -e DISCORD_BOT_TOKEN=your_token discord-mcp
π§ MCP ν΄λΌμ΄μΈνΈ ν΅ν©
Cursor IDE
- Cursor μ€μ β MCP μλ² μ΄κΈ°
- μλ² μΆκ°:
http://localhost:8000/mcp - AI λνμμ Discord λꡬ μ¬μ© μμ
OpenAI ChatGPT
- Custom GPT μμ±
- Action μΆκ°:
http://your-server:8000/mcp - Discord μλ² μΈλΆμ¬νμΌλ‘ ꡬμ±
Claude Desktop
MCP ꡬμ±μ μΆκ°:
{
"mcpServers": {
"discord-mcp": {
"command": "uvx",
"args": ["discord-mcp@latest"],
"env": {
"DISCORD_BOT_TOKEN": "your_bot_token"
}
}
}
}
π μ¬μ© κ°λ₯ν MCP λꡬ
μ±λ λ° κΈΈλ κ΄λ¦¬
discord.list_guilds- λ΄μ΄ μν λͺ¨λ κΈΈλ λͺ©λ‘discord.list_channels- κΈΈλμ μ±λ λͺ©λ‘discord.get_channel- μ±λ μ 보 μ‘°νdiscord.create_channel- μ μ±λ μμ±discord.update_channel- μ±λ μ€μ μ λ°μ΄νΈdiscord.delete_channel- μ±λ μμ
λ©μμ§ κ΄λ¦¬
discord.list_messages- μ±λμ λ©μμ§ λͺ©λ‘discord.get_message- νΉμ λ©μμ§ μ‘°νdiscord.send_message- λ©μμ§ μ μ‘discord.edit_message- λ©μμ§ νΈμ§discord.delete_message- λ©μμ§ μμ discord.search_messages- νν°λ‘ λ©μμ§ κ²μ
μ€λ λ κ΄λ¦¬
discord.create_thread- μ€λ λ μμ±discord.list_threads- νμ±/μμΉ΄μ΄λΈλ μ€λ λ λͺ©λ‘discord.archive_thread- μ€λ λ μμΉ΄μ΄λΈdiscord.unarchive_thread- μ€λ λ μΈμμΉ΄μ΄λΈ
리μ‘μ , ν λ° μΉν
discord.add_reaction- λ©μμ§μ 리μ‘μ μΆκ°discord.remove_reaction- 리μ‘μ μ κ±°discord.list_reactions- λͺ¨λ 리μ‘μ λͺ©λ‘discord.pin_message- λ©μμ§ κ³ μ discord.unpin_message- λ©μμ§ κ³ μ ν΄μ discord.create_webhook- μΉν μμ±discord.send_via_webhook- μΉν μΌλ‘ λ©μμ§ μ μ‘
μν λ° κΆν κ΄λ¦¬
discord.list_roles- κΈΈλ μν λͺ©λ‘discord.add_role- λ©€λ²μκ² μν λΆμ¬discord.remove_role- λ©€λ²μμ μν μ κ±°discord.get_permissions- κΆν μ 보 μ‘°ν
κ³ κΈ AI κΈ°λ₯
discord.summarize_messages- AI κΈ°λ° λ©μμ§ μμ½discord.rank_messages- μ§λ₯ν λ©μμ§ μμdiscord.sync_since- λΈν λκΈ°νdiscord.analyze_channel_activity- μ±λ νλ λΆμ
π 보μ
Bot Token 보μ
- Bot ν ν°μ μ λ λ ΈμΆνμ§ λ§μΈμ - λΉλ°λ²νΈμ²λΌ μ·¨κΈ
- νκ²½λ³μ μ¬μ© - μμ€μ½λμ νλμ½λ© κΈμ§
- μ΅μ κΆν - νμν Discord κΆνλ§ λΆμ¬
νμν Discord κΆν
Send Messages- μ±λμ λ©μμ§ μ μ‘Read Message History- λ©μμ§ κΈ°λ‘ μ½κΈ°Manage Messages- λ©μμ§ νΈμ§/μμ Add Reactions- λ©μμ§μ 리μ‘μ μΆκ°Manage Channels- μ±λ μμ±/μμ (νμμ)Manage Roles- μν κ΄λ¦¬ (νμμ)
λ΄μ₯ 보μ κΈ°λ₯
@everyoneλ°@hereλ©μ μλ νν°λ§- Discord API μ€μ Rate limiting
- λͺ¨λ μμ μ λν κ°μ¬ λ‘κ·Έ
- μ λ ₯ κ²μ¦ λ° μ μ
π λͺ¨λν°λ§ λ° κ΄μ°°μ±
ν¬μ€μ²΄ν¬
curl http://localhost:8000/health
λ©νΈλ¦
curl http://localhost:8000/metrics
λ‘κΉ
λͺ¨λ λ‘κ·Έλ λ€μ νλκ° ν¬ν¨λ ꡬ쑰νλ JSONμ λλ€:
request_id- κ³ μ μμ² μλ³μtool- νΈμΆλλ MCP λꡬchannel_id- Discord μ±λ 컨ν μ€νΈlatency_ms- μλ΅ μκ°success- μμ μ±κ³΅ μν
π νλ‘λμ λ°°ν¬
νκ²½ λ³μ
| λ³μ | μ€λͺ | κΈ°λ³Έκ° | νμ |
|---|---|---|---|
DISCORD_BOT_TOKEN |
Discord Bot Token | - | β |
REDIS_URL |
Redis μ°κ²° URL | redis://localhost:6379 |
β |
LOG_LEVEL |
λ‘κΉ λ 벨 | INFO |
β |
RATE_LIMIT_ENABLED |
Rate limiting νμ±ν | true |
β |
CACHE_TTL |
μΊμ TTL (μ΄) | 300 |
β |
HOST |
μλ² νΈμ€νΈ | 0.0.0.0 |
β |
PORT |
μλ² ν¬νΈ | 8000 |
β |
ν΄λΌμ°λ λ°°ν¬
Heroku
heroku create your-discord-mcp
heroku config:set DISCORD_BOT_TOKEN=your_token
git push heroku main
Railway
railway login
railway init
railway add redis
railway deploy
AWS ECS/Fargate
# μ 곡λ Dockerfile μ¬μ©
docker build -t discord-mcp .
# νκ²½ λ³μμ ν¨κ» ECSμ λ°°ν¬
π§ͺ ν μ€νΈ
# ν
μ€νΈ μμ‘΄μ± μ€μΉ
pip install pytest pytest-asyncio pytest-cov
# λ¨μ ν
μ€νΈ μ€ν
pytest tests/test_tools/
# ν΅ν© ν
μ€νΈ μ€ν
pytest tests/test_integration/
# 컀λ²λ¦¬μ§μ ν¨κ» μ€ν
pytest --cov=. --cov-report=html
π€ κΈ°μ¬νκΈ°
κΈ°μ¬λ₯Ό νμν©λλ€! μμΈν λ΄μ©μ κΈ°μ¬ κ°μ΄λλ₯Ό μ°Έμ‘°νμΈμ.
- μ μ₯μ ν¬ν¬
- κΈ°λ₯ λΈλμΉ μμ± (
git checkout -b feature/amazing-feature) - λ³κ²½μ¬ν μ»€λ° (
git commit -m 'Add amazing feature') - λΈλμΉμ νΈμ (
git push origin feature/amazing-feature) - Pull Request μ΄κΈ°
π λΌμ΄μ μ€
μ΄ νλ‘μ νΈλ MIT λΌμ΄μ μ€ νμ λ°°ν¬λ©λλ€. μμΈν λ΄μ©μ LICENSE νμΌμ μ°Έμ‘°νμΈμ.
π λ¬Έμ
- Wiki: μμ ν λ¬Έμ
- μ€μΉ κ°μ΄λ: λ¨κ³λ³ μ€μ
- λΉ λ₯Έ μμ: 5λΆ μ€μ
- API μ°Έμ‘°: μμ ν API λ¬Έμ
- 보μ κ°μ΄λ: λͺ¨λ² μ¬λ‘
π μ§μ
- μ΄μ: GitHub Issues
- ν λ‘ : GitHub Discussions
π λ³κ²½ λ‘κ·Έ
v1.0.0 (2024-10-29)
- π μ΄κΈ° 릴리μ¦
- β μμ ν Discord API ν΅ν©
- β MCP νμ€ μ€μ
- β Docker μ§μ
- β κ³ κΈ AI κΈ°λ₯
- β 보μ κ°ν
- β ν¬κ΄μ λ¬Έμν
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
E2B
Using MCP to run code via e2b.