sonic-pi-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
sonic-pi-mcp
A reliable MCP server for Sonic Pi, written in Rust. It lets AI agents such as Claude Code, Codex, Cursor and VS Code compose, run, change, debug, stop and record live music in a locally running Sonic Pi.
Independent lifecycle. The server starts, initialises and answers with Sonic Pi closed. It finds Sonic Pi when it launches and reconnects after restarts without replaying anything.
Confirmed execution. Each run reports what Sonic Pi actually did:
completed,running,error(with class, message and your line number) orunconfirmed, which is never retried automatically. Sending a packet is not counted as success.Stop that works when it matters.
sonic_pi_stopis sent even when runaway code makes Sonic Pi too busy to answer.Long-form recording. Lossless takes of up to 4 hours, recorded by Sonic Pi's own audio engine, with a hard time limit, crash recovery and provenance.
Actionable diagnostics.
doctorwalks through installation, process, credentials, handshake and audio engine health, and gives a fix for each failure.Single native binary. No Python, Node.js or other runtime is needed. Only Sonic Pi itself is required.
mcp-name: io.github.ashishra0/sonic-pi-mcp
Requirements
Sonic Pi 5.x, installed and (for anything that plays music) running.
Verified on macOS (Apple Silicon) with Sonic Pi 5.0.0, including a 60-minute recording soak. Linux and Windows builds are tested in CI against a simulated Sonic Pi but have not yet been verified with the real app. Reports are very welcome (see CONTRIBUTING.md). Details: docs/COMPATIBILITY.md.
Related MCP server: strudel-ai
Install
cargo install sonic-pi-mcp --locked # from crates.io (Rust 1.89+)
sonic-pi-mcp doctor # check everything (start Sonic Pi first)Prebuilt binaries for macOS (Apple Silicon, Intel), Linux (x86_64, aarch64) and Windows (x86_64) are
attached to each GitHub release, with SHA-256
checksums. From a checkout: cargo install --path . --locked.
Connect your MCP client
The server speaks MCP over stdio: the command is sonic-pi-mcp with the single argument serve.
If the client can't find it on its PATH, use the absolute path (e.g. ~/.cargo/bin/sonic-pi-mcp).
Claude Code
claude mcp add --scope user sonic-pi -- sonic-pi-mcp serveCodex
codex mcp add sonic-pi -- sonic-pi-mcp serveClaude Desktop (claude_desktop_config.json) and Cursor (~/.cursor/mcp.json)
{ "mcpServers": { "sonic-pi": { "command": "sonic-pi-mcp", "args": ["serve"] } } }VS Code (.vscode/mcp.json)
{ "servers": { "sonic-pi": { "type": "stdio", "command": "sonic-pi-mcp", "args": ["serve"] } } }Tools
30 tools. Each has a title and honest hints (read-only, destructive, idempotent; all closed-world),
and every input schema is plain JSON Schema without $ref or nullable type arrays, so it works in
strict clients too.
Tool | What it does |
| Connection state ( |
| Where Sonic Pi's port and token were found (the token is never shown) |
| Run code and report |
| Stop all runs and live_loops. |
| Size limits, policy guard rail, Ruby syntax check using Sonic Pi's bundled Ruby, unknown names, loud-amp warnings |
| Recent runtime errors, including errors raised later inside live_loops, filterable by |
| Force rediscovery and a new handshake |
| Step-by-step diagnosis with a fix for each failure |
Music knowledge. These tools read the installed Sonic Pi, so they always match its version. Sonic Pi must be installed but does not need to be running:
Tool | What it does |
|
|
| Every option of a synth or effect: default, valid range, slidable, description |
| Official docs for a language function ( |
| Sonic Pi's own bundled example pieces |
Unknown names come back as NOT_FOUND with "did you mean" suggestions. sonic_pi_validate also uses
this data: it flags unknown synth, FX, sample, scale and chord names, and built-in function names used
as variables (scale = …), which Sonic Pi itself refuses to run.
Compositions (stable, not being extended): the model is the source of truth; Sonic Pi code is derived from it.
Tool | What it does |
| New piece (tempo, key, bar length) / inspect it, optionally with the generated code |
| One |
| Body, synth, volume, mute and solo in one undoable step; muted tracks keep running silently so they stay in time |
| Add or remove an effect on one track |
| Tempo (and optionally key) through Sonic Pi's shared state, with no loop redefinition |
| Arrangement: define sections as sets of audible tracks and switch between them |
| Start, resync, or stop only this piece |
| Revision history and JSON persistence |
While a piece is playing, each edit sends only the loops that changed. Sonic Pi hot-swaps them at their next iteration and the other tracks keep playing. Verified on the real runtime: no gap in the kick across a swap, and the off-beat stays within 16 ms. If Sonic Pi rejects an edit, the edit is rolled back, so the model and the music never disagree.
Recording (long-form, up to 4 h):
Tool | What it does |
| Starts capturing Sonic Pi's main output to a 24-bit/48 kHz WAV and returns immediately. Sonic Pi's audio engine writes the file directly. |
| Seconds and bytes recorded so far, runtime errors and code sent since the start; or the final result |
| Finalises the WAV. Returns duration, format, level checks (peak/RMS/clipping/silence) and provenance (Sonic Pi version, code hashes of what was sent while recording) |
| Detailed signal measurements of a finished recording (frozen feature: measurements, not a verdict on the music) |
A recording keeps going when playback stops (sonic_pi_stop does not end it). If Sonic Pi quits or
its audio engine crashes mid-take, the recording is marked interrupted, and the audio captured so far
is kept and the WAV header repaired. When the server exits it stops its recording; if it crashes, the next server process finds and
closes the orphaned recording.
Resources: sonic-pi://guide/workflow, sonic-pi://reference/{synths,effects,samples,scales-and-chords}
and sonic-pi://examples/<category>/<name>.
Every result has structured content. A failure comes back as an isError result with a stable
error.code, such as SONIC_PI_NOT_RUNNING, STALE_CREDENTIALS, RUBY_SYNTAX_ERROR or
POLICY_VIOLATION. See src/error.rs for the full list.
Example sonic_pi_run results
{"status":"completed","confirmed":true,"request_id":"sonic-pi-mcp-4399-3","elapsed_ms":481,
"message":"Sonic Pi evaluated the code. Any live_loops are now playing; ..."}{"status":"error","confirmed":true,"request_id":"sonic-pi-mcp-5111-5","elapsed_ms":152,
"error":{"code":"RUBY_SYNTAX_ERROR","line":2,"message":"Syntax Error Sonic Pi couldn't read your code",
"details":["SyntaxError: unexpected local variable or method, expecting end-of-input",
"source: play 62 amp: 0.3 do"]}}(Both are real outputs from Sonic Pi 5.0.)
Example prompts for Claude Code
"Check that Sonic Pi is connected, then play a short C major arpeggio on the piano."
"Start a 120 BPM deep house groove with separate live_loops for kick, hats, bass and chords."
"Make the bass line darker and add a filter sweep, but don't stop the drums."
"Compose 2 minutes of slowly evolving ambient focus music with a generative melody."
"Something stopped playing. Check the Sonic Pi logs and fix the error."
"Stop everything."
More in examples/.
CLI
sonic-pi-mcp serve # MCP over stdio (what clients launch)
sonic-pi-mcp doctor [--json] # exit code 1 if any check fails
sonic-pi-mcp status [--json]
sonic-pi-mcp discover [--json]
sonic-pi-mcp version [--json]Flag | Env | Default |
|
|
|
|
|
|
|
| auto-discovered |
| off (Unix scans | |
|
| 3000 |
|
| 262144 (max 4 MiB; code above ~55 KB is sent via a file) |
|
| off |
|
| platform data dir (compositions, recordings) |
|
|
|
Invalid configuration causes the server to exit with code 2 and an error that starts CONFIG_INVALID.
Security
Sonic Pi code is arbitrary Ruby running with your user's privileges, and Sonic Pi has no sandbox.
This server blocks obvious host-access APIs by default (system, backticks, File, require,
eval, sockets, …). This is a guard rail to catch an agent's mistakes. It is not a sandbox,
and a determined author can get around it. The real safety boundary is your MCP client's approval
of each tool call. Read docs/SECURITY.md before you enable auto-approve or
--allow-unrestricted-ruby.
Documentation
Research · Architecture · Decisions · Compatibility · Testing · Troubleshooting · Security · Reliability evidence
Contributing
See CONTRIBUTING.md. Security issues: docs/SECURITY.md.
License
Licensed under either of Apache License 2.0 or MIT license, at your option.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Generate full songs with vocals, instrumentals and sound effects from text. One server for Suno, Google Lyria, Mureka, MiniMax, ACE-Step, YuE and ElevenLabs. Your agent can quote the credit cost before generating, start a song, wait for it to finish and return download links. Sign in with OAuth; optional daily credit caps; retries never charge twice.
Audio for your agent: transcribe, speak, translate, summarise, plus sound effects and music.
Score video, make music as an agent: 100+ AI instruments play your MIDI, audio, stems, Logic/Ableton
Autonomous music production for AI agents with MIDI generation, QC and provenance.
Related MCP Servers
- FlicenseCqualityDmaintenanceEnables AI agents to generate, manipulate, and perform algorithmic music using Strudel.cc live coding environment. Provides 46+ tools for pattern generation across multiple genres, music theory operations, real-time audio analysis, and AI-powered composition.50-
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to create and edit Strudel music code, render offline WAV audio, and obtain structured hearing reports with waveform, spectrogram, BPM, and onset analysis.AGPL 3.0
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to connect to Ableton Live, inspect the arrangement, compose and edit MIDI, manage tracks/scenes/clips, insert and tweak devices, and control the mixer.MIT
- AlicenseNot gradedqualityBmaintenanceEnables coding agents to compose, edit and run multi-agent pipelines represented as songs, where channels are agents, notes are agent calls, and mixer buses carry each agent's output to the next. Lets agents create and modify arrangements, validate and render projects headlessly, play them back live in a studio window, and export the result as WAV or MP3, with every change undoable and cached takes replayed for free.43 npmMIT