sonic-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@sonic-mcp play a four-on-the-floor beat with a synth lead"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
sonic-mcp
MCP server that connects Claude Code to Sonic Pi for AI-assisted beat making.
Requirements
Sonic Pi 3.x installed (tested on 3.2.2)
Ubuntu 24.04 with PipeWire audio (other Linux distros may work)
uv (recommended) or pip
Related MCP server: FL Studio MCP
Setup
1. Add to Claude Code
Add this to ~/.claude/mcp.json for global use, or a project's .mcp.json to keep it scoped:
{
"mcpServers": {
"sonic-pi": {
"command": "uvx",
"args": ["--from", "git+https://github.com/AJBogo9/sonic-mcp.git", "sonic-mcp"],
"env": {
"SONIC_PI_SONGS_DIR": "/home/yourname/songs",
"SONIC_PI_PATTERNS_DIR": "/home/yourname/patterns"
}
}
}
}SONIC_PI_SONGS_DIR defaults to ~/songs and SONIC_PI_PATTERNS_DIR defaults to ~/patterns.
2. Start Sonic Pi
Headless (recommended): no GUI required.
# Install the helper scripts once
cp scripts/sonicpi-headless scripts/sonicpi-stop scripts/sonicpi-status ~/.local/bin/
chmod +x ~/.local/bin/sonicpi-headless ~/.local/bin/sonicpi-stop ~/.local/bin/sonicpi-status
# Start / stop
sonicpi-headless
sonicpi-stop
sonicpi-statusQt GUI (alternative): use pw-jack sonic-pi on PipeWire systems. The desktop
shortcut fails to open the audio device on Ubuntu 24.04.
No listener buffer or manual setup is needed in either case. The MCP server connects directly to Sonic Pi's Spider server and auto-discovers the port from the boot log.
Tools
Playback
Tool | Description |
| Run Sonic Pi code |
| Run code in a specific buffer slot 0-9 |
| Stop all playing sounds (including GUI-run buffers) |
| Read the error log -- call after run_code to catch errors |
Mixer
Tool | Description |
| Master amplitude (1.0 = unity, 0.0 = silence, max 5.0) |
| Enable master high-pass filter at freq Hz |
| Disable master high-pass filter |
| Enable master low-pass filter at freq Hz |
| Disable master low-pass filter |
| Switch master output to stereo |
| Switch master output to mono |
OSC cues
Tool | Description |
| Send an OSC cue to trigger a |
Song and pattern library
Tool | Description |
| Save a full song (auto-increments version) |
| List all songs or versions of one song |
| Load a song's code (version 0 = latest) |
| Save a reusable snippet |
| List patterns, optionally filtered by category |
| Load a pattern's code |
Recording
Tool | Description |
| Start recording via PipeWire -- returns the output path |
| Stop recording and save to disk |
How it works
The MCP server sends OSC messages over UDP to two endpoints:
Spider server (port discovered from
~/.sonic-pi/log/server-output.log): handlesrun_code,stop_all,run_in_buffer, and all mixer controls. The Qt GUI uses a dynamically allocated port (around 51235); headless mode uses fixed port 4557.Erlang OSC cues port (fixed UDP 4560): handles
send_cue, which triggerssyncpoints in running Sonic Pi code.
get_log reads ~/.sonic-pi/log/server-errors.log, which captures runtime errors from
evaluated code. Calling it after run_code lets Claude catch and fix errors automatically.
Scripts
See scripts/ for the headless management scripts.
Script | Description |
| Start Sonic Pi without the Qt GUI (PipeWire/JACK audio) |
| Stop a headless instance |
| Show running status, port, and recent log |
Local development
git clone https://github.com/AJBogo9/sonic-mcp.git
cd sonic-mcp
pip install -e .License
MIT
Available Tools
21 toolsget_logA
Read the tail of Sonic Pi's server errors log.
Captures runtime errors and warnings from eval'd code. Call this after run_code to check for errors.
Inputs: lines. Returns: result
list_patternsA
List saved patterns in the pattern library.
Args: category: Optional subfolder to filter by (e.g. "drums"). Leave empty to list all.
Inputs: category. Returns: result
list_songsA
List songs in the songs library.
Args: name: Optional song name to list versions of (e.g. "dark_pop_em"). Leave empty to list all songs and versions.
Inputs: name. Returns: result
load_patternA
Load a saved pattern from the library, returning its code.
Args: path: Relative path from the patterns root (e.g. "drums/boom_bap_basic.rb")
Inputs: path (required). Returns: result
load_songA
Load a song from the songs library.
Args: name: Song folder name (e.g. "dark_pop_em") version: Version number to load (e.g. 3 loads v3.rb). Use 0 (default) to load the latest version.
Inputs: name (required), version. Returns: result
mixer_hpf_disableA
Disable the master high-pass filter.
Inputs: no named parameters. Returns: result
mixer_hpf_enableA
Enable a high-pass filter on the master output.
Args: freq: Cutoff frequency in Hz (e.g. 80.0 removes low rumble).
Inputs: freq (required). Returns: result
mixer_lpf_disableA
Disable the master low-pass filter.
Inputs: no named parameters. Returns: result
mixer_lpf_enableA
Enable a low-pass filter on the master output.
Args: freq: Cutoff frequency in Hz (e.g. 8000.0 softens the high end).
Inputs: freq (required). Returns: result
mixer_mono_modeA
Switch master output to mono mode (sums left and right channels).
Inputs: no named parameters. Returns: result
mixer_stereo_modeA
Switch master output to stereo mode (default).
Inputs: no named parameters. Returns: result
pingA
Check whether Sonic Pi is running and which port it is on.
Reads the boot log and checks that the Spider server port is open. Does not send any OSC message -- safe to call at any time.
Inputs: no named parameters. Returns: result
record_startA
Start recording Sonic Pi's audio output via PipeWire.
Returns the output path -- pass it to record_stop when done. Requires pw-record and pw-link (pipewire-utils package).
Inputs: no named parameters. Returns: result
record_stopA
Stop the PipeWire recording and save to disk.
Args: output_path: The path returned by record_start.
Inputs: output_path (required). Returns: result
run_codeC
Run Sonic Pi code. Sonic Pi must be running (GUI or headless).
Inputs: code (required). Returns: result
run_in_bufferA
Save and run code in a specific Sonic Pi buffer slot (0-9).
Mirrors the GUI buffer tabs. Useful for organizing live_loops across multiple slots.
Args: buffer_id: Buffer index 0-9 code: The Sonic Pi Ruby code to run
Inputs: code (required), buffer_id (required). Returns: result
save_patternA
Save a reusable Sonic Pi snippet to the pattern library.
For full songs, use save_song instead.
Args: name: File name without extension (e.g. "boom_bap_basic") category: Subfolder (e.g. "drums", "melodic", "bass") code: The Sonic Pi Ruby code to save
Inputs: code (required), name (required), category (required). Returns: result
save_songA
Save a full song to the songs library with auto-incrementing version number.
Creates songs/{name}/v{N}.rb where N is one higher than the current latest version.
Args: name: Song folder name in snake_case (e.g. "dark_pop_em", "aurora_borealis") code: The Sonic Pi Ruby code to save
Inputs: code (required), name (required). Returns: result
send_cueA
Send an OSC cue to trigger a sync point in running Sonic Pi code.
Use to trigger live_loops or one_shot blocks waiting on sync. Path must start with /. Example: /trigger/drop
Args: path: OSC address, e.g. "/trigger/drop" or "/scene/chorus" value: Optional value passed as the cue argument. Integers and floats are sent as their native OSC types; anything else as a string.
Inputs: path (required), value. Returns: result
set_master_volumeA
Set the master output volume.
Args: amp: Amplitude multiplier. 1.0 is unity gain, 0.0 is silence, up to 5.0 (may clip).
Inputs: amp (required). Returns: result
stop_allA
Stop all currently playing sounds, including buffers started from the GUI.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 21 tools
Each tool targets a specific action or resource with minimal overlap. For example, run_code and run_in_buffer are differentiated by buffer slot, and load/save tools are separated by pattern vs song. The mixer tools are clearly distinct by filter type and action.
Most tools follow a verb_noun pattern (e.g., list_patterns, save_song). The mixer_* tools use a consistent noun_prefix + verb pattern, and record_start/stop are symmetrical. Ping stands alone but is a common convention.
21 tools cover the full range of Sonic Pi interactions without feeling excessive. The count is slightly high but justified by the need for separate loading, saving, mixing, and recording functions.
The tool set covers all major workflows: code execution (run_code, run_in_buffer), library management (list/load/save patterns and songs), audio control (mixer, volume, stop_all), recording, debugging (get_log), and sync (send_cue). No obvious gaps for typical usage.
Maintenance
Related MCP Connectors
MCP server for Producer/Riffusion AI music generation
Generate AI music via the Lacuna Music API from MCP clients like Claude Desktop & Code.
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Use AI models for chat, image, and video generation from Claude Code and other MCP hosts.
Related MCP Servers
- AlicenseDqualityDmaintenanceA Model Context Protocol server that allows AI assistants like Claude and Cursor to create music and control Sonic Pi programmatically through OSC messages.223 npm19MIT
- FlicenseNot gradedqualityDmaintenanceAn MCP server that connects Claude to FL Studio, allowing the AI to compose music, control instruments, and live record melodies, chords, and drums to the piano roll.108-
- FlicenseNot gradedqualityDmaintenanceAn MCP server that connects Claude to FL Studio, allowing the AI to send melodies, chords, and drum patterns directly to the DAW via virtual MIDI ports.58-
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI assistants like Claude to interact with FL Studio's piano roll, allowing users to create melodies, chord progressions, and musical patterns through natural language with automatic, real-time updates.51MIT