@danielsogl/lighthouse-mcp
Version:
A comprehensive Model Context Protocol (MCP) server that provides web performance auditing, accessibility testing, SEO analysis, security assessment, and Core Web Vitals monitoring using Google Lighthouse. Enables LLMs and AI agents to perform detailed we
66 lines (65 loc) • 2.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseCliArgs = parseCliArgs;
const node_util_1 = require("node:util");
const node_path_1 = require("node:path");
function parseCliArgs(argv) {
const { values } = (0, node_util_1.parseArgs)({
args: argv,
allowPositionals: true,
strict: false,
options: {
headless: { type: "boolean" },
"no-headless": { type: "boolean" },
"user-data-dir": { type: "string" },
"profile-directory": { type: "string" },
"profile-path": { type: "string" },
"chrome-port": { type: "string" },
"remote-debugging-port": { type: "string" },
"chrome-flag": { type: "string", multiple: true },
},
});
const config = {
extraChromeFlags: [],
};
if (typeof values.headless === "boolean") {
config.headless = values.headless;
}
if (values["no-headless"]) {
config.headless = false;
}
if (typeof values["user-data-dir"] === "string") {
config.userDataDir = values["user-data-dir"];
}
if (typeof values["profile-directory"] === "string") {
config.profileDirectory = values["profile-directory"];
}
if (typeof values["profile-path"] === "string") {
config.userDataDir = (0, node_path_1.dirname)(values["profile-path"]);
config.profileDirectory = (0, node_path_1.basename)(values["profile-path"]);
}
const chromePort = parsePort(values["chrome-port"]);
const remoteDebuggingPort = parsePort(values["remote-debugging-port"]);
const resolvedPort = remoteDebuggingPort ?? chromePort;
if (resolvedPort) {
config.remoteDebuggingPort = resolvedPort;
}
const extraFlags = values["chrome-flag"];
if (Array.isArray(extraFlags)) {
config.extraChromeFlags = extraFlags.filter((flag) => typeof flag === "string");
}
else if (typeof extraFlags === "string") {
config.extraChromeFlags = [extraFlags];
}
return config;
}
function parsePort(value) {
if (typeof value !== "string") {
return undefined;
}
const port = Number(value);
if (!Number.isFinite(port) || port <= 0) {
return undefined;
}
return port;
}