Sonic Pi MCP
The Sonic Pi MCP server enables LLM-driven live coding and music performance by controlling Sonic Pi via OSC. Key capabilities include:
Queue/run musical segments (
queue_segment/run_code): Send Sonic Pi code (e.g.live_loops,use_bpm) for execution, with support for smooth crossfades between segments using the included queue runnerPlay individual notes (
play_note): Trigger a single MIDI note (0–127) with optional synth (e.g.:saw,:prophet), filter cutoff, and sustain durationStop all music (
stop_all): Perform a hard stop of all active Sonic Pi jobs via OSCAccess built-in resources: Read DJ session craft, musical vocabulary, and tool usage guidance through the MCP client's resource system
Get performance prompts (
next_performance_segment): Structure and frame upcoming musical sections for longer setsCustomize OSC configuration: Configure host, port, and paths via environment variables for different Sonic Pi setups
Supports playing notes using MIDI note numbers (0-127), enabling programmatic music composition through standard MIDI note representations.
Required as a prerequisite for running the MCP server, which enables communication between AI tools and Sonic Pi.
Allows execution of Ruby code in Sonic Pi, enabling music creation and control through Ruby's syntax and Sonic Pi's musical capabilities.
Click on "Install 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 MCPplay a C major arpeggio with piano synth"
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
Model Context Protocol (MCP) server for Sonic Pi. Describe music in natural language in your LLM client; the model generates Sonic Pi code and this server sends it over OSC. Use the included queue runner in Sonic Pi for crossfades between segments.
Features
queue_segment— send the next full musical segment (namedlive_loops,use_bpm, etc.).run_code— same asqueue_segment(compatibility).stop_all— hard stop via OSC (/stop-all-jobs), like Sonic Pi’s Stop.play_note— quick test note.Resource — DJ session craft, vocabulary, and tool usage (read from the MCP client).
Prompt
next_performance_segment— help frame the next block for longer sets.Env —
OSC_HOST,OSC_PORT,OSC_CODE_PATH,OSC_STOP_ALL_PATH.
Related MCP server: StreamerSongList MCP Server
Prerequisites
Sonic Pi v4.x
Node.js 18+ (
npx/node)An MCP-capable client (Cursor, Claude Desktop, VS Code with MCP, etc.)
Optional: Bun for local development (bun run dev).
One-time Sonic Pi setup (queue runner)
Open Sonic Pi.
Copy sonic-pi-queue.rb into a buffer.
Press Run and leave it running.
The buffer listens on the default OSC port and crossfades between segments sent by the MCP.
Install the MCP server
npx -y sonic-pi-mcpPoint your client at this command over stdio (see below).
Cursor
Use ~/.cursor/mcp.json and/or .cursor/mcp.json in a project:
{
"mcpServers": {
"sonic_pi_mcp": {
"command": "npx",
"args": ["-y", "sonic-pi-mcp"]
}
}
}Local clone (after npm install or bun install and bun run build):
{
"mcpServers": {
"sonic_pi_mcp": {
"command": "node",
"args": ["/absolute/path/to/sonic-pi-mcp/bin/cli.mjs"]
}
}
}Bun without building — some clients ignore cwd; use an absolute path to src/server.ts, or use the launcher:
{
"mcpServers": {
"sonic_pi_mcp": {
"command": "/absolute/path/to/sonic-pi-mcp/bin/mcp-dev.sh",
"args": []
}
}
}Run chmod +x bin/mcp-dev.sh once. The script changes into the repo and runs bun run src/server.ts.
Claude Desktop
~/Library/Application Support/Claude/claude_desktop_config.json (paths differ on Windows):
{
"mcpServers": {
"sonic_pi_mcp": {
"command": "npx",
"args": ["-y", "sonic-pi-mcp"]
}
}
}For a local clone, prefer bin/mcp-dev.sh (see above) if you see Module not found "src/server.ts" or spawn bunx ENOENT. Remove and re-add the MCP in the app if an old definition is cached.
VS Code
Configure your MCP extension to run npx with -y and sonic-pi-mcp, stdio transport, per the extension’s docs.
Environment variables
Variable | Default | Meaning |
|
| Sonic Pi host |
|
| Sonic Pi OSC port |
|
| OSC path for code (must match your Sonic Pi buffer) |
|
| Hard stop path |
Allow incoming OSC in Sonic Pi if you connect from another machine; set OSC_HOST accordingly.
Development
git clone https://github.com/abhishekjairath/sonic-pi-mcp.git
cd sonic-pi-mcp
bun install # or npm install
bun run build
bun run devOSC smoke test (Sonic Pi + runner running):
bun run testMCP Inspector
npx @modelcontextprotocol/inspectorUse node with argument bin/cli.mjs and this directory as the working directory (after bun run build).
Troubleshooting
No sound — Sonic Pi open? Queue buffer running? Port 4560 reachable?
Nothing happens — OSC enabled in Sonic Pi;
OSC_HOST/OSC_PORTmatch.Layers pile up — Use
queue_segmentwith namedlive_loops; usestop_allonly for a full reset.Module not found "src/server.ts"(Claude) — Usebin/mcp-dev.shascommandwith emptyargs, or absolute paths; don’t rely oncwdalone.resources/list/prompts/list→ Method not found — You’re on an older build that only exposed tools. Reinstall/restart the MCP from this repo or npm so resources and prompts are registered.Ruby errors in Sonic Pi log — The generated code failed to parse or run; fix the snippet (brackets, samples, syntax) and send again. The queue runner prints a code snippet on failure.
License
MIT — see LICENSE.
Available Tools
2 toolsplay_noteD
| Name | Required | Description | Default |
|---|---|---|---|
| note | Yes | MIDI note number (0-127) | |
| synth | No | Synth to use (e.g. :saw, :beep, :prophet) | |
| sustain | No | Note duration in seconds | |
| cutoff | No | Filter cutoff frequency |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Tool has no description.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tool has no description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Tool has no description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Tool has no description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Tool has no description.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Tool has no description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
run_codeD
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Sonic Pi code to execute |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Tool has no description.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tool has no description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Tool has no description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Tool has no description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Tool has no description.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Tool has no description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
2 tool updates
- First observed
play_note - First observed
run_code
TDQS
The two tools have clearly distinct purposes: play_note handles individual note playback, while run_code executes code, likely for more complex Sonic Pi scripts. There is no overlap or ambiguity between these functions.
Both tools follow a consistent verb_noun pattern (play_note, run_code) with clear, descriptive names that align well with their inferred functions. No deviations or mixed conventions are present.
With only two tools, this server feels too thin for a Sonic Pi integration, which typically involves managing sounds, loops, effects, and code execution. The scope is significantly under-covered, limiting agent capabilities.
The tool surface is severely incomplete for Sonic Pi's domain, lacking essential operations like stopping playback, adjusting parameters, managing samples, or handling live coding workflows. Agents will face dead ends in typical music programming tasks.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server for Producer/Riffusion AI music generation
Generate AI music via the Lacuna Music API from MCP clients like Claude Desktop & Code.
A Model Context Protocol server for Wix AI tools
Related MCP Servers
- AlicenseCqualityBmaintenanceA Model Context Protocol server that enables real-time interaction with Ableton Live, allowing AI assistants to control song creation, track management, clip operations, and audio recording workflows.232891MIT
- AlicenseAqualityFmaintenanceA Model Context Protocol server that enables AI assistants like Claude to manage song requests, monitor queues, and interact with streaming platforms' song request systems.6192MIT
- AlicenseAqualityDmaintenanceMCP server that connects Claude Code to Sonic Pi for AI-assisted beat making, enabling live code execution and pattern management.21MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI-powered music generation and control of Sonic Pi through natural language requests using OSC.-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/abhishekjairath/sonic-pi-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server