PatternPilot
# PatternPilot
<img src="docs/assets/patternpilot-logo.svg" alt="PatternPilot: ascending Piano Roll notes and a star. From prompt to Piano Roll." width="540">
PatternPilot connects AI assistants to FL Studio over MCP. Ask for a melody,
stage a chord progression, inspect the mixer, or control project tempo with
live writes enabled. The included desktop chat supports common requests
offline, with no API key.
PatternPilot does not open a network port or modify FL Studio's installation.
Run the MCP server and DAW on the same machine under the same OS user.
**Status:** Offline tests use simulated FL modules and a real MCP stdio connection.
Live validation on Windows and macOS is still required. Linux is suitable for
development; FL Studio under Wine and split-machine setups are not supported yet.
## Try the read-only bridge
1. On the machine running FL Studio, install [uv](https://docs.astral.sh/uv/)
and clone the repository:
```sh
git clone https://github.com/cyberneticangel/PatternPilot.git
cd PatternPilot
uv sync --locked
uv run patternpilot install-bridge --fl-user-data "PATH TO YOUR FL STUDIO USER DATA"
```
Find the FL user data path in **Options → File settings**. Pass its root
(the folder that contains `Settings`), not the FL installation folder.
The installer prints both installed script paths and the mailbox path. The default
mailbox is `%LOCALAPPDATA%\fl-mcp` on Windows or `~/.fl-mcp` on macOS/Linux.
Keep it on a local, non-synced filesystem. If you use `--mailbox`, pass the
same path to `install-bridge`, `doctor`, `serve`, and `chat`.
2. In **Options → MIDI settings**, select and enable a **dedicated** input
and choose **FL MCP (user)** as its controller type. A dedicated virtual
MIDI input may be needed; do not replace the script on a controller you
rely on. The mailbox carries the requests, not the MIDI input. Check
**View → Script output** for `FL MCP ready: read-only`.
3. With FL Studio open, run:
```sh
uv run patternpilot doctor
```
Expect `"bridge_ready": true` plus the BPM, playback state, and FL build.
Run it once stopped and once while playing. If the heartbeat or live read
fails, see the [DAW acceptance checklist](docs/daw-smoke-test.md).
4. Once `doctor` works, open the [standalone chat](#desktop-chat), or add the
server to an MCP host using `patternpilot serve`
over stdio. For OpenCode V2, run from the project on the DAW machine:
```sh
opencode mcp add patternpilot -- uv run --project "ABSOLUTE PROJECT PATH" patternpilot serve
opencode mcp list
```
If `uv` is not on the host's PATH, use its absolute path or the absolute
path to the installed `patternpilot` executable. The same executable and
arguments work in MCP Inspector: `npx -y @modelcontextprotocol/inspector …`.
Stop the MCP host before running `doctor` again if it owns the mailbox.
A host reporting “connected” only confirms that the MCP process started.
## Desktop chat
Run `uv run patternpilot chat` on a desktop with Tkinter available. The window
works offline, without an API key or another MCP host. It recognizes common
production requests and offers setup help; it is not a general-purpose chatbot.
- **“Make a dark melody in F minor”** stages a four-bar melody in 4/4.
You can also ask for a bright, calm, or tense melody, and specify up to eight bars.
- **“Draw a Cmaj7 chord”** or **“Draw chords: Fm, Dbmaj7, Ab, Eb”** stages notes
with one four-beat chord per slot by default.
- **“Set BPM to 128”** asks for confirmation and applies the change if live
writes are enabled. Use `uv run patternpilot chat --allow-writes` *and* reinstall
the controller with `--replace --allow-writes` as described below.
- **“Status”** checks live BPM and playback. **“Help”** shows example requests.
To add staged notes, open the **intended instrument and pattern** in FL Studio,
then choose **Piano Roll → Tools → Script… → FL MCP Apply Notes**. Enable
**Preview staged notes**, set the starting beat if needed, then confirm or
cancel. Staging alone does not change a project or require the live MIDI
controller to be active. The latest batch replaces the previous one, expires
after 15 minutes, and can be applied more than once if you run the script again.
Use the chat or external MCP host one at a time for live reads and edits.
## Tools
| Tool | What it does |
| --- | --- |
| `get_status` | Live bridge readiness, capabilities, BPM, transport and project generation. |
| `list_mixer_tracks` | Master and ordinary inserts; excludes FL's special Current utility track. |
| `list_channels` | All Channel Rack groups using global indices. |
| `get_current_pattern` | Current pattern number, name, and duration in beats, not notes. |
| `stage_piano_roll_chords` | Stages one or more chord symbols with configurable octave, inversion, and duration. |
| `stage_piano_roll_melody` | Stages an in-key melody with a selected mood, length, and optional reproducible seed. |
| `set_playback` | Starts or stops playback; rejects changes while recording. Stop may reset the playhead. |
| `set_mixer_track` | Sets one of mute, normalized volume, or pan on a non-Master insert. |
| `set_bpm` | Sets project tempo (10–522 BPM) and reports the DAW's readback; refuses during recording. |
List tools accept `start` and `limit` (maximum 16); follow `next_start` until
it is `null`. Check `get_status` for capabilities on the installed scripting API.
Live write tools are absent from the MCP catalog by default. To enable them **after the
read-only smoke test**, reinstall with `--replace --allow-writes`, reload the
FL controller, and start `serve --allow-writes` or `chat --allow-writes`. Use a disposable
project and enable host confirmations where available. Disable both flags and
reload/restart to turn writes off again.
For mixer edits, use the `index`, exact `name` (as `expected_name`), `instance`,
and `project` from a fresh `list_mixer_tracks` call. For example, pass
`change: {"field":"volume","value":0.6}`. `before` and `after` report FL's
readback; FL may quantize a value. Index/name checks do not guarantee identity
across same-name replacements, so don't rearrange inserts during an edit.
Do not assume FL Undo is available for every operation. If a write returns
`outcome_unknown` or is canceled, read back state before deciding whether to
retry. The server does not automatically replay writes.
This version does not edit existing Piano Roll notes, place Playlist clips,
load plugins, record, render, or save/open projects.
## Development and removal
```sh
uv sync --locked
uv run pytest
uv run ruff check .
uv build
```
`fl-mcp` remains available as a CLI alias. The FL controller and Piano Roll
scripts still use their existing **FL MCP** menu names.
To uninstall, disconnect the MCP host and chat, disable the FL MIDI input used
by the bridge, and remove these from the FL user data folder:
- `Settings/Hardware/FL MCP/device_fl_mcp.py`
- `Settings/Piano roll scripts/FL MCP Apply Notes.pyscript`
Once both sides are closed, the dedicated mailbox directory can also be
removed. Do not remove its lock files while either side is running.
## License
[GNU Affero General Public License v3.0](LICENSE).
TDQS
Scored across 6 tools
Most tools are clearly separated by resource and action: status vs. pattern metadata, mixer tracks vs. channel rack, chords vs. melody. The only mild overlap is between list_mixer_tracks and list_channels, since channels carry mixer assignments, but the descriptions make the distinction clear.
All six tools follow a consistent snake_case verb_noun pattern (get_status, list_channels, stage_piano_roll_chords). Verb choice is predictable by intent: get for single-object reads, list for collections, stage for pending mutations.
Six tools is a tight, purposeful set for a scoped FL Studio inspection/staging server, with no filler. It is slightly lean on the write side, with only two staging tools and no apply/clear counterpart.
Core read surfaces (transport, mixer, channels, pattern metadata) are covered, but there are notable gaps: no tool to read existing pattern notes, no transport control, no mixer level/pan operations, and staged content must be applied manually outside the toolset. These are disclosed in the descriptions but still leave agents at dead ends for round-trip workflows.