Sone MCP Server
by Bayern99
README.md
# Sone
English | [简体中文](./README.zh-CN.md)
Sone connects an AI agent to a live SuperCollider session over MCP. It consists of a zero-dependency Quark that runs inside `sclang` and a standalone TypeScript MCP server.
You can attach Sone to the `sclang` process already running in `scide`, `vscode-supercollider`, `scnvim`, or `scel`. If no SuperCollider editor is open, Sone starts a headless `sclang` process on demand.
## Architecture
### SuperCollider Quark
The Quark in `providers/ScAgent/` uses only the SuperCollider standard library (`OSCdef`, `String.parseJSON`, `openUDPPort`, `ServerTree`, `Sanitize`, `Limiter`, `JITLib`, `History`, and `BufWr`). It requires no external Quarks and no `LanguageServer.quark`.
`ScAgentSafety` mounts a tail synth on `ServerTree` with `Sanitize.ar`, `CheckBadValues`, `LeakDC`, and `Limiter.ar` set to `0.92`. This chain removes NaN values, infinities, DC offset, and overloads from the hardware output, and remounts after `CmdPeriod` or `s.freeAll`.
`ScAgentCapture` records the master bus and up to 8 active `Ndef` buses into 16-second `BufWr` ring buffers. Capturing the recent window writes frame-aligned `mix.wav` and per-voice stem WAV files in under 100 ms.
`ScAgentPalette` provides an opt-in set of `SynthDef` instruments (`\scWarmSub`, `\scPluck`, `\scModal`, `\scFmPerc`, `\scGrain`, `\scKick`, `\scSnare`, `\scHat`) with `ControlSpec` metadata and stereo send buses (`\fxVerb`, `\fxDelay`, `\fxGlue`).
### MCP server and tools
The server and UI stay under 1,500 lines of TypeScript with 5 runtime dependencies and no `vscode`, React, or Tailwind imports. The model sees 4 tools:
1. `sc_inspect` reads active `Ndef`, `Pdef`, and `Tdef` proxies, per-voice 10 Hz audio metrics (`peakDb`, `rmsDb`, `centroidHz`, `flatness`, `onsetsPerSec`), `ControlSpec` ranges, `SynthDescLib` entries, `Scale` and `Tuning` directories, loaded buffers, and `History`.
2. `sc_play` validates UGen graphs when `dryRun` is `true`, or evaluates quantized `JITLib` code against the running server. Before evaluation, it saves live heap snapshots of existing proxies for rollback.
3. `sc_control` adjusts proxy parameters with `set` or `xset`, switches named scenes on bar boundaries, changes tempo, stops proxies, runs global or per-voice undo, and triggers `CmdPeriod` panic.
4. `sc_capture` writes aligned `mix.wav` and stem WAV files from the recent ring buffer or the next bars for tools such as [Agent-Listening-CLI](https://github.com/Bayern99/Agent-Listening-CLI) and `gemini-api`. It also renders a `Pdef` offline with `Pattern.asScore` or exports the live session as standalone SuperCollider code.
### Human locks and UI strip
The Node process stores the live or read-only mode and the list of locked proxies outside `sclang`. Only the app-only tool `sc_ui_authority` can change those values, and the model cannot see or call it.
A single-file MCP App in `ui/live-strip.ts` (under 200 lines) renders active proxies, audio metrics, lock buttons, undo buttons, and a panic button at `ui://sc-live/strip.html`.
When `sc_play` runs while voices are locked, Sone snapshots the locked proxies before evaluation and checks their state after evaluation. If evaluated code alters, frees, or pauses a locked voice, Sone restores the snapshot and returns `LOCK_VIOLATION`.
### Skills and workspace files
Sone serves `skills/sc-live/SKILL.md` through the SEP-2640 skills extension (`skills/list`, `skills/get`, and `skill://sc-live/SKILL.md`) and `plugin.json`. Audio captures write to a rotating temporary directory under `os.tmpdir()`. Sone writes no files to the user workspace.
## Quick start
Sone requires Node.js 20 or later and SuperCollider (tested on 3.14.1).
```bash
npm install
npm run compile
# Start the stdio MCP server. It attaches to a running ScAgent or spawns headless sclang.
node out/bin/sc-mcp.js --stdio
# Start the loopback Streamable HTTP server instead.
node out/bin/sc-mcp.js --http --port 41890
# Print manual ScAgent.quark setup steps without changing your global SuperCollider config.
node out/bin/sc-mcp.js install-quark --dry-run
```
### Attaching to an editor
1. Add `providers/ScAgent` to your SuperCollider `includePaths`, or evaluate `Quarks.install("/path/to/sone/providers/ScAgent");`.
2. Run `ScAgent.start;` inside `scide`, `vscode-supercollider`, `scnvim`, or `scel`.
3. Start Sone from your agent client. Sone reads `~/.sc-live/active.json` and attaches to that `sclang` process, so editor evaluation and `sc_play` share the same `Ndef` proxies, `TempoClock`, and `History`.
## Verification
```bash
npm run typecheck # TypeScript check for server and UI
npm run lint # Zero-warning ESLint and import boundary checks
npm run compile # Compile TypeScript and bundle the single-file Live Strip HTML
npm test # Budget invariants, OSC, MCP protocol, SEP-2640, and Live Strip UI tests
npm run test:native # Real sclang and scsynth adversarial tests and live musical benchmarks
```
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues