// tools/tool-entry.ts — Declarative ToolEntry type for registry-based tool registration.
//
// Phase 1 (refactor/declarative-registry): replaces the register-*-tools.ts boilerplate pattern:
//   server.registerTool(name, { description, inputSchema, annotations }, safeXxx(name, handler))
// with a plain data array that registerFromEntries() consumes.
import { safe, safeTracked, safeLicensed } from './safe-handler.js';
// ---------------------------------------------------------------------------
// Registration helper
// ---------------------------------------------------------------------------
/**
 * Registers every entry in `entries` onto the MCP server.
 * Applies the safe-handler wrapper declared in entry.wrap (defaults to 'tracked').
 *
 * Drop-in replacement for calling register*Tools(server) on each migrated file.
 */
export function registerFromEntries(server, entries) {
    for (const entry of entries) {
        const { name, description, schema, handler, annotations = {}, wrap = 'tracked' } = entry;
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        let wrappedHandler;
        if (wrap === 'none') {
            wrappedHandler = handler;
        }
        else if (wrap === 'licensed') {
            wrappedHandler = safeLicensed(name, handler);
        }
        else if (wrap === 'safe') {
            wrappedHandler = safe(handler);
        }
        else {
            wrappedHandler = safeTracked(name, handler);
        }
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        const toolConfig = { description, inputSchema: schema, annotations };
        if (entry.outputSchema !== undefined) {
            // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
            toolConfig.outputSchema = entry.outputSchema;
        }
        server.registerTool(name, 
        // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
        toolConfig, 
        // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
        wrappedHandler);
    }
}
//# sourceMappingURL=tool-entry.js.map