Sonic Pi MCP
@abhishekjairath
Model Context Protocol (MCP) server for controlling Sonic Pi through AI assistants
Overview
What is Sonic Pi MCP?
A Model Context Protocol server that allows AI assistants (like Claude and Cursor) to interact with Sonic Pi through OSC messages, enabling programmatic music creation and control.
How to use Sonic Pi MCP?
Install Bun and ensure Sonic Pi v4+ is running. Add the provided live_loop :code_runner code to a Sonic Pi buffer and execute it. Configure your MCP client (e.g., Cursor or Claude Desktop) with the command bunx sonic-pi-mcp and stdio transport. Then use the play_note and run_code tools to control Sonic Pi.
Key features of Sonic Pi MCP
- Play individual notes with customizable synth parameters
- Execute arbitrary Sonic Pi code from AI assistants
- Works with any MCP-compatible client (Claude Desktop, Cursor, etc.)
- Supports OSC communication on port 4560
- Simple JSON-based tool parameters
Use cases of Sonic Pi MCP
- Compose melodies and harmonies through natural language prompts
- Generate complex rhythmic patterns programmatically
- Live-code music using AI assistance in real time
- Create and test Sonic Pi code without manual editing
FAQ from Sonic Pi MCP
What prerequisites are needed?
Bun runtime and Sonic Pi v4.0 or higher are required.
How do I set up Sonic Pi to work with the server?
Add the provided live_loop :code_runner code to a Sonic Pi buffer, run it, and ensure Sonic Pi is listening on port 4560.
What transport does the server use?
It uses stdio transport with OSC messages sent to Sonic Pi.
Why is there no sound?
Ensure Sonic Pi is running, the OSC handler code is active, and no other application is blocking port 4560.
How do I debug code execution errors?
Check the Sonic Pi log window for errors, verify your Sonic Pi code syntax, and make sure all required synths and samples are available.