Configuration and IPC
Environment variables
| Variable | Read by | Meaning |
|---|---|---|
REAPER_MCP_DIR | server and bridge | IPC directory. Default: <REAPER resource directory>/reaper-mcp-bridge. Set the same value for both. |
REAPER_MCP_CLOSE_DIALOGS | server | 1 lets the server close REAPER’s blocking windows while it waits (see below). Off by default. |
The default REAPER resource directory is ~/.config/REAPER on Linux, %APPDATA%\REAPER on
Windows and ~/Library/Application Support/REAPER on macOS. The installers also read the
variables listed in Installation.
IPC contract
The server and the bridge exchange files in the IPC directory:
| File | Written by | Content |
|---|---|---|
request.json | server | {"id": "<uuid>", "command": "<name>", "args": {…}} |
response.json | bridge | {"id": "<same uuid>", "ok": true, "result": …} or {"id": …, "ok": false, "error": "…"} |
heartbeat | bridge | Unix time in seconds, rewritten every second |
generation | bridge | ID of the running bridge copy; a newer copy makes the older one stop |
Both sides publish files with an atomic rename, so the other side never reads half a file. The server serializes requests and removes a request that timed out.
Timeouts
| Situation | Timeout |
|---|---|
| Most commands | 5 seconds |
Slow commands: opening, saving and switching projects, adding FX, run_action and others | 5 minutes |
| Rendering | 30 to 60 minutes depending on the tool; timeout_seconds changes it |
| Heartbeat | A heartbeat older than 5 seconds counts as stale. Before giving up the server waits another 5 seconds, because a long REAPER operation stalls the heartbeat. |
Several agents and several REAPER instances
Several MCP clients on one REAPER. Each client starts its own server process; they take turns
through a lock file (client.lock) in the IPC directory, so every request gets its own answer. A
long command (a render, opening a big project) makes the others wait; waiting for the turn counts
against a command’s timeout, and a command that never gets its turn fails with “another MCP client
is using this REAPER”. The operating system releases the lock when a server process ends, also
when it crashes.
Several REAPER instances on one machine. Give each instance its own IPC directory and point each MCP server at the matching one:
REAPER_MCP_DIR=/tmp/reaper-a reaper -newinst & # -newinst: do not hand over to the running REAPER
REAPER_MCP_DIR=/tmp/reaper-b reaper -newinst &
and in the MCP client configuration "env": {"REAPER_MCP_DIR": "/tmp/reaper-a"} for one server,
/tmp/reaper-b for the other. Two instances must not share an IPC directory: the bridge started
later takes over and the earlier one stops answering.
Blocking windows
Some projects make REAPER open a modal window while loading: “Project Load Warning” for project elements this REAPER does not know (old projects, or projects from a newer REAPER), and “Project Settings” for a project that shows its notes on load. Until someone clicks it, REAPER and the bridge stop, and the command times out with “REAPER stopped responding”.
With REAPER_MCP_CLOSE_DIALOGS=1 in the server’s environment, the server closes these two windows
itself when a command finds the bridge stopped for more than 5 seconds: OK on the load warning,
Cancel on project settings. No other window is touched, and the result of the command lists what was
closed in closed_dialogs.
| Platform | How |
|---|---|
| Windows | posts WM_CLOSE to REAPER’s owned dialogs with exactly these titles |
| Linux (X11) | clicks the button with xdotool, which must be installed; the server must see REAPER’s display (DISPLAY) |
| macOS | not supported: close the window in REAPER |