A Python implementation of a Model Context Protocol (MCP) server that enables AI assistants to interact with humans through Discord. It acts as a bridge between AI systems (like Claude Code) and human users, enabling collaborative tasks, decision-making, and information gathering — all through Discord forum threads.
- 🔗 MCP Integration — Full Model Context Protocol support for Claude Code and compatible AI assistants
- 💬 Discord Forum Threads — Organized conversations in Discord forum channels
- 🧠 AI-Powered Titles — Automatic thread title generation using Google Gemini AI
- ⚡ Real-Time Communication — Bidirectional messaging between AI and humans
- 📝 Conversation Management — Thread persistence and history tracking
- 🛡️ Graceful Fallbacks — Degraded operation when AI services are unavailable
- Python 3.8+
- Discord account and bot
- Google AI API Key (optional, for enhanced title generation)
- MCP-compatible AI client (e.g., Claude Code)
# Clone the repository
git clone https://github.com/0rnot/DiscordClaudeCode.git
cd DiscordClaudeCode
# Install dependencies
pip install -r requirements.txt
# Or install as a package
pip install .export DISCORD_BOT_TOKEN="your_discord_bot_token"
export GOOGLE_AI_API_KEY="your_google_ai_api_key" # Optional
export HUMAN_CHANNEL_ID="your_discord_forum_channel_id"
export HUMAN_USER_ID="your_discord_user_id"Add the following to your ~/.claude.json:
{
"mcpServers": {
"human-in-the-loop": {
"command": "python3",
"args": ["/path/to/DiscordClaudeCode/final_working_version.py"],
"env": {
"DISCORD_BOT_TOKEN": "your_discord_bot_token",
"GOOGLE_AI_API_KEY": "your_google_ai_api_key",
"HUMAN_CHANNEL_ID": "your_discord_forum_channel_id",
"HUMAN_USER_ID": "your_discord_user_id"
}
}
}
}┌─────────────┐ MCP Protocol ┌──────────────┐ Discord API ┌─────────┐
│ Claude Code │ ◄──────────────────► │ MCP Server │ ◄────────────────► │ Discord │
│ (AI Agent) │ │ (This Repo) │ │ (Human) │
└─────────────┘ └──────────────┘ └─────────┘
- AI Request — The AI assistant sends a question via the MCP protocol
- Discord Thread — The bot creates or reuses a thread in a Discord forum channel
- Human Response — The human replies in the Discord thread
- AI Continues — The response is returned to the AI assistant
- Title Generation — Thread titles are automatically updated based on conversation context
| Tool | Description | Use Case |
|---|---|---|
ask_human |
Send a question and wait for a human response | Decisions, confirmations, feedback |
report_to_human |
Send a status update without waiting for a response | Progress reports, notifications |
Click to expand detailed setup instructions
- Create Application at Discord Developer Portal
- Configure Bot
- Generate a bot token under the "Bot" page
- Enable Message Content Intent under "Privileged Gateway Intents"
- Set Installation Settings
- Enable both Guild Install and User Install
- Add
applications.commandsandbotscopes - Bot permissions: Send Messages, Create Public Threads, Read Message History
- Create a Forum Channel in your Discord server
- Get IDs (Enable Developer Mode in Discord settings)
- Right-click the forum channel → "Copy ID" for
HUMAN_CHANNEL_ID - Right-click your profile → "Copy ID" for
HUMAN_USER_ID
- Right-click the forum channel → "Copy ID" for
DiscordClaudeCode/
├── final_working_version.py # Main MCP server implementation
├── requirements.txt # Python dependencies
├── setup.py # Package setup
├── README.md # English documentation (this file)
├── README_ja.md # 日本語ドキュメント
├── LICENSE # MIT License
└── .gitignore # Git ignore rules
discord.py(≥2.3.0) — Discord API integrationmcp(≥0.4.0) — Model Context Protocol supportPyNaCl(≥1.4.0) — Discord voice supportgoogle-generativeai(≥0.8.0) — AI title generation (optional)
Contributions are welcome! Please feel free to submit a Pull Request.
- 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
This project is licensed under the MIT License — see the LICENSE file for details.
This project was inspired by KOBA789/human-in-the-loop.
If you find this project useful, please consider giving it a ⭐!

