← Files VeraARCHIVED FILE
scripts/run_component_mcp.cjs
1.81 KB · Oct 3, 2026 · 06:30 UTC
#!/usr/bin/env node
"use strict";
const fs = require("node:fs");
const path = require("node:path");
const { spawn } = require("node:child_process");
const COMPONENTS = new Set([
"archive-organization",
"open-item-reconciliation",
"client-file-preparation",
"new-client",
"journal-sampling",
"check-entries",
"journal-bank-reconciliation",
"sales-plan",
"variance-analysis",
"financial-analysis",
"report-builder",
"concordato-plan-review",
"prompt-optimizer",
"deep-research-validator",
"previdenza-inps",
"registro-imprese-sari",
"bilancio-xbrl-it",
"studio-archive",
]);
const component = process.argv[2];
if (!COMPONENTS.has(component)) {
process.stderr.write(`Unknown Vera module: ${component || "<missing>"}\n`);
process.exit(2);
}
const pluginRoot = path.resolve(__dirname, "..");
const packagedRoot = path.join(pluginRoot, "modules", component);
const sourceRoot = path.resolve(pluginRoot, "..", component);
const componentRoot = fs.existsSync(packagedRoot) ? packagedRoot : sourceRoot;
const serverCandidates = [
path.join(componentRoot, "mcp", "server.cjs"),
path.join(componentRoot, "scripts", "review_mcp_server.cjs"),
];
const serverPath = serverCandidates.find((candidate) => fs.existsSync(candidate));
if (!serverPath) {
process.stderr.write(
`MCP server not found for ${component}: ${serverCandidates.join(", ")}\n`,
);
process.exit(2);
}
const child = spawn(process.execPath, [serverPath, "--stdio"], {
cwd: componentRoot,
env: { ...process.env, VERA_COMPONENT_HOST: "1" },
stdio: "inherit",
});
child.on("error", (error) => {
process.stderr.write(`Could not start ${component}: ${error.message}\n`);
process.exit(1);
});
child.on("exit", (code, signal) => {
if (signal) {
process.kill(process.pid, signal);
return;
}
process.exit(code ?? 1);
});
SHA-256: 462830fa289a74521cba0d53b5e113c5e0d8f392022292e412b1f59375747617