@mthines/reaper-mcp 0.100.1 → 0.100.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/main.js CHANGED
@@ -5362,6 +5362,23 @@ var MIN_PYTHON_MINOR = 10;
5362
5362
  function getPythonBin() {
5363
5363
  return process.env["PYTHON_BIN"] ?? "python3";
5364
5364
  }
5365
+ var WINDOWS_PYTHON_CANDIDATES = ["python3", "python", "py"];
5366
+ async function resolvePythonBin(isWindows = platform2() === "win32") {
5367
+ const configured = getPythonBin();
5368
+ if (process.env["PYTHON_BIN"] || !isWindows) return configured;
5369
+ let tooOld = null;
5370
+ for (const candidate of WINDOWS_PYTHON_CANDIDATES) {
5371
+ try {
5372
+ await checkPython(candidate);
5373
+ return candidate;
5374
+ } catch (err) {
5375
+ if (!tooOld && err instanceof Error && err.message.startsWith(`Python ${MIN_PYTHON_MAJOR}.${MIN_PYTHON_MINOR}+ required`)) {
5376
+ tooOld = candidate;
5377
+ }
5378
+ }
5379
+ }
5380
+ return tooOld ?? configured;
5381
+ }
5365
5382
  function parsePythonVersion(output) {
5366
5383
  const match = output.match(/Python\s+(\d+)\.(\d+)\.(\d+)/i);
5367
5384
  if (!match) return null;
@@ -5407,9 +5424,12 @@ function resolveRequirementsTxt(baseDir) {
5407
5424
  const sidecarDir = resolveAssetDir(baseDir, "sidecar");
5408
5425
  return join5(sidecarDir, "requirements.txt");
5409
5426
  }
5427
+ function pipUpgradeCommand() {
5428
+ return `"${join5(SIDECAR_VENV_PATH, VENV_BIN, VENV_PYTHON_NAME)}" -m pip install --upgrade pip`;
5429
+ }
5410
5430
  async function installDeps(requirementsPath) {
5411
5431
  const pip = join5(SIDECAR_VENV_PATH, VENV_BIN, VENV_PIP_NAME);
5412
- await exec(`"${pip}" install --upgrade pip`);
5432
+ await exec(pipUpgradeCommand());
5413
5433
  const { stdout, stderr } = await exec(`"${pip}" install -r "${requirementsPath}"`);
5414
5434
  if (stdout) process.stdout.write(stdout);
5415
5435
  if (stderr) process.stderr.write(stderr);
@@ -5697,7 +5717,7 @@ Installing sidecar scripts to: ${SIDECAR_DIR}`);
5697
5717
  console.log("\nRun `reaper-mcp doctor` to verify.\n");
5698
5718
  }
5699
5719
  async function installCore() {
5700
- const pythonBin = getPythonBin();
5720
+ const pythonBin = await resolvePythonBin();
5701
5721
  console.log(`
5702
5722
  Checking Python interpreter: ${pythonBin}`);
5703
5723
  let version = "";
@@ -5962,7 +5982,10 @@ var SidecarClientImpl = class {
5962
5982
  } catch {
5963
5983
  }
5964
5984
  const child = spawn(VENV_PYTHON, [SIDECAR_SCRIPT_PATH], {
5965
- stdio: ["pipe", "pipe", "pipe"]
5985
+ stdio: ["pipe", "pipe", "pipe"],
5986
+ // Requests and responses are UTF-8; on Windows Python would otherwise use cp1252 and garble
5987
+ // non-ASCII paths. PYTHONUTF8 also covers any process the sidecar starts.
5988
+ env: { ...process.env, PYTHONUTF8: "1", PYTHONIOENCODING: "utf-8" }
5966
5989
  });
5967
5990
  if (child.stdout) {
5968
5991
  child.stdout.setEncoding("utf8");
@@ -11984,7 +12007,7 @@ async function doctor() {
11984
12007
  let pythonOk = false;
11985
12008
  let pythonDetail = "Not found";
11986
12009
  try {
11987
- const pythonBin = process.env["PYTHON_BIN"] ?? "python3";
12010
+ const pythonBin = await resolvePythonBin();
11988
12011
  const { stdout, stderr } = await execAsync(`"${pythonBin}" --version`);
11989
12012
  const versionStr = (stdout + stderr).trim();
11990
12013
  const match = versionStr.match(/Python\s+(\d+)\.(\d+)/i);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mthines/reaper-mcp",
3
- "version": "0.100.1",
3
+ "version": "0.100.2",
4
4
  "type": "module",
5
5
  "description": "MCP server for controlling REAPER DAW — real-time mixing, FX control, and frequency analysis for AI agents",
6
6
  "license": "MIT",
@@ -73,8 +73,16 @@ local function temp_dir(reaper, env)
73
73
  dir = reaper.GetTempPath()
74
74
  else
75
75
  local t = env.os.tmpname()
76
- dir = t:match("^(.+)[/\\][^/\\]+$") or "/tmp"
76
+ dir = t:match("^(.+)[/\\][^/\\]+$")
77
77
  env.os.remove(t)
78
+ -- Windows' os.tmpname() is a bare name like "\\s3k4." with no folder in it
79
+ if not dir and env.os.getenv then
80
+ for _, var in ipairs({ "TEMP", "TMP" }) do
81
+ local v = env.os.getenv(var)
82
+ if v and v ~= "" then dir = v; break end
83
+ end
84
+ end
85
+ dir = dir or "/tmp"
78
86
  end
79
87
  if dir:sub(-1) ~= "/" and dir:sub(-1) ~= "\\" then dir = dir .. "/" end
80
88
  return dir
package/sidecar/server.py CHANGED
@@ -615,9 +615,19 @@ def dispatch(raw: str) -> str:
615
615
  # Main loop
616
616
  # ---------------------------------------------------------------------------
617
617
 
618
+ def configure_stdio() -> None:
619
+ """Speak UTF-8 on stdin/stdout whatever the locale says.
620
+
621
+ The Node side writes and reads UTF-8. On Windows Python defaults to the locale
622
+ encoding (cp1252), which turns a path like "å" into two wrong characters.
623
+ stdout is line-buffered so responses are delivered immediately.
624
+ """
625
+ sys.stdin.reconfigure(encoding="utf-8")
626
+ sys.stdout.reconfigure(encoding="utf-8", line_buffering=True)
627
+
628
+
618
629
  def main() -> None:
619
- # Disable output buffering so responses are delivered immediately
620
- sys.stdout = os.fdopen(sys.stdout.fileno(), "w", buffering=1)
630
+ configure_stdio()
621
631
 
622
632
  # Log startup to stderr (visible in MCP server logs)
623
633
  print(f"[reaper-mcp-sidecar] Starting — Python {sys.version}", file=sys.stderr, flush=True)
@@ -475,3 +475,26 @@ def test_separate_method_says_how_to_install_when_demucs_is_missing(tmp_path, mo
475
475
  _write_sine(path, -12)
476
476
  resp = _call("separate", {"path": str(path), "outDir": str(tmp_path / "out")})
477
477
  assert "setup-sidecar --with-separation" in resp["error"]["message"]
478
+
479
+
480
+ def test_configure_stdio_decodes_utf8_even_under_a_cp1252_locale():
481
+ """Windows defaults stdio to cp1252, which turns a UTF-8 "\u00e5" into two characters."""
482
+ import os
483
+ import subprocess
484
+ import sys
485
+
486
+ sidecar_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
487
+ code = (
488
+ "import sys; sys.path.insert(0, sys.argv[1]); import server; server.configure_stdio(); "
489
+ "line = sys.stdin.readline().strip(); "
490
+ "print(sys.stdin.encoding, sys.stdout.encoding, line == 'Bj\\u00e5rn')"
491
+ )
492
+ env = {**os.environ, "PYTHONIOENCODING": "cp1252", "PYTHONUTF8": "0"}
493
+ out = subprocess.run(
494
+ [sys.executable, "-c", code, sidecar_dir],
495
+ input="Bj\u00e5rn\n".encode("utf-8"),
496
+ capture_output=True,
497
+ env=env,
498
+ check=True,
499
+ )
500
+ assert out.stdout.decode("utf-8").split() == ["utf-8", "utf-8", "True"]