def find_rust_binary() -> str | None:
import os
import shutil
from pathlib import Path
if "COREASON_META_MCP_BINARY" in os.environ:
p = Path(os.environ["COREASON_META_MCP_BINARY"])
if p.exists():
return str(p.resolve())
workspace_root = os.environ.get("COREASON_WORKSPACE_ROOT")
if workspace_root:
workspace_dir = Path(workspace_root)
for folder in ("release", "debug"):
for ext in (".exe", ""):
p = workspace_dir / "coreason-meta-engineering" / "target" / folder / f"coreason-meta-mcp{ext}"
if p.exists():
return str(p.resolve())
return shutil.which("coreason-meta-mcp")
def main() -> None:
import subprocess
import sys
rust_binary = find_rust_binary()
if rust_binary:
res = subprocess.run([rust_binary], stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr) sys.exit(res.returncode)
print(
"Error: coreason-meta-mcp binary not found.\n"
"Build it with: cargo build --release\n"
"Or set COREASON_META_MCP_BINARY environment variable.",
file=sys.stderr,
)
sys.exit(1)
if __name__ == "__main__": main()