sonic-pi-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-pi-mcp play a C major scale with synth :blade"
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-pi-mcp
sonic-pi-mcp is a Python MCP server that lets an MCP client control a local
Sonic Pi runtime over the standard stdio transport.
It starts Sonic Pi's Ruby daemon, sends OSC messages to the Spider runtime, runs Sonic Pi code, stops jobs, reads runtime events/logs, and searches the local Sonic Pi docs/samples/synthdefs.
Requirements
Python 3.11+
A local Sonic Pi installation or checkout.
The Sonic Pi root directory must contain:
app/server/ruby/bin/daemon.rbapp/server/ruby/bin/spider-server.rbusually
etc/doc,etc/samples, andetc/synthdefs
No machine-specific path is baked into this package. Set SONIC_PI_ROOT in the
MCP client environment unless you pass root_path to sonic_start.
Related MCP server: SuperCollider OSC MCP
Install
From PyPI:
pip install sonic-pi-mcpFrom a local checkout:
pip install .Build a wheel/sdist:
python -m buildThen install the wheel on another machine:
pip install dist/sonic_pi_mcp-*.whlThe wheel only contains the Python package under src/sonic_pi_mcp. Generated
runtime files, exported audio, examples, tests, and local scripts are excluded
from distribution.
Configuration
Required in most deployments:
SONIC_PI_ROOT=<path to the Sonic Pi root directory>Useful optional variables:
SONIC_PI_MCP_RUNTIME_DIR=<writable directory for temporary run_file buffers>
SONIC_PI_MCP_STARTUP_TIMEOUT=60
SONIC_PI_MCP_KEEPALIVE_INTERVAL=4
SONIC_PI_MCP_EVENT_BUFFER_SIZE=5000
SONIC_PI_MCP_DEFAULT_COLLECT_MS=1500
SONIC_PI_HOME=<custom Sonic Pi user-home root for logs, if needed>SONIC_PI_MCP_RUNTIME_DIR is used when code is too large for Sonic Pi's OSC
packet size and must be submitted with run_file. If it is not set, the server
uses a per-user cache directory such as %LOCALAPPDATA%\sonic-pi-mcp on
Windows, ~/Library/Caches/sonic-pi-mcp on macOS, or
${XDG_CACHE_HOME:-~/.cache}/sonic-pi-mcp on Linux.
PowerShell example without hard-coding a drive:
$env:SONIC_PI_ROOT = Join-Path $env:ProgramFiles 'Sonic Pi'
$env:SONIC_PI_MCP_RUNTIME_DIR = Join-Path $env:LOCALAPPDATA 'sonic-pi-mcp'
sonic-pi-mcpPOSIX shell example:
export SONIC_PI_ROOT="$HOME/apps/sonic-pi"
export SONIC_PI_MCP_RUNTIME_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/sonic-pi-mcp"
sonic-pi-mcpMCP Client Setup
This package is a stdio MCP server. Configure clients to run the installed
console command sonic-pi-mcp.
Generic MCP JSON shape:
{
"mcpServers": {
"sonic-pi": {
"command": "sonic-pi-mcp",
"args": [],
"env": {
"SONIC_PI_ROOT": "<path to Sonic Pi root>",
"SONIC_PI_MCP_RUNTIME_DIR": "<writable runtime directory>"
}
}
}
}If your client does not inherit shell environment variables, put the variables in the client config. Avoid relying on the terminal profile of the user who installed the package.
If startup fails, the error includes preflight results, recent daemon output, Sonic Pi log tails, and likely fixes for common path, permission, and audio backend issues.
Run Manually
python -m sonic_pi_mcpor:
sonic-pi-mcpBoth commands run the same stdio MCP server. They do not open an HTTP port.
MCP Tools
sonic_start(root_path?, no_inputs?)sonic_status()sonic_preflight(root_path?)sonic_run_code(code, buffer_name?, collect_ms?)sonic_play_file(path, buffer_name?, collect_ms?)sonic_start_recording(collect_ms?)sonic_stop_recording(collect_ms?)sonic_save_recording(output_path, collect_ms?, wait_timeout?)sonic_delete_recording(collect_ms?)sonic_record_file(path, output_path, duration_seconds, bit_depth?, buffer_name?, root_path?, no_inputs?, overwrite?, shutdown_after?, save_timeout?)sonic_stop(collect_ms?)sonic_shutdown()sonic_read_events(since?, limit?)sonic_get_logs(source?, tail?)sonic_send_cue(path, args?)sonic_search_docs(query, limit?, root_path?)sonic_list_samples(limit?, root_path?)sonic_list_synths(limit?, root_path?)sonic_list_fx(limit?, root_path?)
Suggested Agent Workflow
Call
sonic_preflight()when setting up a new machine or after a boot failure.Call
sonic_start(no_inputs=true)unless the user needs audio input.Call
sonic_status()and confirmstateisready.Use
sonic_search_docs,sonic_list_samples,sonic_list_synths, andsonic_list_fxto stay within the user's installed Sonic Pi version.Send music with
sonic_run_code(code, buffer_name, collect_ms)or run a local.rbfile withsonic_play_file(path, buffer_name, collect_ms).Export a fixed-duration WAV with
sonic_record_file(path, output_path, duration_seconds, bit_depth=24)when the user asks for a rendered file.Inspect returned events for
syntax_error,runtime_error, or missingDefining fn :live_loop_...messages.Call
sonic_stop()before replacing a long-running composition.Call
sonic_shutdown()when the session is no longer needed.
Security
sonic_run_code executes local Sonic Pi code through the same token-protected
Spider API used by the Sonic Pi GUI. Treat access to this MCP server as local
code execution and local audio-device control.
License
MIT License. You may use, copy, modify, publish, distribute, sublicense, and sell copies of this package, provided the license text is included.
Packaging Notes
The package is intentionally path-neutral:
No repository-local absolute path is embedded.
SONIC_PI_ROOTor theroot_pathtool argument identifies Sonic Pi.SONIC_PI_MCP_RUNTIME_DIRcontrols where temporary large-buffer files are written.Build configuration excludes generated files such as
.runtime/,exports/, examples, tests, and local playback/export scripts.
Available Tools
19 toolssonic_delete_recordingC
Delete Sonic Pi's temporary recording.
Inputs: collect_ms. Returns: object
sonic_get_logsB
Read Sonic Pi log tails. Source can be gui, spider, daemon, supersonic, or scsynth.
Inputs: tail, source. Returns: object
sonic_list_fxB
List bundled Sonic Pi FX names.
Inputs: limit, root_path. Returns: result
sonic_list_samplesC
List bundled Sonic Pi sample names.
Inputs: limit, root_path. Returns: result
sonic_list_synthsB
List bundled Sonic Pi synth names.
Inputs: limit, root_path. Returns: result
sonic_play_fileB
Run a local Sonic Pi .rb file in the managed runtime.
Inputs: path (required), collect_ms, buffer_name. Returns: object
sonic_preflightB
Check whether the local environment looks ready to start Sonic Pi.
Inputs: root_path. Returns: object
sonic_read_eventsC
Read buffered Sonic Pi events after an optional sequence number.
Inputs: limit, since. Returns: object
sonic_record_fileC
Start Sonic Pi if needed, record a .rb file for a fixed duration, and save WAV output.
Inputs: path (required), output_path (required), duration_seconds (required), bit_depth, +6 more. Returns: object
sonic_run_codeC
Run Sonic Pi code in the managed runtime and return newly collected events.
Inputs: code (required), collect_ms, buffer_name. Returns: object
sonic_save_recordingC
Save the current Sonic Pi recording to a WAV file.
Inputs: output_path (required), collect_ms, wait_timeout. Returns: object
sonic_search_docsC
Search local Sonic Pi markdown documentation and snippets.
Inputs: query (required), limit, root_path. Returns: result
sonic_send_cueC
Send an external OSC cue into Sonic Pi's cue server.
Inputs: path (required), args. Returns: object
sonic_shutdownA
Shut down the managed Sonic Pi runtime.
Inputs: no named parameters. Returns: object
sonic_startC
Start a managed local Sonic Pi runtime.
Inputs: no_inputs, root_path. Returns: object
sonic_start_recordingC
Start Sonic Pi's built-in WAV recorder.
Inputs: collect_ms. Returns: object
sonic_statusB
Return current Sonic Pi session status.
Inputs: no named parameters. Returns: object
sonic_stopC
Stop all running Sonic Pi jobs.
Inputs: collect_ms. Returns: object
sonic_stop_recordingC
Stop Sonic Pi's built-in WAV recorder.
Inputs: collect_ms. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 19 tools
Most tools have a clear, distinct purpose, such as runtime lifecycle versus recording versus code execution. The only mild overlap is between sonic_shutdown and sonic_stop, which could confuse an agent about whether to stop jobs or shut down the entire runtime.
All tools follow the same sonic_ prefix with snake_case verb_noun or verb naming. The pattern is highly predictable and consistent across lifecycle, recording, and inspection tools.
With 19 tools, the set is on the heavier side but well-scoped for the domain. The number reflects the broad functionality (runtime, recording, code execution, and resource listing) without being excessive or redundant.
The tool surface covers the main workflows: starting and stopping the runtime, executing code, recording audio, and inspecting bundled resources. Minor gaps exist, such as no per-job management or a dedicated tool to list running jobs, but these are not critical for typical usage.
Maintenance
Related MCP Connectors
OSC ↔ MIDI bridge for synthesizers and DAWs, with the SyntHub catalogue. A MIDI MCP and OSC MCP.
Search, write, check, export and share the patches, skills and files in your Minima library.
Build, run, inspect, and continue AgentScript workflows on connected Super Chrome and Mac clients.
Control Unreal Engine to browse assets, import content, and manage levels and sequences. Automate…
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
- AlicenseBqualityBmaintenanceEnables AI assistants to control SuperCollider audio synthesis via OSC, supporting melody, rhythm, and soundscape generation through MCP tools.1328MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI-powered music generation and control of Sonic Pi through natural language requests using OSC.-
- FlicenseNot gradedqualityDmaintenanceEnables agentic interaction with vanilla Pure Data by providing tools for live patch creation, inspection, and manipulation via an MCP server that synchronizes with a Pd bridge patch.5-