supercollider-mcp 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. supercollider_mcp-0.2.0/.gitignore +42 -0
  2. supercollider_mcp-0.2.0/CHANGELOG.md +61 -0
  3. supercollider_mcp-0.2.0/LICENSE +21 -0
  4. supercollider_mcp-0.2.0/PKG-INFO +225 -0
  5. supercollider_mcp-0.2.0/README.md +202 -0
  6. supercollider_mcp-0.2.0/pyproject.toml +57 -0
  7. supercollider_mcp-0.2.0/scripts/build_synthdefs.py +59 -0
  8. supercollider_mcp-0.2.0/supercollidermcp/__init__.py +8 -0
  9. supercollider_mcp-0.2.0/supercollidermcp/__main__.py +30 -0
  10. supercollider_mcp-0.2.0/supercollidermcp/compose.py +653 -0
  11. supercollider_mcp-0.2.0/supercollidermcp/engine.py +173 -0
  12. supercollider_mcp-0.2.0/supercollidermcp/osc.py +226 -0
  13. supercollider_mcp-0.2.0/supercollidermcp/patterns.py +116 -0
  14. supercollider_mcp-0.2.0/supercollidermcp/server.py +339 -0
  15. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/__init__.py +19 -0
  16. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_blip.scsyndef +0 -0
  17. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_fm.scsyndef +0 -0
  18. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_fx.scsyndef +0 -0
  19. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_grain.scsyndef +0 -0
  20. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_hat.scsyndef +0 -0
  21. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_kick.scsyndef +0 -0
  22. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_lfo.scsyndef +0 -0
  23. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_limiter.scsyndef +0 -0
  24. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_noise.scsyndef +0 -0
  25. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_pad.scsyndef +0 -0
  26. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_pluck.scsyndef +0 -0
  27. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_saw.scsyndef +0 -0
  28. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_sine.scsyndef +0 -0
  29. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_snare.scsyndef +0 -0
  30. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/mcp_square.scsyndef +0 -0
  31. supercollider_mcp-0.2.0/supercollidermcp/synthdefs/synthdefs.scd +164 -0
  32. supercollider_mcp-0.2.0/supercollidermcp/theory.py +169 -0
  33. supercollider_mcp-0.2.0/tests/__init__.py +0 -0
  34. supercollider_mcp-0.2.0/tests/conftest.py +92 -0
  35. supercollider_mcp-0.2.0/tests/test_compose.py +177 -0
  36. supercollider_mcp-0.2.0/tests/test_live_server.py +47 -0
  37. supercollider_mcp-0.2.0/tests/test_osc.py +74 -0
  38. supercollider_mcp-0.2.0/tests/test_server.py +167 -0
  39. supercollider_mcp-0.2.0/tests/test_synthdefs_nrt.py +150 -0
  40. supercollider_mcp-0.2.0/tests/test_theory.py +95 -0
