// engine/registry/mcp-official-publisher.ts — SPEC-273: MCP Official Registry publisher
// Generates mcp-registry-entry.json for registry.modelcontextprotocol.io (Linux Foundation).
import { writeFileSync } from 'node:fs';
import { join } from 'node:path';
/**
 * Generates an MCP Official Registry entry object from the given options.
 *
 * @param options  Configuration for the MCP registry entry.
 * @returns A fully populated McpRegistryEntry ready for serialization.
 */
export function generateMcpRegistryEntry(options) {
    return {
        id: options.id,
        name: options.name,
        description: options.description,
        version: options.version,
        repository: options.repository,
        author: options.author,
        transportTypes: ['stdio'],
        categories: options.categories,
        toolCount: options.tools.length,
    };
}
/**
 * Writes mcp-registry-entry.json to the given project directory.
 *
 * @param projectPath  Absolute path to the project root.
 * @param options      MCP registry options.
 */
export function writeMcpRegistryEntry(projectPath, options) {
    const filePath = join(projectPath, 'mcp-registry-entry.json');
    const entry = generateMcpRegistryEntry(options);
    const content = JSON.stringify(entry, null, 2) + '\n';
    /* v8 ignore start */
    try {
        writeFileSync(filePath, content, 'utf-8');
    }
    catch (err) {
        const msg = err instanceof Error ? err.message : String(err);
        throw new Error(`Failed to write mcp-registry-entry.json to ${filePath}: ${msg}`, {
            cause: err,
        });
    }
    /* v8 ignore stop */
}
//# sourceMappingURL=mcp-official-publisher.js.map