Hydrogen MCP Server
README.md
# Hydrogen MCP Server

**Sequence, mix, and render Hydrogen projects from your local MCP client.**
[](https://github.com/RandyNorthrup/hydrogen-mcp-server/actions/workflows/quality.yml)
[](https://www.python.org/)
[](https://gofastmcp.com/)
[](#verification)
[](LICENSE)
[Quick start](#quick-start) · [Tool overview](#tool-overview) · [First groove](#make-a-two-bar-groove) · [Configuration](#configuration)
This independent integration exposes **28 MCP tools** and maps **67 OSC action names** from Hydrogen 1.2.7. It supports live transport and mixer control, native project editing, audio and MIDI export, and Windows desktop controls for Hydrogen menus and dialogs.
## Quick start
Install Python 3.13 or 3.14, [uv](https://docs.astral.sh/uv/), and [Hydrogen](https://hydrogen-music.org/downloads/). The Windows Hydrogen installer includes `hydrogen.exe` and `h2cli.exe`. Native integration is verified on Windows with Hydrogen 1.2.7 and Python 3.13.
```sh
git clone https://github.com/RandyNorthrup/hydrogen-mcp-server.git
cd hydrogen-mcp-server
uv sync --locked --no-dev
```
Register the generated executable in your MCP client using its absolute path. A client with an `mcpServers` configuration can use this example.
```json
{
"mcpServers": {
"hydrogen": {
"command": "C:/path/to/hydrogen-mcp-server/.venv/Scripts/hydrogen-mcp.exe",
"args": []
}
}
}
```
On Linux and macOS, use `.venv/bin/hydrogen-mcp` inside your checkout and set the [Hydrogen paths](#configuration) for your installation. The MCP transport is stdio. You can also start it manually from the checkout with `uv run --locked --no-dev hydrogen-mcp`.
### Connect to Hydrogen for live control
1. Open Hydrogen and go to **Preferences → OSC**.
2. Enable **OSC support** and **OSC feedback**. Use port `9000` or set `HYDROGEN_OSC_PORT` to match your app.
3. Call `hydrogen_status`. Look for a timestamp in `osc.last_feedback_received_at` to confirm live feedback.
Offline project editing and `h2cli` audio export work with the desktop app closed. Keep trusted source files in the configured project or library roots.
> [!TIP]
> If Hydrogen 1.2.7 saves OSC as enabled but the listener does not start, apply a different unused incoming port in Preferences, then apply your original port again. You can also save your song and restart Hydrogen.
## Tool overview
| Workflow | Tools |
| --- | --- |
| Discover files, live controls, and feedback | `hydrogen_list`, `hydrogen_status`, `hydrogen_controls` |
| Control transport, recording, BPM, mixer, timeline, MIDI triggers, and JACK | `hydrogen_live` |
| Launch Hydrogen and work with the active song | `hydrogen_launch`, `hydrogen_open_song`, `hydrogen_new_song`, `hydrogen_save_as` |
| Compose and inspect songs, patterns, instruments, and layered samples | `hydrogen_read_song`, `hydrogen_edit_song`, `hydrogen_read_instrument`, `hydrogen_read_pattern`, `hydrogen_write_pattern`, `hydrogen_add_live_pattern`, `hydrogen_open_pattern` |
| Read and create playlists | `hydrogen_read_playlist`, `hydrogen_write_playlist` |
| Load, inspect, validate, import, upgrade, and export drumkits | `hydrogen_load_drumkit`, `hydrogen_read_drumkit`, `hydrogen_validate_drumkit`, `hydrogen_import_drumkit`, `hydrogen_export_drumkit` |
| Render a mix, export isolated stereo stems, or write type 1 MIDI | `hydrogen_render`, `hydrogen_render_stems`, `hydrogen_export_midi` |
| View and interact with a Hydrogen window on Windows | `hydrogen_desktop_windows`, `hydrogen_desktop_image`, `hydrogen_desktop_input` |
The `hydrogen://reference/osc` resource lists the action signatures. For live controls, `sent_unconfirmed` means the UDP datagram was sent. Mixer feedback comes back through `hydrogen_status`. `hydrogen_save_as` verifies the saved song file and changes the active save path. Save current edits before opening or creating another live song.
For Windows desktop control, list the windows, capture a selected window, then send client-relative pointer coordinates or keyboard input to that window. The feature requires an interactive Windows session. Plugins and JACK operations depend on support in the installed Hydrogen build.
## Make a two-bar groove
Ask your MCP client to create two bars with the factory GM kit and export a stereo WAV. To call the tools directly, send this payload to `hydrogen_edit_song`.
```json
{
"source": { "scope": "factory", "path": "demo_songs/GM_kit_demo1.h2song" },
"output": "Grooves/first-beat.h2song",
"edit": {
"name": "First beat",
"bpm": 110,
"mode": "song",
"reset_patterns": true,
"patterns": [
{
"name": "Beat",
"notes": [
{ "instrument": 0, "position": 0 },
{ "instrument": 0, "position": 48 },
{ "instrument": 0, "position": 96 },
{ "instrument": 0, "position": 144 }
]
}
],
"arrangement": [["Beat"], ["Beat"]]
}
}
```
Then send this payload to `hydrogen_render`.
```json
{
"source": { "path": "Grooves/first-beat.h2song" },
"output": "Grooves/first-beat.wav"
}
```
With the default checkout configuration, both files appear in `projects/Grooves/`. File references use paths relative to `projects`, `user`, or `factory`. Discover those paths with `hydrogen_list`. File edits write a new project, and drumkit imports can also create a folder in the user library.
### Rendering details
- **Notes and timing.** Use instrument IDs from `hydrogen_read_song` for offline edits. Hydrogen uses 48 ticks per quarter note and 192 ticks for a 4/4 bar. Live OSC indexes are zero-based except for one-based mixer `strip` positions.
- **Audio.** The Windows 1.2.7 format audit covered WAV, AIFF, FLAC, Ogg Vorbis, Opus, AU, CAF, Wave64, VOC, and MP3. Codec availability depends on the Hydrogen build. Use 48 kHz for Opus and 8-bit PCM for VOC. Stems are separate stereo WAVs rendered by Hydrogen.
- **MIDI.** Export uses the saved arrangement, velocity, instrument mapping, and enabled tempo markers. It includes every note with nonzero probability. The MIDI file contains events for import into a DAW or sequencer.
- **Sample layers.** `sample_instruments` adds instruments from existing audio files. `sample_layers` edits gain, pitch, velocity range, trim, loop, or sample assignment. Keep custom samples with the project for portable exports.
- **Drumkits.** Import and export Hydrogen’s `.h2drumkit` archives. The import tool’s upgrade mode accepts a manifest or archive and writes the upgraded result to a new directory.
## Configuration
Set these variables in your MCP client environment, or copy [`.env.example`](.env.example) to `.env` and run `uv run --env-file .env hydrogen-mcp`. Reconnect the client after changing settings.
| Environment variable | Windows default |
| --- | --- |
| `HYDROGEN_INSTALL_DIR` | `C:/Program Files/Hydrogen` |
| `HYDROGEN_APP` | `hydrogen.exe` in the install directory |
| `HYDROGEN_CLI` | `h2cli.exe` in the install directory |
| `HYDROGEN_OSC_PORT` | `9000` |
| `HYDROGEN_CONFIG` | `~/.hydrogen/hydrogen.conf` |
| `HYDROGEN_USER_DATA` | `~/.hydrogen/data` |
| `HYDROGEN_SYSTEM_DATA` | `data` inside the install directory |
| `HYDROGEN_PROJECT_DIR` | `projects` inside a checkout or `~/Hydrogen Projects` for a wheel install |
The MCP server sends OSC over loopback. Hydrogen controls its own listener, so check its firewall access before using OSC on an untrusted network. Hydrogen resolves the asset references inside songs and kits used for native rendering.
## Verification
CI checks formatting, lint, types, protocol tests, dependencies, and the wheel build on Windows. The optional native suite verifies live OSC, song and kit operations, rendering, stem isolation, and Windows desktop capture and input against Hydrogen itself.
```powershell
uv sync --locked
uv run --locked ruff format --check .
uv run --locked ruff check .
uv run --locked mypy
uv run --locked pytest -q
uv run --locked bandit -q -r src
uv run --locked deptry .
uv run --locked vulture src tests --min-confidence 80
uv run --locked pip-audit --local --progress-spinner off
uv build --no-sources
```
Run the native suite on Windows with a standard Hydrogen installation. The desktop test activates a disposable Hydrogen window.
```powershell
$env:HYDROGEN_NATIVE_TESTS = '1'
uv run --locked pytest -q
```
[Changelog](CHANGELOG.md) · [Verification notes](PLAN.md) · [MIT license](LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues