Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 DiscordClaudeCode

Bridge between Claude Code and Discord — Human-in-the-Loop via MCP

License: MIT Python 3.8+ MCP Discord

English | 日本語


Overview

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.

✨ Key Features

  • 🔗 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

📸 Screenshots

Screenshot_Discord_20250827_1813123Screenshot_20250720_2314002


🚀 Quick Start

Prerequisites

  • Python 3.8+
  • Discord account and bot
  • Google AI API Key (optional, for enhanced title generation)
  • MCP-compatible AI client (e.g., Claude Code)

Installation

# 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 .

Environment Variables

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"

Claude Code Configuration

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"
      }
    }
  }
}

📖 How It Works

┌─────────────┐     MCP Protocol     ┌──────────────┐     Discord API     ┌─────────┐
│  Claude Code │ ◄──────────────────► │  MCP Server  │ ◄────────────────► │ Discord │
│  (AI Agent)  │                      │  (This Repo) │                    │ (Human) │
└─────────────┘                      └──────────────┘                    └─────────┘
  1. AI Request — The AI assistant sends a question via the MCP protocol
  2. Discord Thread — The bot creates or reuses a thread in a Discord forum channel
  3. Human Response — The human replies in the Discord thread
  4. AI Continues — The response is returned to the AI assistant
  5. Title Generation — Thread titles are automatically updated based on conversation context

MCP Tools

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

🛠️ Discord Bot Setup

Click to expand detailed setup instructions
  1. Create Application at Discord Developer Portal
  2. Configure Bot
    • Generate a bot token under the "Bot" page
    • Enable Message Content Intent under "Privileged Gateway Intents"
  3. Set Installation Settings
    • Enable both Guild Install and User Install
    • Add applications.commands and bot scopes
    • Bot permissions: Send Messages, Create Public Threads, Read Message History
  4. Create a Forum Channel in your Discord server
  5. 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

📁 Project Structure

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

📦 Dependencies

  • discord.py (≥2.3.0) — Discord API integration
  • mcp (≥0.4.0) — Model Context Protocol support
  • PyNaCl (≥1.4.0) — Discord voice support
  • google-generativeai (≥0.8.0) — AI title generation (optional)

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License — see the LICENSE file for details.

🙏 Acknowledgments

This project was inspired by KOBA789/human-in-the-loop.


If you find this project useful, please consider giving it a ⭐!

About

Discord x Claude Code bridge via MCP (Model Context Protocol). Human-in-the-loop AI assistant integration with forum threads, real-time communication, and AI-powered title generation.

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages