Every `doctor`, `mcp doctor` and MCP server that reports or compares its catalog identity rebuilt all advertised JSON Schemas and canonicalized them to compute the default digests, about 200 ms of CPU per process. The default (full input and output schema) catalog is a deterministic function of the compiled contracts and pinned schema converter, so compilation now records it once into dist and the runtime reuses it. Compact and output-schema-off identities, and source runs, still compute their digests on first use. Refs #3813 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
861 B
JavaScript
20 lines
861 B
JavaScript
import { writeFile } from "node:fs/promises";
|
|
import { dirname, join, resolve } from "node:path";
|
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
|
// Record the default catalog digests into the compiled runtime. Run after
|
|
// `tsc` and before bundling, so the digests come from the same compiled
|
|
// contracts and pinned schema converter that the runtime serves.
|
|
const compiledRoot = resolve(
|
|
dirname(fileURLToPath(import.meta.url)),
|
|
"../dist",
|
|
);
|
|
const { createCatalogDigests } = await import(
|
|
pathToFileURL(join(compiledRoot, "catalogIdentity.js")).href
|
|
);
|
|
await writeFile(
|
|
join(compiledRoot, "recordedCatalogDigests.js"),
|
|
`/** Recorded from the compiled default catalog by scripts/record-catalog-digests.mjs; do not edit. */\nexport const RECORDED_CATALOG_DIGESTS = Object.freeze(${JSON.stringify(createCatalogDigests())});\n`,
|
|
"utf8",
|
|
);
|