SuperCollider Headless MCP Server
# SuperCollider Headless MCP Server
[](https://www.npmjs.com/package/supercollider-headless-mcp)
[](https://opensource.org/licenses/MIT)
[](https://nodejs.org/)
[](https://github.com/dheerajstvpm/supercollider-headless-mcp)
> β οΈ **Active Development** β This project is under active development. APIs may change between versions. Use in production at your own risk.
An **Model Context Protocol (MCP) server** that gives any MCP-compatible LLM unrestricted access to **SuperCollider** audio synthesis (`scsynth`) and algorithmic composition (`sclang`) β **zero manual installation required**.
## π One-Command Installation
```bash
npx -y supercollider-headless-mcp
```
That's it. The server automatically:
1. Downloads the latest official SuperCollider release for your platform (Windows/macOS/Linux)
2. Extracts it to `~/.supercollider-mcp/runtime/` (no admin rights needed)
3. Prunes IDE/GUI bloat, keeping only `sclang`, `scsynth`, `SCClassLibrary`, `plugins`, and runtime libraries
4. Boots `scsynth` in headless mode with a versatile starter SynthDef library
5. Exposes 6 MCP tools + 2 reusable prompts for audio synthesis and algorithmic composition
## π¦ Supported MCP Clients
| Client | Configuration |
|--------|---------------|
| **Claude Code** | `claude mcp add supercollider npx -y supercollider-headless-mcp` |
| **VS Code (Copilot)** | Add to `.vscode/mcp.json` (see below) |
| **Cursor** | Settings β MCP β Add server |
| **Cline** | Settings β MCP Servers β Add |
| **Windsurf** | Settings β MCP β Add server |
### VS Code / Copilot Configuration (`.vscode/mcp.json`)
```json
{
"servers": {
"supercollider": {
"command": "npx",
"args": ["-y", "supercollider-headless-mcp"],
"env": {}
}
}
}
```
### Cursor Configuration (`.cursor/mcp.json`)
```json
{
"mcpServers": {
"supercollider": {
"command": "npx",
"args": ["-y", "supercollider-headless-mcp"]
}
}
}
```
### Cline Configuration (`.cline/mcp_settings.json`)
```json
{
"mcpServers": {
"supercollider": {
"command": "npx",
"args": ["-y", "supercollider-headless-mcp"]
}
}
}
```
## π Available Tools
### 1. `setup_engine`
Provision SuperCollider runtime, boot `scsynth`, load SynthDef library.
```typescript
await mcp.callTool("setup_engine", {
forceReprovision: false, // Force re-download
sampleRate: 48000, // Sample rate
blockSize: 64, // Block size
device: "default" // Audio device (optional)
});
```
**Returns:** Runtime paths, version, sample rate, audio device, block size, loaded SynthDefs.
---
### 2. `play_code`
Evaluate arbitrary `sclang` code β SynthDefs, Pdefs, Tdefs, Ndefs, patterns, buffers, microtonal scales.
```typescript
await mcp.callTool("play_code", {
code: `
s.sync;
Pdef(\\ambient, Pbind(
\\instrument, \\warmStrings,
\\degree, Pseq([0, 2, 4, 5, 7, 9, 11, 12], inf),
\\dur, 0.5,
\\amp, 0.3
)).play;
`,
timeout: 60000
});
```
**Returns:** Console output, errors, return value. Automatically wraps code with `s.sync` before/after for safe SynthDef compilation.
---
### 3. `stop_all`
Immediately silence all sound (`CmdPeriod.run`) while keeping `scsynth` booted.
```typescript
await mcp.callTool("stop_all", {});
```
---
### 4. `list_and_set_audio_device`
List available output devices (`ServerOptions.outDevices`). Optionally switch device and reboot `scsynth`.
```typescript
// List devices
await mcp.callTool("list_and_set_audio_device", {});
// Switch device
await mcp.callTool("list_and_set_audio_device", { setDevice: "Headphones" });
```
---
### 5. `export_wav`
Render a self-contained pattern/score to a 24-bit `.wav` file using Non-Real-Time mode (`Score.recordNRT`).
```typescript
await mcp.callTool("export_wav", {
code: `
Pdef(\\render, Pbind(
\\instrument, \\warmStrings,
\\degree, Pseq([0, 2, 4, 5, 7, 9, 11, 12], 2),
\\dur, 0.5,
\\amp, 0.4
)).play;
`,
outputPath: "./output/ambient-track.wav",
duration: 30,
sampleRate: 48000
});
```
---
### 6. `get_status`
Get server boot state, CPU load, active synths, loaded SynthDefs, audio device info.
```typescript
await mcp.callTool("get_status", {});
```
---
## π΅ Built-in SynthDef Library
| SynthDef | Description | Key Parameters |
|----------|-------------|----------------|
| `\warmStrings` | Rich analog-style pads | freq, amp, gate, attack, decay, sustain, release, cutoff, res, pan |
| `\soloFlute` | Expressive flute with vibrato/breath | freq, amp, gate, vibratoRate, vibratoDepth, breathiness, pan |
| `\subBass` | Deep sub-bass with drive | freq, amp, gate, attack, decay, sustain, release, drive, pan |
| `\pluckSynth` | Karplus-Strong plucked strings | freq, amp, gate, attack, decay, coef, pan |
| `\kick` | Punchy kick drum | freq, amp, gate, attack, decay, pitchDecay, drive, pan |
| `\snare` | Snare with tone/noise mix | freq, amp, gate, attack, decay, tone, noiseMix, pan |
| `\hihat` | Closed/open hi-hat | freq, amp, gate, attack, decay, open, pan |
| `\mcpLimiter` | Master safety limiter (always active) | threshold, dur |
---
## π§ Reusable Prompts
### `compose_track`
Generate complete multi-track compositions.
```typescript
await mcp.getPrompt("compose_track", {
style: "ambient", // ambient, techno, experimental, etc.
duration: "120", // seconds
bpm: "90", // tempo
key: "C major", // musical key
instruments: "warmStrings, soloFlute, subBass, pluckSynth"
});
```
### `design_synth`
Design custom SynthDefs with best practices.
```typescript
await mcp.getPrompt("design_synth", {
type: "pad", // pad, lead, bass, drum, texture, etc.
features: "subtractive, filter modulation",
controls: "freq, amp, gate, cutoff, res, attack, decay, sustain, release",
polyphony: "8"
});
```
---
## π‘ Example Prompts for LLMs
### Simple Ambient Pad
> "Create a slow-evolving ambient pad using the warmStrings synth, with notes from a C major scale, 8-second attack/release, and subtle filter modulation."
### Generative Drum Pattern
> "Make a generative drum pattern using kick, snare, and hihat with Pbrown for kick placement, Pseq for snare on 2 and 4, and Pwhite for hi-hat density. 120 BPM."
### Microtonal Composition
> "Compose a piece using 19-EDO tuning (19 equal divisions of the octave) with the soloFlute synth. Use Scale.new to define the tuning."
### NRT Render to WAV
> "Render a 60-second ambient track to output.wav at 48kHz/24-bit using Score.recordNRT. Use Pdef patterns with warmStrings and subBass."
### Custom SynthDef Design
> "Design a FM synthesis bass SynthDef with 2 operators, configurable ratio, index, and ADSR envelope. Include example Pbind usage."
---
## π§ Advanced Usage
### Environment Variables
| Variable | Description |
|----------|-------------|
| `SUPERCOLLIDER_PATH` | Override auto-detected sclang path |
### Runtime Location
Managed runtime: `~/.supercollider-mcp/runtime/supercollider-{platform}-{arch}/`
### Manual Provisioning
```bash
# Force re-download latest SuperCollider
npx -y supercollider-headless-mcp --force-reprovision
```
---
## π Architecture
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MCP Client (LLM) β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β JSON-RPC over stdio
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β supercollider-headless-mcp Server β
β βββββββββββββββ ββββββββββββββββ ββββββββββββββββββββββ β
β β Provisioner β β SC Session β β MCP Tools/Prompts β β
β β (download, ββββ (sclang + ββββ (setup, play, β β
β β extract, β β scsynth, β β stop, device, β β
β β prune) β β SynthDefs) β β export, status) β β
β βββββββββββββββ ββββββββββββββββ ββββββββββββββββββββββ β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β spawn
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SuperCollider Runtime β
β ββββββββββββ ββββββββββββ ββββββββββββββββββββββββββββ β
β β sclang ββββ scsynth β β SCClassLibrary + plugins β β
β β (lang) β β (audio) β β (pruned, headless) β β
β ββββββββββββ ββββββββββββ ββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
---
## π Requirements
- **Node.js** β₯ 18
- **No SuperCollider installation needed** (auto-provisioned)
---
## π Troubleshooting
### "sclang not found" / Provisioning fails
```bash
# Set custom path if auto-detection fails
export SUPERCOLLIDER_PATH="/path/to/sclang"
npx -y supercollider-headless-mcp
```
### Audio device issues
```typescript
// List devices first
await mcp.callTool("list_and_set_audio_device", {});
// Then set specific device
await mcp.callTool("list_and_set_audio_device", { setDevice: "Your Device Name" });
```
### Permission errors (Windows)
Run terminal as Administrator for first run, or ensure `~/.supercollider-mcp` is writable.
### macOS Gatekeeper
If extraction fails: `xattr -d com.apple.quarantine ~/.supercollider-mcp/runtime/...`
---
## π License
MIT License β see [LICENSE](LICENSE) for details.
---
## π Acknowledgments
- [SuperCollider](https://supercollider.github.io/) β The amazing audio synthesis engine
- [Model Context Protocol](https://modelcontextprotocol.io/) β For the open protocol
- [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk) β TypeScript SDK
---
## π Links
- **npm**: https://www.npmjs.com/package/supercollider-headless-mcp
- **GitHub**: https://github.com/dheerajstvpm/supercollider-headless-mcp
- **Issues**: https://github.com/dheerajstvpm/supercollider-headless-mcp/issuesTDQS
Scored across 6 tools
Each tool has a distinct primary purpose: setup, code evaluation, global stop, device management, NRT export, and status reporting. Minor overlap existsβsetup_engine loads SynthDefs which play_code can also do, and get_status reports audio device info that list_and_set_audio_device also exposesβbut descriptions clarify the boundaries.
All tools use snake_case with a verb-first pattern (setup_engine, play_code, stop_all, export_wav, get_status), which is predictable. list_and_set_audio_device is a longer compound verb but still follows the convention; stop_all lacks an explicit object but remains readable.
Six tools cover the core lifecycle of a headless SuperCollider runtime without redundancy. The set is tightly scoped and each tool earns its place.
The surface covers setup, arbitrary code execution, global silence, device switching, WAV export, and statusβsufficient for most workflows. Minor gaps remain, such as no explicit engine shutdown/quit or per-node stop, though play_code can work around these via sclang.