eolas-mech-mcp
Version:
A Node.js wrapper for the eolas-mech-mcp Python server.
26 lines (21 loc) • 1.22 kB
JavaScript
const { spawnSync, execSync } = require("child_process");
const path = require("path");
const fs = require("fs");
// Determine the correct python and pip commands to use.
// This helps avoid issues where `python` is not aliased to `python3`.
const pythonCmd = process.platform === 'win32' ? 'python' : 'python3';
function run(command, args, silent = false) {
const options = silent ? { stdio: "ignore" } : { stdio: "inherit" };
const result = spawnSync(command, args, options);
if (result.error || result.status !== 0) {
// If the command fails, exit silently. The MCP client will report the disconnection.
process.exit(result.status || 1);
}
}
// 1. Ensure the Python package `eolas-mech-mcp` is installed to the user's
// local directory. This avoids "externally-managed-environment" errors on
// systems with protected Python installations (PEP 668).
run(pythonCmd, ["-m", "pip", "install", "--quiet", "--disable-pip-version-check", "--upgrade", "--user", "--break-system-packages", "--no-warn-script-location", "eolas-mech-mcp"], true);
// Directly run the package as a module (avoids stale console scripts)
run(pythonCmd, ["-m", "eolas_mech_mcp"], false);