// `archilyzer mcp [args…]` — start the MCP server, exactly as // `pnpm --filter yt-dlp-transcript-mcp exec tsx src/index.ts [args…]` does: // mcp's own tsx, cwd mcp/, the environment passed through untouched (the // server reads TRANSCRIPT_SITE_URL / TRANSCRIPT_HUB_URL / TRANSCRIPT_LOCAL_DIR, // ARCHILYZER_EDITOR_URL and WORKER_TOKEN from it), stdio inherited. // // A CHILD, never an import: the mcp package depends on common, so common // importing mcp would make the dependency a cycle. And NOTHING may be printed // to stdout on the way in — stdout is the JSON-RPC channel. import { existsSync } from "node:fs"; import path from "node:path"; import { REPO_ROOT, runChild, tsxFor } from "./_spawnBin"; export async function main(argv: string[], root = REPO_ROOT): Promise { const dir = path.join(root, "mcp"); const entry = path.join(dir, "src", "index.ts"); if (!existsSync(entry)) { console.error(`mcp: no MCP server at ${entry}`); return 1; } return runChild({ command: tsxFor(dir), args: ["src/index.ts", ...argv], cwd: dir }); }