mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 03:02:56 +00:00
52 lines
1.3 KiB
JavaScript
Executable File
52 lines
1.3 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
/**
|
|
* Print a ready-to-paste MCP server config with absolute paths filled in.
|
|
*
|
|
* Usage:
|
|
* node scripts/print-mcp-config.mjs /path/to/binary
|
|
* node scripts/print-mcp-config.mjs /path/to/binary --kind database
|
|
* node scripts/print-mcp-config.mjs /path/to/binary --loader-args '["-l","Mach-O","--aarch64"]'
|
|
*/
|
|
import { resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const targetPath = process.argv[2];
|
|
if (!targetPath) {
|
|
process.stderr.write(
|
|
"Usage: node scripts/print-mcp-config.mjs <target-path> [--kind executable|database] [--loader-args JSON]\n",
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
const flags = process.argv.slice(3);
|
|
const kind = readFlag(flags, "--kind") ?? "executable";
|
|
const loaderArgs = readFlag(flags, "--loader-args");
|
|
|
|
const serverPath = resolve(
|
|
fileURLToPath(new URL("..", import.meta.url)),
|
|
"dist/main.js",
|
|
);
|
|
|
|
const env = {
|
|
HOPPER_TARGET_PATH: resolve(targetPath),
|
|
HOPPER_TARGET_KIND: kind,
|
|
};
|
|
if (loaderArgs) env.HOPPER_LOADER_ARGS_JSON = loaderArgs;
|
|
|
|
const config = {
|
|
mcpServers: {
|
|
betterBinaryMCP: {
|
|
command: "node",
|
|
args: [serverPath],
|
|
env,
|
|
},
|
|
},
|
|
};
|
|
|
|
process.stdout.write(`${JSON.stringify(config, null, 2)}\n`);
|
|
|
|
function readFlag(args, name) {
|
|
const i = args.indexOf(name);
|
|
return i !== -1 ? args[i + 1] : undefined;
|
|
}
|