@@ -0,0 +1,42 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ .Python
8
+ build/
9
+ develop-eggs/
10
+ dist/
11
+ downloads/
12
+ eggs/
13
+ .eggs/
14
+ lib/
15
+ lib64/
16
+ parts/
17
+ sdist/
18
+ var/
19
+ wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+ MANIFEST
24
+
25
+ # Virtual environments
26
+ .env
27
+ .venv
28
+ env/
29
+ venv/
30
+ ENV/
31
+ env.bak/
32
+ venv.bak/
33
+
34
+ # IDE specific files
35
+ .idea/
36
+ .vscode/
37
+ *.swp
38
+ *.swo
39
+
40
+ # Local
41
+ .pytest_cache/
42
+ .ruff_cache/
@@ -0,0 +1,61 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ A rewrite. Every tool now produces the sound it describes, and none of them block.
6
+
7
+ ### Added
8
+
9
+ - Bundled SynthDefs: `sine`, `saw`, `square`, `noise`, `fm`, `pad`, `pluck`, `kick`, `snare`, `hat`, `blip`,
10
+ `grain`, plus `mcp_fx` (distortion, low-pass, delay, reverb), `mcp_lfo` and an output limiter. They are
11
+ uploaded to scsynth automatically, and the source is `supercollidermcp/synthdefs/synthdefs.scd`.
12
+ - `server_status` tool: connection check, CPU, running playbacks, recent scsynth errors.
13
+ - `stop_all` tool: silence everything and cancel scheduled notes.
14
+ - `seed` on every generative tool (the seed used is reported), so a result can be replayed exactly.
15
+ - Custom drum patterns as step strings (`X x o .`), five lanes, independent lane lengths, swing.
16
+ - Scales: harmonic/melodic minor, the church modes, minor pentatonic, whole tone, chromatic.
17
+ - Chords: 6, m6, mmaj7, m7b5, 7sus4, 9, maj9, m9, madd9 and slash chords (`G/B`).
18
+ - `supercollider-mcp` command (`uvx supercollider-mcp`), configurable with `--host`/`--port` or
19
+ `SC_HOST`/`SC_PORT`.
20
+ - Test suite: unit tests, protocol tests against a fake scsynth, offline renders of every SynthDef with
21
+ `scsynth -N`, and an end-to-end test against a live server. CI on Python 3.10–3.13.
22
+
23
+ ### Changed
24
+
25
+ - Requires the current MCP SDK (`mcp>=2.3`) and Python 3.10+ (was 3.12+).
26
+ - Playback is scheduled on scsynth with timestamped OSC bundles, so tools return immediately and
27
+ calls can overlap. Before, each call blocked the server for the whole sound.
28
+ - Tool parameters have real types, ranges and enums in their schemas (before, everything was a string),
29
+ and `effects` is an object instead of a JSON string.
30
+ - Invalid notes, chords and patterns are reported as errors instead of silently becoming A440.
31
+ - `create_drum_pattern` takes `bars` (16 steps each) instead of `beats`, and steps are 16th notes. Before,
32
+ every step lasted a whole beat, so grooves played four times too slow.
33
+ - `play_melody` makes stepwise melodies that resolve to the tonic (and takes `root`, `notes`, `synth`). It no
34
+ longer appends an unrelated scale run.
35
+ - `create_chord_progression` keeps roots near middle C, and its `staccato` and `arpeggio` styles play on the
36
+ beat and in 8th notes. New `octave`, `synth` and `repeats` parameters.
37
+ - `create_layered_synth`: `detune` 1.0 now means ±50 cents (it used to reach a full octave), and there is a
38
+ new `stereo_width` parameter.
39
+ - `create_ambient_soundscape` events now actually overlap, and each mood has its own effects.
40
+ - `create_generative_rhythm` really evolves (patterns mutate bar by bar and snap back every 8 bars).
41
+
42
+ ### Fixed
43
+
44
+ - `create_granular_texture` crashed with `pitch_spread=0`.
45
+ - `create_sequence` ignored its `synth` parameter and split undelimited input into single characters.
46
+ - Every "synth type" and effect was silently ignored, because all sounds used sclang's `default` SynthDef.
47
+ - Notes ended with a click (`/n_free` instead of an envelope release).
48
+ - Node IDs could collide between overlapping calls.
49
+
50
+ ### Removed
51
+
52
+ - The `sc-osc` CLI (its entry point never worked).
53
+ - The duplicated helper modules (`melody.py`, `rhythm.py`, the old `osc.py`), which `server.py` never used.
54
+
55
+ ## 0.1.1
56
+
57
+ - Pin `mcp<2`: mcp 2.0 renamed `FastMCP`, so fresh installs crashed on startup.
58
+
59
+ ## 0.1.0
60
+
61
+ - Initial release.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 tok
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,225 @@
1
+ Metadata-Version: 2.5
2
+ Name: supercollider-mcp
3
+ Version: 0.2.0
4
+ Summary: MCP server that lets AI assistants make sound with SuperCollider over OSC
5
+ Project-URL: Homepage, https://github.com/Tok/SuperColliderMCP
6
+ Project-URL: Issues, https://github.com/Tok/SuperColliderMCP/issues
7
+ Project-URL: Changelog, https://github.com/Tok/SuperColliderMCP/blob/main/CHANGELOG.md
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: audio,mcp,model-context-protocol,music,osc,supercollider,synthesis
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Sound Synthesis
19
+ Requires-Python: >=3.10
20
+ Requires-Dist: mcp<3,>=2.3
21
+ Requires-Dist: python-osc>=1.9
22
+ Description-Content-Type: text/markdown
23
+
24
+ [![CI](https://github.com/Tok/SuperColliderMCP/actions/workflows/ci.yml/badge.svg)](https://github.com/Tok/SuperColliderMCP/actions/workflows/ci.yml)
25
+ [![Verified on MseeP](https://mseep.ai/badge.svg)](https://mseep.ai/app/70ac07b9-ec05-4fec-9456-5c4331cdf994)
26
+
27
+ # SuperCollider MCP 🎛️
28
+
29
+ A [Model Context Protocol](https://modelcontextprotocol.io/) server that lets AI assistants make sound with
30
+ [SuperCollider](https://supercollider.github.io/). Ask for "a dark ambient drone with slow swells" or
31
+ "a breakbeat at 170 under a Cm7-Fm7 arpeggio" and it plays on your SuperCollider server.
32
+
33
+ - **Real synths and drums.** It ships its own SynthDefs (sine, saw, square, noise, FM, pad, Karplus-Strong
34
+ pluck, kick, snare, hats, grains) plus an effect chain (distortion, low-pass, delay, reverb) and a safety
35
+ limiter. Nothing depends on sclang's `default` synth or on sc3-plugins.
36
+ - **Sample-accurate timing.** Phrases are streamed to scsynth as timestamped OSC bundles, so every tool
37
+ returns immediately. Calls can overlap, so you can layer drums, chords and melody.
38
+ - **Music-aware tools.** Melodies follow 14 scales, chords understand symbols like `Am7`, `Bbmaj9` and `G/B`,
39
+ drum patterns are readable step strings the assistant can write itself, and generative tools take a
40
+ `seed` so a result you like can be replayed exactly.
41
+ - **A panic button.** `stop_all` silences everything this server started.
42
+
43
+ ## Requirements
44
+
45
+ - [SuperCollider](https://supercollider.github.io/downloads) 3.10 or newer (tested with 3.13). Only the
46
+ audio server, `scsynth`, has to be running.
47
+ - [uv](https://docs.astral.sh/uv/), or any Python 3.10+ with pip.
48
+
49
+ ## Quick start
50
+
51
+ **1. Install and boot SuperCollider.** Install it from the
52
+ [downloads page](https://supercollider.github.io/downloads) (or `brew install --cask supercollider` on
53
+ macOS, `sudo apt install supercollider` on Debian/Ubuntu), then boot the server:
54
+
55
+ - in the SuperCollider IDE: *Server → Boot Server* (or run `s.boot;`)
56
+ - or without the IDE: `scsynth -u 57110`
57
+
58
+ **2. Add the MCP server to your assistant.**
59
+
60
+ Claude Code:
61
+
62
+ ```bash
63
+ claude mcp add supercollider -- uvx supercollider-mcp
64
+ ```
65
+
66
+ Claude Desktop, Cursor, Cline, Roo Code and other clients that use an `mcpServers` config:
67
+
68
+ ```json
69
+ {
70
+ "mcpServers": {
71
+ "supercollider": {
72
+ "command": "uvx",
73
+ "args": ["supercollider-mcp"]
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ To run the latest code from GitHub instead of the PyPI release, use
80
+ `"args": ["--from", "git+https://github.com/Tok/SuperColliderMCP", "supercollider-mcp"]`.
81
+
82
+ **3. Ask for something.** Start with "play a test sound" to check the connection, then try the prompts
83
+ below.
84
+
85
+ ### Configuration
86
+
87
+ | Setting | Flag | Environment | Default |
88
+ | --- | --- | --- | --- |
89
+ | scsynth host | `--host` | `SC_HOST` | `127.0.0.1` |
90
+ | scsynth UDP port | `--port` | `SC_PORT` | `57110` |
91
+ | log level (stderr) | `--log-level` | | `WARNING` |
92
+
93
+ For example `"args": ["supercollider-mcp", "--port", "57111"]`.
94
+
95
+ ## Tools
96
+
97
+ | Tool | What it does |
98
+ | --- | --- |
99
+ | `server_status` | Connection check: scsynth version, CPU, running playbacks, recent server errors |
100
+ | `stop_all` | Silence everything this server started and cancel scheduled notes |
101
+ | `play_example_osc` | A short test chime |
102
+ | `play_synth` | One note on `sine`, `saw`, `square`, `noise`, `fm`, `pad` or `pluck` |
103
+ | `create_layered_synth` | A thick unison: several detuned copies of one note spread in stereo |
104
+ | `create_lfo_modulation` | A held note with a server-side LFO on pitch, volume, filter or pan |
105
+ | `create_granular_texture` | A cloud of 5–100 tiny grains per second, scattered in pitch and space |
106
+ | `play_melody` | A generated melody in one of 14 scales that resolves to the tonic |
107
+ | `create_sequence` | A melody you spell out: `"C4 E4_ G4_ . C5+"` |
108
+ | `create_chord_progression` | Chord symbols as pads, staccato stabs, 8th-note arpeggios or power chords |
109
+ | `create_drum_pattern` | `four_on_floor`, `breakbeat`, `shuffle`, `half_time`, `two_step`, `random`, or your own |
110
+ | `create_generative_rhythm` | Drums that keep mutating: `minimal`, `techno`, `glitch`, `jazz`, `ambient` |
111
+ | `create_ambient_soundscape` | A drone with overlapping swells in a `calm`, `dark`, `bright`, `mysterious` or `chaotic` mood |
112
+
113
+ Most tools also take `volume` (0–1) and an optional `effects` object:
114
+
115
+ ```json
116
+ {"reverb": 0.6, "delay": 0.3, "delay_time": 0.25, "distortion": 0.0, "filter": 0.2}
117
+ ```
118
+
119
+ All amounts are 0–1, and 0 means off. `filter` darkens the sound with a low-pass filter. `delay_time` is in
120
+ seconds and defaults to three quarters of a beat.
121
+
122
+ **Notes** are names like `C4` (middle C), `F#3` or `Bb2`, or frequencies like `"440"` or `"440hz"`.
123
+
124
+ **Sequences** separate notes with spaces or dashes. `_` halves a note, `+` doubles it, `:1.5` sets its
125
+ length in beats, and `.` is a rest.
126
+
127
+ **Drum patterns** use one character per 16th note: `X` accent, `x` hit, `o` ghost note, `.` rest. Lanes
128
+ (`kick`, `snare`, `hat`, `open_hat`, `perc`) can have different lengths and loop independently:
129
+
130
+ ```json
131
+ {"custom": {"kick": "X..x..X...x.....", "snare": "....X.......X..o", "hat": "x.x.x.x.x.x.x.x."}, "tempo": 92, "swing": 0.2}
132
+ ```
133
+
134
+ ### Things to try
135
+
136
+ - "Play a dorian melody in D on the pluck synth with some delay, then the same one an octave lower."
137
+ - "Give me two bars of breakbeat at 170 BPM, then layer an Am7-Dm7-G7-Cmaj7 arpeggio on top."
138
+ - "A mysterious ambient soundscape, 60 seconds, low register."
139
+ - "Sweep a saw's filter with a slow triangle LFO while a granular cloud shimmers around A5."
140
+ - "Write me a half-time drum pattern with ghost notes on the snare."
141
+
142
+ ## How it works
143
+
144
+ ```
145
+ assistant ──MCP (stdio)──▶ supercollider-mcp ──OSC/UDP──▶ scsynth ──▶ speakers
146
+ ```
147
+
148
+ On first use the server checks that scsynth answers, uploads its SynthDefs (`/d_recv`) and creates its own
149
+ node group with a voice group, an effects group and a limiter. Node IDs sit far above the ranges sclang
150
+ uses, so your own SuperCollider work is not affected. If scsynth restarts, the setup runs again on the next
151
+ call.
152
+
153
+ Each tool call turns into a *phrase*: a time-ordered stream of synth events (`supercollidermcp/compose.py`,
154
+ pure Python). A background task sends each event about half a second ahead as an OSC bundle with an NTP
155
+ timetag, and scsynth starts it at exactly that time. Every synth frees itself when its envelope ends. When
156
+ a call asks for effects, its voices go to a private bus that one `mcp_fx` synth reads.
157
+
158
+ ## Upgrading from 0.1
159
+
160
+ - Point your MCP config at `uvx supercollider-mcp` as shown above. Old configs that run
161
+ `mcp run path/to/server.py` still work through a small compatibility `server.py`.
162
+ - Sounds now come from real SynthDefs, so you no longer need sclang's `default` synth.
163
+ - Tools return right away instead of blocking until the sound ends.
164
+ - Some parameters changed meaning. `create_drum_pattern` takes `bars` (16 steps each) instead of `beats`.
165
+ `effects` is an object instead of a JSON string. `detune` is now ±50 cents at 1.0 instead of up to an
166
+ octave. The `sc-osc` command-line tool is gone.
167
+
168
+ See [CHANGELOG.md](CHANGELOG.md) for everything else.
169
+
170
+ ## Troubleshooting
171
+
172
+ - **"No reply from the SuperCollider server…"**: scsynth is not running, or it listens on a different
173
+ port. Boot it, or set `SC_PORT`.
174
+ - **Calls succeed but you hear nothing**: check that scsynth's outputs are connected to your sound card
175
+ and that `server_status` shows synths while something plays.
176
+ - **Linux with PipeWire** (the default on current Ubuntu and Fedora): scsynth talks to JACK, so install
177
+ PipeWire's JACK layer (`sudo apt install pipewire-jack`) and start SuperCollider through it:
178
+ `pw-jack scide`, or `pw-jack scsynth -u 57110` without the IDE. Otherwise scsynth tries to start its
179
+ own `jackd`, which conflicts with PipeWire.
180
+ - **`FAILURE IN SERVER /g_queryTree Group 2147480000 not found` in the post window** on first connect is
181
+ expected: it is how the server notices that scsynth still needs to be set up.
182
+ - **Remote scsynth**: timetags use wall-clock time, so keep both machines' clocks in sync (NTP).
183
+
184
+ ## Development
185
+
186
+ ```bash
187
+ git clone https://github.com/Tok/SuperColliderMCP.git
188
+ cd SuperColliderMCP
189
+ uv sync
190
+ uv run pytest # unit and protocol tests run anywhere
191
+ uv run ruff check . && uv run ruff format --check .
192
+ ```
193
+
194
+ Some tests need SuperCollider:
195
+
196
+ - `tests/test_synthdefs_nrt.py` renders every SynthDef with `scsynth -N` (no audio device needed) and
197
+ checks the audio. It runs automatically when `scsynth` is on `PATH`, or set `SCSYNTH=/path/to/scsynth`.
198
+ - `tests/test_live_server.py` runs every tool against a live server. Start a silent one with
199
+ `scsynth -u 57199 -i 0 -o 0`, then run `SC_TEST_PORT=57199 uv run pytest`.
200
+
201
+ The SynthDefs are written in SuperCollider itself, in `supercollidermcp/synthdefs/synthdefs.scd`. After
202
+ editing that file, rebuild the compiled `.scsyndef` files with `python scripts/build_synthdefs.py`
203
+ (needs `sclang`; it runs headless).
204
+
205
+ ```
206
+ supercollidermcp/
207
+ ├── server.py MCP tools: validation and wiring
208
+ ├── compose.py musical logic: requests → timed events (pure, unit-tested)
209
+ ├── theory.py notes, scales, chords
210
+ ├── patterns.py drum patterns as step strings
211
+ ├── engine.py server setup, buses, streaming playback, stop_all
212
+ ├── osc.py async OSC client that also reads scsynth's replies
213
+ └── synthdefs/ synthdefs.scd (source) + compiled .scsyndef files
214
+ ```
215
+
216
+ Contributions are welcome. New sounds usually mean a SynthDef in `synthdefs.scd` plus a composer function
217
+ in `compose.py`.
218
+
219
+ ## External Security Assessment
220
+
221
+ [![MseeP.ai Security Assessment Badge](https://mseep.net/pr/tok-supercollidermcp-badge.png)](https://mseep.ai/app/tok-supercollidermcp)
222
+
223
+ ## License
224
+
225
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,202 @@
1
+ [![CI](https://github.com/Tok/SuperColliderMCP/actions/workflows/ci.yml/badge.svg)](https://github.com/Tok/SuperColliderMCP/actions/workflows/ci.yml)
2
+ [![Verified on MseeP](https://mseep.ai/badge.svg)](https://mseep.ai/app/70ac07b9-ec05-4fec-9456-5c4331cdf994)
3
+
4
+ # SuperCollider MCP 🎛️
5
+
6
+ A [Model Context Protocol](https://modelcontextprotocol.io/) server that lets AI assistants make sound with
7
+ [SuperCollider](https://supercollider.github.io/). Ask for "a dark ambient drone with slow swells" or
8
+ "a breakbeat at 170 under a Cm7-Fm7 arpeggio" and it plays on your SuperCollider server.
9
+
10
+ - **Real synths and drums.** It ships its own SynthDefs (sine, saw, square, noise, FM, pad, Karplus-Strong
11
+ pluck, kick, snare, hats, grains) plus an effect chain (distortion, low-pass, delay, reverb) and a safety
12
+ limiter. Nothing depends on sclang's `default` synth or on sc3-plugins.
13
+ - **Sample-accurate timing.** Phrases are streamed to scsynth as timestamped OSC bundles, so every tool
14
+ returns immediately. Calls can overlap, so you can layer drums, chords and melody.
15
+ - **Music-aware tools.** Melodies follow 14 scales, chords understand symbols like `Am7`, `Bbmaj9` and `G/B`,
16
+ drum patterns are readable step strings the assistant can write itself, and generative tools take a
17
+ `seed` so a result you like can be replayed exactly.
18
+ - **A panic button.** `stop_all` silences everything this server started.
19
+
20
+ ## Requirements
21
+
22
+ - [SuperCollider](https://supercollider.github.io/downloads) 3.10 or newer (tested with 3.13). Only the
23
+ audio server, `scsynth`, has to be running.
24
+ - [uv](https://docs.astral.sh/uv/), or any Python 3.10+ with pip.
25
+
26
+ ## Quick start
27
+
28
+ **1. Install and boot SuperCollider.** Install it from the
29
+ [downloads page](https://supercollider.github.io/downloads) (or `brew install --cask supercollider` on
30
+ macOS, `sudo apt install supercollider` on Debian/Ubuntu), then boot the server:
31
+
32
+ - in the SuperCollider IDE: *Server → Boot Server* (or run `s.boot;`)
33
+ - or without the IDE: `scsynth -u 57110`
34
+
35
+ **2. Add the MCP server to your assistant.**
36
+
37
+ Claude Code:
38
+
39
+ ```bash
40
+ claude mcp add supercollider -- uvx supercollider-mcp
41
+ ```
42
+
43
+ Claude Desktop, Cursor, Cline, Roo Code and other clients that use an `mcpServers` config:
44
+
45
+ ```json
46
+ {
47
+ "mcpServers": {
48
+ "supercollider": {
49
+ "command": "uvx",
50
+ "args": ["supercollider-mcp"]
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ To run the latest code from GitHub instead of the PyPI release, use
57
+ `"args": ["--from", "git+https://github.com/Tok/SuperColliderMCP", "supercollider-mcp"]`.
58
+
59
+ **3. Ask for something.** Start with "play a test sound" to check the connection, then try the prompts
60
+ below.
61
+
62
+ ### Configuration
63
+
64
+ | Setting | Flag | Environment | Default |
65
+ | --- | --- | --- | --- |
66
+ | scsynth host | `--host` | `SC_HOST` | `127.0.0.1` |
67
+ | scsynth UDP port | `--port` | `SC_PORT` | `57110` |
68
+ | log level (stderr) | `--log-level` | | `WARNING` |
69
+
70
+ For example `"args": ["supercollider-mcp", "--port", "57111"]`.
71
+
72
+ ## Tools
73
+
74
+ | Tool | What it does |
75
+ | --- | --- |
76
+ | `server_status` | Connection check: scsynth version, CPU, running playbacks, recent server errors |
77
+ | `stop_all` | Silence everything this server started and cancel scheduled notes |
78
+ | `play_example_osc` | A short test chime |
79
+ | `play_synth` | One note on `sine`, `saw`, `square`, `noise`, `fm`, `pad` or `pluck` |
80
+ | `create_layered_synth` | A thick unison: several detuned copies of one note spread in stereo |
81
+ | `create_lfo_modulation` | A held note with a server-side LFO on pitch, volume, filter or pan |
82
+ | `create_granular_texture` | A cloud of 5–100 tiny grains per second, scattered in pitch and space |
83
+ | `play_melody` | A generated melody in one of 14 scales that resolves to the tonic |
84
+ | `create_sequence` | A melody you spell out: `"C4 E4_ G4_ . C5+"` |
85
+ | `create_chord_progression` | Chord symbols as pads, staccato stabs, 8th-note arpeggios or power chords |
86
+ | `create_drum_pattern` | `four_on_floor`, `breakbeat`, `shuffle`, `half_time`, `two_step`, `random`, or your own |
87
+ | `create_generative_rhythm` | Drums that keep mutating: `minimal`, `techno`, `glitch`, `jazz`, `ambient` |
88
+ | `create_ambient_soundscape` | A drone with overlapping swells in a `calm`, `dark`, `bright`, `mysterious` or `chaotic` mood |
89
+
90
+ Most tools also take `volume` (0–1) and an optional `effects` object:
91
+
92
+ ```json
93
+ {"reverb": 0.6, "delay": 0.3, "delay_time": 0.25, "distortion": 0.0, "filter": 0.2}
94
+ ```
95
+
96
+ All amounts are 0–1, and 0 means off. `filter` darkens the sound with a low-pass filter. `delay_time` is in
97
+ seconds and defaults to three quarters of a beat.
98
+
99
+ **Notes** are names like `C4` (middle C), `F#3` or `Bb2`, or frequencies like `"440"` or `"440hz"`.
100
+
101
+ **Sequences** separate notes with spaces or dashes. `_` halves a note, `+` doubles it, `:1.5` sets its
102
+ length in beats, and `.` is a rest.
103
+
104
+ **Drum patterns** use one character per 16th note: `X` accent, `x` hit, `o` ghost note, `.` rest. Lanes
105
+ (`kick`, `snare`, `hat`, `open_hat`, `perc`) can have different lengths and loop independently:
106
+
107
+ ```json
108
+ {"custom": {"kick": "X..x..X...x.....", "snare": "....X.......X..o", "hat": "x.x.x.x.x.x.x.x."}, "tempo": 92, "swing": 0.2}
109
+ ```
110
+
111
+ ### Things to try
112
+
113
+ - "Play a dorian melody in D on the pluck synth with some delay, then the same one an octave lower."
114
+ - "Give me two bars of breakbeat at 170 BPM, then layer an Am7-Dm7-G7-Cmaj7 arpeggio on top."
115
+ - "A mysterious ambient soundscape, 60 seconds, low register."
116
+ - "Sweep a saw's filter with a slow triangle LFO while a granular cloud shimmers around A5."
117
+ - "Write me a half-time drum pattern with ghost notes on the snare."
118
+
119
+ ## How it works
120
+
121
+ ```
122
+ assistant ──MCP (stdio)──▶ supercollider-mcp ──OSC/UDP──▶ scsynth ──▶ speakers
123
+ ```
124
+
125
+ On first use the server checks that scsynth answers, uploads its SynthDefs (`/d_recv`) and creates its own
126
+ node group with a voice group, an effects group and a limiter. Node IDs sit far above the ranges sclang
127
+ uses, so your own SuperCollider work is not affected. If scsynth restarts, the setup runs again on the next
128
+ call.
129
+
130
+ Each tool call turns into a *phrase*: a time-ordered stream of synth events (`supercollidermcp/compose.py`,
131
+ pure Python). A background task sends each event about half a second ahead as an OSC bundle with an NTP
132
+ timetag, and scsynth starts it at exactly that time. Every synth frees itself when its envelope ends. When
133
+ a call asks for effects, its voices go to a private bus that one `mcp_fx` synth reads.
134
+
135
+ ## Upgrading from 0.1
136
+
137
+ - Point your MCP config at `uvx supercollider-mcp` as shown above. Old configs that run
138
+ `mcp run path/to/server.py` still work through a small compatibility `server.py`.
139
+ - Sounds now come from real SynthDefs, so you no longer need sclang's `default` synth.
140
+ - Tools return right away instead of blocking until the sound ends.
141
+ - Some parameters changed meaning. `create_drum_pattern` takes `bars` (16 steps each) instead of `beats`.
142
+ `effects` is an object instead of a JSON string. `detune` is now ±50 cents at 1.0 instead of up to an
143
+ octave. The `sc-osc` command-line tool is gone.
144
+
145
+ See [CHANGELOG.md](CHANGELOG.md) for everything else.
146
+
147
+ ## Troubleshooting
148
+
149
+ - **"No reply from the SuperCollider server…"**: scsynth is not running, or it listens on a different
150
+ port. Boot it, or set `SC_PORT`.
151
+ - **Calls succeed but you hear nothing**: check that scsynth's outputs are connected to your sound card
152
+ and that `server_status` shows synths while something plays.
153
+ - **Linux with PipeWire** (the default on current Ubuntu and Fedora): scsynth talks to JACK, so install
154
+ PipeWire's JACK layer (`sudo apt install pipewire-jack`) and start SuperCollider through it:
155
+ `pw-jack scide`, or `pw-jack scsynth -u 57110` without the IDE. Otherwise scsynth tries to start its
156
+ own `jackd`, which conflicts with PipeWire.
157
+ - **`FAILURE IN SERVER /g_queryTree Group 2147480000 not found` in the post window** on first connect is
158
+ expected: it is how the server notices that scsynth still needs to be set up.
159
+ - **Remote scsynth**: timetags use wall-clock time, so keep both machines' clocks in sync (NTP).
160
+
161
+ ## Development
162
+
163
+ ```bash
164
+ git clone https://github.com/Tok/SuperColliderMCP.git
165
+ cd SuperColliderMCP
166
+ uv sync
167
+ uv run pytest # unit and protocol tests run anywhere
168
+ uv run ruff check . && uv run ruff format --check .
169
+ ```
170
+
171
+ Some tests need SuperCollider:
172
+
173
+ - `tests/test_synthdefs_nrt.py` renders every SynthDef with `scsynth -N` (no audio device needed) and
174
+ checks the audio. It runs automatically when `scsynth` is on `PATH`, or set `SCSYNTH=/path/to/scsynth`.
175
+ - `tests/test_live_server.py` runs every tool against a live server. Start a silent one with
176
+ `scsynth -u 57199 -i 0 -o 0`, then run `SC_TEST_PORT=57199 uv run pytest`.
177
+
178
+ The SynthDefs are written in SuperCollider itself, in `supercollidermcp/synthdefs/synthdefs.scd`. After
179
+ editing that file, rebuild the compiled `.scsyndef` files with `python scripts/build_synthdefs.py`
180
+ (needs `sclang`; it runs headless).
181
+
182
+ ```
183
+ supercollidermcp/
184
+ ├── server.py MCP tools: validation and wiring
185
+ ├── compose.py musical logic: requests → timed events (pure, unit-tested)
186
+ ├── theory.py notes, scales, chords
187
+ ├── patterns.py drum patterns as step strings
188
+ ├── engine.py server setup, buses, streaming playback, stop_all
189
+ ├── osc.py async OSC client that also reads scsynth's replies
190
+ └── synthdefs/ synthdefs.scd (source) + compiled .scsyndef files
191
+ ```
192
+
193
+ Contributions are welcome. New sounds usually mean a SynthDef in `synthdefs.scd` plus a composer function
194
+ in `compose.py`.
195
+
196
+ ## External Security Assessment
197
+
198
+ [![MseeP.ai Security Assessment Badge](https://mseep.net/pr/tok-supercollidermcp-badge.png)](https://mseep.ai/app/tok-supercollidermcp)
199
+
200
+ ## License
201
+
202
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,57 @@
1
+ [project]
2
+ name = "supercollider-mcp"
3
+ version = "0.2.0"
4
+ description = "MCP server that lets AI assistants make sound with SuperCollider over OSC"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.10"
9
+ keywords = ["supercollider", "mcp", "model-context-protocol", "osc", "music", "audio", "synthesis"]
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Intended Audience :: Developers",
13
+ "Topic :: Multimedia :: Sound/Audio :: Sound Synthesis",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ ]
20
+ dependencies = [
21
+ "mcp>=2.3,<3",
22
+ "python-osc>=1.9",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://github.com/Tok/SuperColliderMCP"
27
+ Issues = "https://github.com/Tok/SuperColliderMCP/issues"
28
+ Changelog = "https://github.com/Tok/SuperColliderMCP/blob/main/CHANGELOG.md"
29
+
30
+ [project.scripts]
31
+ supercollider-mcp = "supercollidermcp.__main__:main"
32
+
33
+ [dependency-groups]
34
+ dev = [
35
+ "pytest>=8",
36
+ "ruff>=0.8",
37
+ ]
38
+
39
+ [build-system]
40
+ requires = ["hatchling>=1.26"]
41
+ build-backend = "hatchling.build"
42
+
43
+ [tool.hatch.build.targets.wheel]
44
+ packages = ["supercollidermcp"]
45
+
46
+ [tool.hatch.build.targets.sdist]
47
+ include = ["supercollidermcp", "tests", "scripts", "README.md", "CHANGELOG.md", "LICENSE"]
48
+
49
+ [tool.ruff]
50
+ line-length = 120
51
+ target-version = "py310"
52
+
53
+ [tool.ruff.lint]
54
+ select = ["E", "F", "W", "I", "UP", "B", "SIM", "RUF"]
55
+
56
+ [tool.pytest.ini_options]
57
+ testpaths = ["tests"]
@@ -0,0 +1,59 @@
1
+ """Compile supercollidermcp/synthdefs/synthdefs.scd into .scsyndef files.
2
+
3
+ Needs sclang (SuperCollider 3.10+). It runs headless, so no IDE or display is needed.
4
+
5
+ python scripts/build_synthdefs.py
6
+
7
+ Environment overrides:
8
+ SCLANG path to the sclang binary (default: found on PATH)
9
+ SCLANG_CONF path to a sclang_conf.yaml, passed as `sclang -l`
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import os
15
+ import re
16
+ import shutil
17
+ import subprocess
18
+ import sys
19
+ from pathlib import Path
20
+
21
+ SYNTHDEF_DIR = Path(__file__).resolve().parent.parent / "supercollidermcp" / "synthdefs"
22
+ SOURCE = SYNTHDEF_DIR / "synthdefs.scd"
23
+
24
+
25
+ def main() -> int:
26
+ sclang = os.environ.get("SCLANG") or shutil.which("sclang")
27
+ if not sclang:
28
+ print("sclang not found: install SuperCollider or set SCLANG=/path/to/sclang", file=sys.stderr)
29
+ return 1
30
+
31
+ for old in SYNTHDEF_DIR.glob("*.scsyndef"):
32
+ old.unlink()
33
+
34
+ cmd = [sclang]
35
+ if conf := os.environ.get("SCLANG_CONF"):
36
+ cmd += ["-l", conf]
37
+ cmd += [str(SOURCE), str(SYNTHDEF_DIR)]
38
+
39
+ env = {**os.environ, "QT_QPA_PLATFORM": os.environ.get("QT_QPA_PLATFORM", "offscreen")}
40
+ result = subprocess.run(cmd, env=env, capture_output=True, text=True, timeout=120)
41
+ output = result.stdout + result.stderr
42
+ built = sorted(p.name for p in SYNTHDEF_DIR.glob("*.scsyndef"))
43
+ wrote = re.search(r"wrote (\d+) SynthDefs", output)
44
+
45
+ # Judge success by what sclang reports and writes, not by its exit code: headless
46
+ # sclang 3.13 often segfaults while shutting down, after the files are written.
47
+ if "ERROR" in output or not wrote or int(wrote.group(1)) != len(built):
48
+ print(output, file=sys.stderr)
49
+ print("SynthDef build failed", file=sys.stderr)
50
+ return 1
51
+
52
+ print(f"built {len(built)} SynthDefs in {SYNTHDEF_DIR}:")
53
+ for name in built:
54
+ print(f" {name}")
55
+ return 0
56
+
57
+
58
+ if __name__ == "__main__":
59
+ sys.exit(main())
@@ -0,0 +1,8 @@
1
+ """SuperColliderMCP: an MCP server for making sound with SuperCollider over OSC."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ __version__ = version("supercollider-mcp")
7
+ except PackageNotFoundError: # running from a source checkout without installing
8
+ __version__ = "0.0.0+unknown"