import { T as ToolManifest, O as OpenApiDocument } from '../generate-BCDqBUjZ.js'; /** * `@12-apps/mcp/generate` — the `mcp:generate` / `mcp:check` gate (12-23), moved * out of the origin host's `apps/web/scripts/mcp/generate.ts` so a host's own script is * a one-line call and `12-apps/ci`'s `mcp-contract.yml`, which shells out to the * consumer's `mcp:check` package script, keeps working unchanged. * * It renders the committed surface artifacts from the host's OpenAPI document: * * openapi.json — the document itself, canonicalized * manifest.json — the MCP tool manifest generated from it * surface-lock.json — which surface the current version stands for * * With `check: true` it regenerates IN MEMORY and fails on any drift — the same * command CI runs, so a forgotten regeneration is a red build rather than a tool * list that silently disagrees with the endpoints. * * It ALSO refuses, in both modes, to emit a tool surface that changed while the * advertised VERSION did not. That version is the only signal a connected host has * that `tools/list` is worth re-reading, so a shipped tool behind an unmoved * version is invisible to every client that already cached it — and "remember to * bump it" as a comment is not a rule (see `server/surface-lock.ts`). */ /** One extra artifact a host renders from the same manifest, e.g. a store submission. */ interface McpExtraArtifact { /** Absolute path of the committed file. */ path: string; /** Rendered text, INCLUDING its trailing newline (compared byte for byte). */ render: (manifest: ToolManifest) => string; } interface McpGenerateOptions { /** * The host's OpenAPI document, or a thunk producing it. A thunk is the useful * form: building it usually evaluates a Zod registry, and `--check` should pay * that cost once, when it runs. */ document: OpenApiDocument | (() => OpenApiDocument); /** * The advertised surface version — the number a client is handed on `initialize` * and caches `tools/list` against. */ version: number; /** Human label for the spec the tools were generated from. */ source: string; /** * Where the host's version constant lives, repo-relative — quoted verbatim in * the surface-lock failure, so the fix is a path and a value rather than a hunt. */ versionLocation: string; /** The constant's name, if the host does not call it `MCP_SURFACE_VERSION`. */ versionName?: string; /** Where the three artifacts are committed. */ outputs: { openapi: string; manifest: string; surfaceLock: string; }; /** Anything else the host commits from the same manifest. */ extraArtifacts?: readonly McpExtraArtifact[]; } /** The rendered text of every artifact, keyed by its committed path. */ type RenderedArtifacts = Map; interface McpGenerateResult { artifacts: RenderedArtifacts; /** Non-null when the surface moved without a version bump — the message to print. */ surfaceProblem: string | null; } /** * Render every artifact from the document. Pure: nothing is written and nothing is * compared, so a caller can diff, print or discard the result. */ declare function renderMcpArtifacts(options: McpGenerateOptions): McpGenerateResult; /** Every artifact whose committed text differs from a fresh render. */ declare function mcpArtifactDrift(artifacts: RenderedArtifacts): string[]; /** Write every artifact, creating directories as needed. */ declare function writeMcpArtifacts(artifacts: RenderedArtifacts): void; interface McpGenerateCliOptions extends McpGenerateOptions { /** `true` for `mcp:check` (verify only), `false` for `mcp:generate` (write). */ check: boolean; /** The command to suggest on drift. Default: `pnpm mcp:generate`. */ regenerateCommand?: string; } /** * The CLI face: render, then either verify or write, printing the verdict and * exiting non-zero on any failure. A host's `scripts/mcp/generate.ts` becomes an * import, its document builder, and one call. */ declare function mcpGenerateCli(options: McpGenerateCliOptions): void; export { type McpExtraArtifact, type McpGenerateCliOptions, type McpGenerateOptions, type McpGenerateResult, type RenderedArtifacts, mcpArtifactDrift, mcpGenerateCli, renderMcpArtifacts, writeMcpArtifacts };