Skip to main content
Glama
zoom-g3n-mcp

zoom-g3n-mcp

by KerJen
README.md
# zoom-g3n-mcp

**English** | [Русский](README.ru.md)

Let Claude (or any MCP client) build and tweak Zoom G3n patches by talking to the pedal over USB. This is an
[MCP](https://modelcontextprotocol.io) server (Python, stdio) that reads effect chains, changes parameters and effect
types, renames patches, stores them to the pedal's memory and makes backups, all over USB MIDI.

> **Disclaimer.** This is an unofficial project, not affiliated with or endorsed by ZOOM Corporation. The protocol was
> reverse-engineered and has been tested **only on a Zoom G3n with firmware 2.20 on Windows 11**. Use it at your own
> risk and **back up your patches first** (`backup_all`).

## Example conversation (illustrative)

> **You:** Make a shoegaze patch: fuzz into a big hall reverb with a dotted-eighth delay at 81 BPM.

Claude then works out the signal chain with the effect catalog and edits the pedal's current patch:

```
search_effects(query="fuzz")                      -> picks a fuzz effect, reads its parameters
set_effect(slot=2, effect="<fuzz>", params={...}) -> fuzz in slot 2, read back and verified
set_effect(slot=5, effect="<delay>", params={"Time": 556, ...})   # dotted eighth at 81 BPM = 556 ms
set_effect(slot=6, effect="<hall reverb>", params={...})
rename_patch(name="Shoegaze")
store_patch(number=149)                           -> refuses non-empty targets unless overwrite=True
```

Result: *"Patch 149 'Shoegaze': Fuzz > Delay > Hall, stored and verified."*

## Requirements

* A Zoom G3n connected with a USB **data** cable (a charge-only cable makes the pedal invisible).
* Python 3.10 or newer.
* Zoom Guitar Lab installed once. It is used only to download the effect library from which the local effect catalog is
  built. Guitar Lab must be **closed** while the server runs, because only one program can hold the pedal's MIDI port.
* Windows 11 is the tested platform. macOS and Linux should work through `python-rtmidi` but are untested.

## Installation

```bash
git clone https://github.com/KerJen/zoom-g3n-mcp.git
cd zoom-g3n-mcp
python -m venv .venv
.venv/Scripts/pip install -r requirements.txt      # Windows; on macOS/Linux: .venv/bin/pip

# Build the effect catalog from Guitar Lab's local cache (reads local files only)
.venv/Scripts/python tools/build_catalog.py

# Quick read-only check that the pedal answers
.venv/Scripts/python tools/probe.py
```

The effect catalog (`data/g3n_effects.json`) is generated on your machine from Zoom's own files and is not part of this
repository. If it is missing, the server still starts, but tools that need it report: *"Effect catalog not found."*

## Connect to a client

**Claude Code**

```bash
claude mcp add --scope user zoom-g3n -- <path-to>/zoom-g3n-mcp/.venv/Scripts/python.exe <path-to>/zoom-g3n-mcp/server.py
```

(Windows example: `C:\path\to\zoom-g3n-mcp\.venv\Scripts\python.exe C:\path\to\zoom-g3n-mcp\server.py`.)
Alternatively copy `.mcp.json.example` to `.mcp.json` and fix the paths; Claude Code picks it up inside this folder.

**Claude Desktop** (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "zoom-g3n": {
      "command": "<path-to>/zoom-g3n-mcp/.venv/Scripts/python.exe",
      "args": ["<path-to>/zoom-g3n-mcp/server.py"]
    }
  }
}
```

**Other MCP clients:** run `<venv python> server.py` as a stdio server.

The connection to the pedal is opened lazily on the first tool call. On a MIDI error the server closes the port,
reopens it once and retries.

## Tools

| Tool | What it does |
|---|---|
| `g3n_status` | MIDI ports, current patch (number, bank, position), name and effect chain |
| `list_patches(include_empty)` | all stored patches 0..149 with their effect chains (takes several seconds) |
| `get_patch(number)` | full details of a stored patch; no number reads the current edit buffer |
| `select_patch(number)` | switch the pedal to patch 0..149 |
| `set_param(slot, param, value)` | set one parameter by name or index in the current patch, range-checked and verified |
| `set_effect_enabled(slot, enabled)` | turn the effect in a slot on or off |
| `set_effect(slot, effect, params, enabled)` | change the effect type in a slot (name or type id) and optionally set params |
| `search_effects(query, group)` | search the catalog of 166 effects by name, description or group |
| `rename_patch(name)` | rename the current edit buffer (max 10 ASCII characters) |
| `store_patch(number, overwrite)` | store the edit buffer into pedal memory and verify by read-back |
| `backup_all` | save all 150 patches to `backups/g3n_all_patches_<timestamp>.json` |
| `restore_patch(number, backup_file)` | restore one patch from a backup file |
| `disconnect` | release the MIDI port (e.g. to use Guitar Lab); reconnects on the next call |

## Usage tips

* **Slots are 0-based.** Parameter values are raw integers (0..max from the catalog). For example, delay times are in
  milliseconds up to roughly 4000; higher values are tempo-sync codes.
* **Amps and cabinets can occupy two slots.** The second slot shows up as "linked" to the first one and cannot be edited
  on its own; edit the first slot.
* **AUTO SAVE.** The pedal persists edits of the current patch when it switches patches. Treat any edit of the edit
  buffer as potentially permanent. `rename_patch` and parameter edits are not written to memory by the tools themselves
  until `store_patch`, but AUTO SAVE can still save them.
* Call `disconnect` before opening Guitar Lab.

## Safety

* `backup_all` saves every patch to `backups/`; run it before bigger experiments.
* Before overwriting a non-empty patch, its current data is saved automatically to `backups/auto_<time>_patch<N>.json`.
* `store_patch` refuses a non-empty target (name other than `Empty`) unless you pass `overwrite=True`.
* Every write (parameter, effect, name, store, restore) is read back from the pedal; a mismatch is reported as an error.

## Troubleshooting

* **Pedal not visible / "MIDI port not found":** use a USB cable that carries data (not charge-only), connect directly or
  through a powered hub, and make sure the pedal is on.
* **Port busy or no replies:** close Zoom Guitar Lab (and any other MIDI program), then call `disconnect` and retry.
* **"Effect catalog not found":** install Guitar Lab, connect the pedal once so it downloads the effects, then run
  `python tools/build_catalog.py`.
* **Timeouts:** reconnect the cable, power-cycle the pedal, and retry. `list_patches` and `backup_all` read 150 patches
  and take several seconds.

## Matching a reference tone (re-amping)

Describing a tone in words is unreliable, so the `tools/dev/` scripts let Claude *hear* the pedal: a dry recording of
your playing is sent through the pedal, the result is recorded and compared with a reference guitar in numbers, and
the patch is tuned until the numbers converge. You record yourself once; after that everything runs from the chat.

1. **Dry take.** Plug the guitar straight into your audio interface (Hi-Z on) and record 20–30 s of the riff
   (e.g. with `ffmpeg -f dshow -i audio="<input>" di.wav` on Windows). Keep peaks around −6 dBFS: a clipped dry take
   adds fizz of its own.
2. **Wiring.** Interface output → pedal INPUT, pedal OUTPUT → interface input (turn the interface output down).
3. **Reference.** Any track you own; isolate its guitar with a source-separation model such as
   [Demucs](https://github.com/facebookresearch/demucs) (`htdemucs_6s` has a guitar stem).
4. **Measure and tune.**
   ```bash
   pip install -r requirements-tone.txt
   python tools/dev/reamp.py di.wav wet.wav --gain 0                     # check the level
   python tools/dev/tone_metrics.py wet.wav                              # band profile, fizz, mud, attack, noise
   python tools/dev/tone_match.py --di di.wav --ref guitar_stem.wav --ref-start 43 --ref-end 58
   python tools/dev/amp_shootout.py --ref guitar_stem.wav --ref-start 43 --ref-end 58
   ```
   `tone_match.py` changes one knob at a time in the edit buffer, re-amps a 10 s window and keeps the value closest to
   the reference (custom search spaces via `--space steps.json`); nothing is stored to memory.

Lessons from tuning a high-gain patch this way: set gates to detect the **guitar input** (ZNR/NoiseGate `DETCT`), not
the effect input — otherwise the gate never closes behind a high-gain amp; and expect the G3n's own noise floor to
become audible under sustained notes at high gain with a boost in front.

## Project layout

```
server.py            MCP server (13 tools)
g3n/protocol.py      USB-MIDI protocol: SysEx framing, 7-bit packing, CRC, PTCF patch model
g3n/catalog.py       effect catalog loading, lookups, formatting
tools/build_catalog.py   build data/g3n_effects.json from Guitar Lab's cache
tools/probe.py       read-only protocol probe
tools/backup.py      read all patches into backups/
tools/dev/           research scripts (some write to the pedal; see headers)
tests/               offline tests
docs/PROTOCOL.md     the reverse-engineered protocol
```

## Tests

```bash
.venv/Scripts/pip install -r requirements-dev.txt
.venv/Scripts/python -m pytest
```

The tests are offline and need no pedal.

## Protocol

The reverse-engineered protocol is documented in [docs/PROTOCOL.md](docs/PROTOCOL.md).

## Contributing

Issues and pull requests are welcome. Other Zoom "n" or "Four" models may share the protocol; PRs with MIDI captures
and test reports for other pedals and firmware versions are especially welcome.

## License

[MIT](LICENSE)