betweentwomidnights/darius-in-discord
If you are the rightful owner of darius-in-discord and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
Darius in Discord is an MCP server that streams AI-generated music to Discord, allowing real-time control via natural language commands.
Darius in Discord 🎵🤖
this is my first mcp server. built on a whim for a guy named yikes.
What This Does
- Darius (Discord Bot): Streams Magenta RT-generated audio to Discord voice channels
- Claude (MCP Server): Acts as an intelligent control interface for the music parameters
- You: Give natural language commands like "make it more aggressive" or "add some acid house vibes"
The result: claude responds to your verbal feedback in real-time while your friends listen in Discord.
Magenta RT API Backend
This application connects to a Magenta RT API hosted on HuggingFace Spaces: thecollabagepatch/magenta-retry
Note: The API URL is currently hardcoded in magenta_mcp_server.py (line 186) and discord_bot.py (line 185):
ws_url = "wss://thecollabagepatch-magenta-retry.hf.space/ws/jam"
This space is specifically designed to be duplicable as an API for various Magenta RT applications. darius-in-discord is just one such application using this backend.
Using Your Own Backend
You can:
- Use the existing space (may have usage limits or downtime)
- Duplicate the space to your own HuggingFace account:
- Go to thecollabagepatch/magenta-retry
- Click "⋮" menu → "Duplicate this Space"
- Choose CPU or GPU (GPU recommended for real-time performance)
- Update the hardcoded URLs in
magenta_mcp_server.pyanddiscord_bot.pywith your space URL
- Run locally with your own Magenta RT instance
Coming soon: Environment variable configuration for the API URL to make switching backends easier.
Architecture
┌─────────────────┐ ┌──────────────────┐
│ Claude Desktop │────────▶│ MCP Server │
│ (Control UI) │ │ (Parameter │
└─────────────────┘ │ Control) │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ Magenta RT API │
│ /ws/jam │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ Discord Bot │
│ (Audio Stream) │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ Discord Voice │
│ Channel │
└──────────────────┘
Setup
Prerequisites
- Python 3.10+
- Discord Bot Token (Get one here)
- Claude Desktop (Download here)
- FFmpeg (for Discord voice)
Installation
-
Clone the repository:
git clone https://github.com/betweentwomidnights/darius-in-discord.git cd darius-in-discord -
Create virtual environment:
python -m venv venv # Windows venv\Scripts\activate # Mac/Linux source venv/bin/activate -
Install dependencies:
pip install mcp websockets discord.py pynacl python-dotenv pydub -
Configure environment:
cp .env.example .env # Edit .env and add your Discord bot token -
Install FFmpeg:
- Windows: Download from ffmpeg.org or
winget install ffmpeg - Mac:
brew install ffmpeg - Linux:
sudo apt install ffmpeg
- Windows: Download from ffmpeg.org or
-
Configure Claude Desktop:
Edit your Claude Desktop config file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - Mac:
~/Library/Application Support/Claude/claude_desktop_config.json
Add this configuration (adjust paths to match your setup):
{ "mcpServers": { "magenta-rt": { "command": "/full/path/to/venv/Scripts/python.exe", "args": ["/full/path/to/magenta_mcp_server.py"] } } }Windows example:
{ "mcpServers": { "magenta-rt": { "command": "C:\\Users\\YourName\\darius-in-discord\\venv\\Scripts\\python.exe", "args": ["C:\\Users\\YourName\\darius-in-discord\\magenta_mcp_server.py"] } } } - Windows:
-
Invite Darius to your Discord server:
- Go to Discord Developer Portal
- Select your application
- OAuth2 → URL Generator
- Select scopes:
bot - Select permissions:
Connect,Speak - Copy and open the generated URL to invite the bot
Usage
1. Start Darius (Discord Bot)
python discord_bot.py
You should see:
darius#0330 has connected to Discord!
Bot is in 1 guild(s)
2. Start Music in Discord
In your Discord server:
!join # Darius joins your voice channel
!jam warmup # Start streaming music
3. Control via Claude Desktop
Restart Claude Desktop to load the MCP server, then just talk naturally:
Examples:
- "Start a jam session with dark techno vibes"
- "Make it more aggressive"
- "Too chaotic, bring it back"
- "Add some acid house flavor"
- "Keep the vibe but make it darker"
- "Go completely crazy"
Claude will:
- Read the parameter guide automatically
- Make gradual adjustments (avoiding jarring transitions)
- Understand the math behind weight normalization
- Stay within optimal parameter ranges
Discord Commands
Manual control commands:
!join- Join your voice channel!jam [styles]- Start with specific styles (e.g.,!jam techno, ambient)!stop- Stop the music!leave- Leave voice channel!status- Check bot status
How It Works
Parameters You Can Control
- Temperature (0.1-2.0): Randomness/creativity
- Guidance (0.0-8.0): How strongly it follows style prompts
- TopK (1-256): Sampling variety
- Styles: Genres, instruments, vibes, or any descriptive words
- Style Weights: Blend multiple styles with different intensities
- Use Current Mix as Style: For smoother transitions
- Finetune Steering (if available):
- Mean Weight: Pull toward average of training data
- Centroid Weights: Steer toward specific clusters
The Knowledge Base
Claude automatically reads magenta_knowledge.md which contains:
- Parameter ranges and sweet spots
- Weight normalization math
- Best practices for gradual changes
- Common interaction patterns
- Technical implementation details
This ensures Claude makes intelligent adjustments without you having to explain how everything works.
Gradual Adjustments
Claude knows to change parameters slowly (2-4 steps with delays) to avoid jarring audio artifacts. For example:
You: "Make it more chaotic"
Claude: Increases temperature from 1.1 → 1.3 → 1.5 → 1.7 over 6 seconds, while also bumping topk from 40 → 60 → 80.
Project Structure
darius-in-discord/
├── magenta_mcp_server.py # MCP server for Claude Desktop
├── discord_bot.py # Discord bot for audio streaming
├── magenta_knowledge.md # Parameter guide for Claude
├── magenta_prompts.js # Style presets (from web tester)
├── .env.example # Environment template
├── .gitignore # Git ignore rules
├── requirements.txt # Python dependencies
└── README.md # This file
Known Issues
- Audio artifacts: The pydub resampling can introduce some artifacts. Future improvements could use SoX for better quality.
- Latency: There's 1-2 seconds of latency due to Discord streaming and WebSocket buffering.
- Crossfade jank: Occasionally the crossfades can be rough, especially during parameter changes.
Future Enhancements
- Environment variable for API URL configuration
- Voice input support (yell directly at Claude through Discord)
- Better audio resampling (SoX instead of pydub)
- One-shot generation support
- Audio injection via
/jam/startendpoint with bar-aligned chunks (possibly better for use inside discord tbh) - Web dashboard for visualization
- Multi-user sessions
Credits
Built by Kevin (betweentwomidnights) with Claude (Anthropic) using pure vibes.
Powered by:
- Magenta RT - Infinite music generation
- Claude Desktop - AI interface via MCP
- Discord.py - Discord bot framework
License
MIT License - see LICENSE file for details
enjoy the goon sessions yikes