@whoisxmlapidotcom/mcp-whoisxmlapi
Version:
The official WhoisXML API MCP server: 32 first-party tools for WHOIS, DNS, IP geolocation, threat intel, typosquatting, email verification, and native bulk — in Claude, Cursor, VS Code, or any MCP client.
57 lines (46 loc) • 1.67 kB
JavaScript
import { spawn } from "node:child_process";
import { existsSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const PLATFORM_TARGETS = [
{ platform: "darwin", arch: "x64", key: "darwin-x64" },
{ platform: "darwin", arch: "arm64", key: "darwin-arm64" },
{ platform: "linux", arch: "x64", key: "linux-x64" },
{ platform: "linux", arch: "arm64", key: "linux-arm64" },
{ platform: "linux", arch: "arm", key: "linux-arm" },
{ platform: "win32", arch: "x64", key: "win32-x64" },
{ platform: "win32", arch: "arm64", key: "win32-arm64" }
];
const current = PLATFORM_TARGETS.find(
(target) => target.platform === process.platform && target.arch === process.arch
);
if (!current) {
throw new Error(`Unsupported platform combination: ${process.platform}/${process.arch}`);
}
const binaryName = process.platform === "win32" ? "mcp-whoisxmlapi.exe" : "mcp-whoisxmlapi";
const vendorRoot = path.join(__dirname, "..", "vendor", current.key);
const binaryPath = path.join(vendorRoot, binaryName);
if (!existsSync(binaryPath)) {
throw new Error(
`mcp-whoisxmlapi binary not found for ${current.key}. ` +
"Please reinstall the package or open an issue on GitHub."
);
}
const child = spawn(binaryPath, process.argv.slice(2), {
stdio: "inherit",
env: process.env
});
child.on("error", (err) => {
console.error(err);
process.exit(1);
});
child.on("exit", (code, signal) => {
if (signal) {
process.kill(process.pid, signal);
return;
}
process.exit(code ?? 1);
});