# DiscordClaudeCode

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

- **Type:** MCP server
- **Install:** `agentstack add mcp-0rnot-discordclaudecode`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [0rnot](https://agentstack.voostack.com/s/0rnot)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [0rnot](https://github.com/0rnot)
- **Source:** https://github.com/0rnot/DiscordClaudeCode

## Install

```sh
agentstack add mcp-0rnot-discordclaudecode
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 🤖 DiscordClaudeCode

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

[](https://opensource.org/licenses/MIT)
[](https://www.python.org/downloads/)
[](https://modelcontextprotocol.io/)
[](https://discord.com/)

**[English](#overview)** | **[日本語](README_ja.md)**

---

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

---

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

```bash
# 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

```bash
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`:

```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](https://discord.com/developers/applications)
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](LICENSE) file for details.

## 🙏 Acknowledgments

This project was inspired by [KOBA789/human-in-the-loop](https://github.com/KOBA789/human-in-the-loop).

---

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

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [0rnot](https://github.com/0rnot)
- **Source:** [0rnot/DiscordClaudeCode](https://github.com/0rnot/DiscordClaudeCode)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-0rnot-discordclaudecode
- Seller: https://agentstack.voostack.com/s/0rnot
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
