execute_lua
Run Lua code to control REAPER DAW through its ReaScript API, enabling automation and custom functionality within the digital audio workstation.
Instructions
Execute arbitrary Lua code in REAPER.
This gives full control over REAPER via ReaScript.
The code runs in REAPER's Lua environment with access to the reaper.* API.
Args:
code: Lua code to execute
Example:
execute_lua("reaper.ShowMessageBox('Hello from MCP!', 'Test', 0)")
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes |
Implementation Reference
- scythe_mcp/server/main.py:273-290 (handler)MCP tool handler for 'execute_lua'. Decorated with @mcp.tool() for automatic registration. Delegates execution to ReaperBridge instance.@mcp.tool() def execute_lua(ctx: Context, code: str) -> str: """ Execute arbitrary Lua code in REAPER. This gives full control over REAPER via ReaScript. The code runs in REAPER's Lua environment with access to the reaper.* API. Args: code: Lua code to execute Example: execute_lua("reaper.ShowMessageBox('Hello from MCP!', 'Test', 0)") """ bridge = get_bridge() result = bridge.execute_lua(code) return result.get("message", "Lua code executed")
- Core implementation of Lua execution via file-based command to REAPER's Lua script. Writes command to JSON file and polls for response.def execute_lua(self, code: str) -> Dict[str, Any]: """Execute arbitrary Lua code in REAPER.""" self._write_command("execute_lua", {"code": code}) response = self._read_response(timeout=5.0) if response: return response return {"success": True, "message": "Lua code sent for execution"}