discord-mcp-agent
A Model Context Protocol (MCP) server for Discord-based AI agent-user communication. Enables AI agents to communicate with users through Discord instead of IDE chat interfaces.
README
Discord MCP Agent
A Model Context Protocol (MCP) server for Discord-based AI agent-user communication. Enables AI agents to communicate with users through Discord instead of IDE chat interfaces.
Table of Contents
- Quick Start
- Discord Bot Setup
- Tools Reference
- Reaction Features
- Configuration
- Usage Examples
- Troubleshooting
- Requirements
- Contributing
- Links
Quick Start
Installation
# Using uvx (recommended - no install needed)
uvx discord-mcp-agent
# Or install via pip
pip install discord-mcp-agent
# For screenshot support
pip install discord-mcp-agent[screenshot]
VS Code / GitHub Copilot
Add to .vscode/mcp.json:
{
"servers": {
"discord": {
"type": "stdio",
"command": "uvx",
"args": ["discord-mcp-agent"],
"env": {
"DISCORD_TOKEN": "your-bot-token",
"DISCORD_GUILD_ID": "your-server-id",
"DISCORD_CHANNEL": "general"
}
}
}
}
Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"discord": {
"command": "uvx",
"args": ["discord-mcp-agent"],
"env": {
"DISCORD_TOKEN": "your-bot-token",
"DISCORD_GUILD_ID": "your-server-id",
"DISCORD_CHANNEL": "general"
}
}
}
}
Discord Bot Setup
- Go to Discord Developer Portal
- Click New Application → Give it a name → Create
- Go to Bot section → Click Add Bot
- Copy the Bot Token (keep this secret!)
- Enable under Privileged Gateway Intents:
- ✅ Message Content Intent
- Go to OAuth2 → URL Generator:
- Scopes:
bot - Bot Permissions:
Send Messages,Read Message History,Add Reactions,Attach Files
- Scopes:
- Copy the generated URL and open it to invite the bot to your server
- Get your Server ID: Enable Developer Mode in Discord settings, right-click your server → Copy ID
⚠️ Security Warning: Never commit your bot token to version control! Use environment variables or
.envfiles.
Tools Reference
discord_ask
Send a question and wait for user response. Supports reaction-based interactions.
| Parameter | Type | Required | Description |
|---|---|---|---|
question |
string | ✅ | The question to ask user |
Reactions automatically added:
- 📷 Take screenshot
- ❌ Cancel request
Response format:
{
"text": "User's response text",
"attachments": [{ "filename": "...", "url": "..." }],
"cancelled": false
}
discord_notify
Send a notification (no response expected).
| Parameter | Type | Required | Description |
|---|---|---|---|
message |
string | ✅ | The message to send |
discord_send_file
Send a file to the user.
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
string | ✅ | Absolute path to the file |
message |
string | ❌ | Optional message with the file |
discord_screenshot
Take and send a desktop screenshot.
| Parameter | Type | Required | Description |
|---|---|---|---|
message |
string | ❌ | Optional message with the screenshot |
Requires
pip install discord-mcp-agent[screenshot]
discord_embed
Send a rich embed message with full formatting.
| Parameter | Type | Required | Description |
|---|---|---|---|
title |
string | ❌ | Embed title |
description |
string | ❌ | Main content |
color |
integer | ❌ | Hex color (default: 0x5865F2) |
fields |
array | ❌ | Array of {name, value, inline} objects |
footer |
string | ❌ | Footer text |
thumbnail_url |
string | ❌ | Small image (top-right) |
image_url |
string | ❌ | Large image (bottom) |
author_name |
string | ❌ | Author name (top) |
url |
string | ❌ | Title link URL |
Reaction Features
Every message from the bot includes interactive reaction buttons:
| Emoji | Action | Description |
|---|---|---|
| 📷 | Screenshot | Takes a screenshot and sends it to Discord |
| ❌ | Cancel | Cancels the current discord_ask and returns control |
| ⏳ | Timeout | Added automatically when a request times out |
How It Works
- Bot sends a message with 📷 and ❌ reactions
- User can click reactions to trigger actions
- 📷 immediately captures and sends a screenshot
- ❌ cancels waiting and returns
"cancelled": true
Configuration
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
DISCORD_TOKEN |
✅ | - | Your Discord bot token |
DISCORD_GUILD_ID |
✅ | - | Your Discord server ID |
DISCORD_CHANNEL |
❌ | general |
Channel name to use |
DISCORD_REMINDER |
❌ | - | Custom text appended to all responses |
DISCORD_ASK_TIMEOUT |
❌ | 300 |
Seconds to wait for user response |
DISCORD_HTTP_TIMEOUT |
❌ | 30 |
Seconds for HTTP operations |
DISCORD_CONNECTION_TIMEOUT |
❌ | 30 |
Seconds to establish connection |
Custom Reminder
Inject custom instructions into every tool response:
{
"env": {
"DISCORD_REMINDER": "Remember: Always confirm with the user before completing tasks."
}
}
Timeout Configuration
Adjust timeouts for your use case:
{
"env": {
"DISCORD_ASK_TIMEOUT": "600",
"DISCORD_HTTP_TIMEOUT": "60"
}
}
Usage Examples
MCP Tool Call: Ask Question
{
"name": "discord_ask",
"arguments": {
"question": "What color theme would you like for the dashboard?"
}
}
Response:
{
"text": "I'd prefer a dark theme with blue accents",
"attachments": [],
"cancelled": false
}
MCP Tool Call: Send Embed
{
"name": "discord_embed",
"arguments": {
"title": "Build Complete ✅",
"description": "Your project has been successfully built.",
"color": 5763719,
"fields": [
{ "name": "Duration", "value": "2m 34s", "inline": true },
{ "name": "Size", "value": "1.2 MB", "inline": true }
],
"footer": "Built with discord-mcp-agent"
}
}
Handling Image Attachments
When users send images in response to discord_ask, they're automatically:
- Downloaded from Discord
- Encoded as base64
- Returned as
ImageContentfor AI model consumption
Troubleshooting
| Error | Cause | Solution |
|---|---|---|
DISCORD_TOKEN environment variable is required |
Missing token | Set DISCORD_TOKEN in your MCP config |
Guild with ID X not found |
Bot not in server | Invite bot using OAuth2 URL |
Channel 'X' not found in guild |
Wrong channel name | Check DISCORD_CHANNEL matches exactly |
Failed to connect within 30 seconds |
Network/token issue | Verify token and network connectivity |
PIL not installed |
Screenshot dep missing | Run pip install discord-mcp-agent[screenshot] |
⏳ No response received within X seconds |
User didn't respond | Increase DISCORD_ASK_TIMEOUT or user can click ❌ |
Common Issues
Bot appears offline:
- Ensure
Message Content Intentis enabled in Discord Developer Portal - Check that the bot token is correct
Bot can't see messages:
- Enable
Message Content Intentin bot settings - Ensure bot has
Read Message Historypermission
Screenshots not working:
- Install Pillow:
pip install discord-mcp-agent[screenshot] - On Linux, may require display server access
Requirements
- Python 3.10+
mcp >= 1.0.0discord.py >= 2.0.0pydantic >= 2.0.0aiohttp >= 3.8.0Pillow >= 10.0.0(optional, for screenshots)
Security
⚠️ Never commit your Discord bot token to version control!
- Use environment variables or
.envfiles - Add
.envto.gitignore - Regenerate token immediately if exposed
Contributing
Contributions are welcome!
- Fork the repository
- Create your feature branch
- Add tests for new features
- Submit a pull request
Development Setup
git clone https://github.com/zebbern/discord-mcp-agent.git
cd discord-mcp-agent
pip install -e ".[dev]"
pytest tests/ -v
Links
Made with ❤️ for the MCP community
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。