erdalgunes/sonic-pi-mcp
If you are the rightful owner of sonic-pi-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Sonic Pi MCP Server is a Model Context Protocol server that allows for programmatic control of Sonic Pi, a live coding music synthesizer.
Sonic Pi MCP Server
An MCP (Model Context Protocol) server that enables programmatic control of Sonic Pi, the live coding music synthesizer.
Features
- 🎵 Code Execution - Run Sonic Pi code programmatically
- 🎹 Sound Control - Play notes, samples, and control synthesizers
- 🔄 Live Loops - Create and manage live coding loops
- 🎛️ Effects - Apply audio effects and filters
- 📊 State Management - Monitor server status and logs
- 🔒 Secure Communication - Token-based authentication with Sonic Pi daemon
Prerequisites
- Sonic Pi (v4.0 or later)
- Node.js (v18 or later)
- npm or yarn
Installation
# Clone the repository
git clone https://github.com/yourusername/sonic-pi-mcp.git
cd sonic-pi-mcp
# Install dependencies
npm install
# Build the server
npm run build
# Start the server
npm start
Configuration
The server will automatically detect Sonic Pi's configuration from:
~/.sonic-pi/config/audio-settings.toml
(audio configuration)~/.sonic-pi/config/tau-settings.toml
(server settings)
Usage
With Claude Desktop
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json
):
{
"mcpServers": {
"sonic-pi": {
"command": "node",
"args": ["/path/to/sonic-pi-mcp/dist/index.js"]
}
}
}
With MCP Inspector
npx @modelcontextprotocol/inspector
Then connect to: node /path/to/sonic-pi-mcp/dist/index.js
Available Tools
Code Execution
run_code
- Execute Sonic Pi codestop_all
- Stop all running sounds
Sound Control
play_note
- Play a single noteplay_sample
- Play a sampleuse_synth
- Select synthesizer
Live Loops
start_live_loop
- Start a live loopstop_live_loop
- Stop a live loop
Configuration
set_bpm
- Set beats per minuteset_volume
- Set master volume
Status
get_status
- Get server statusget_logs
- Get recent logs
Examples
Basic Note Playing
// Play a C major chord
await runCode(`
play :c4
play :e4
play :g4
`);
Live Loop
// Create a drum loop
await startLiveLoop('drums', `
sample :bd_haus
sleep 0.5
sample :sn_zome
sleep 0.5
`);
With Effects
// Play with reverb
await runCode(`
with_fx :reverb, room: 0.8 do
play :c4, release: 2
end
`);
Architecture
The MCP server acts as a bridge between MCP clients and Sonic Pi's daemon:
- MCP Server - Handles MCP protocol and client requests
- OSC Client - Communicates with Sonic Pi daemon
- Process Manager - Manages Sonic Pi daemon lifecycle
- State Manager - Tracks server state and sessions
Development
# Install dependencies
npm install
# Run in development mode
npm run dev
# Run tests
npm test
# Build for production
npm run build
# Lint code
npm run lint
Troubleshooting
Sonic Pi not found
Ensure Sonic Pi is installed and the daemon is accessible:
- macOS:
/Applications/Sonic Pi.app
- Windows:
C:\Program Files\Sonic Pi
- Linux: Check your distribution's package location
Connection refused
The server will automatically start Sonic Pi's daemon if not running. Check:
- Sonic Pi is properly installed
- No firewall blocking local connections
- Ports 4560-4562 are available
No sound
Verify:
- Audio output device is configured
- System volume is not muted
- Sonic Pi works when launched normally
Contributing
Contributions are welcome! Please read for guidelines.
License
MIT - See for details.
Acknowledgments
- Sonic Pi by Sam Aaron
- Model Context Protocol by Anthropic
- The Sonic Pi community