// tools/register-webhook-tools.ts — Registers webhook management tools on the MCP server.
// These tools are always accessible (no license gate) — they manage the webhook receiver.
import { z } from 'zod';
import { safe } from './safe-handler.js';
import { handleStartWebhook, handleStopWebhook, handleWebhookStatus } from './webhook.js';
export function registerWebhookTools(server) {
    // start_webhook
    server.registerTool('start_webhook', {
        description: 'Start a local HTTP server to receive Lemon Squeezy webhook events. ' +
            'Configure the server URL in your Lemon Squeezy dashboard under Settings > Webhooks.',
        inputSchema: {
            port: z
                .number()
                .int()
                .min(1)
                .max(65535)
                .optional()
                .describe('Port to listen on (default: 2358)'),
            secret: z
                .string()
                .optional()
                .describe('Webhook secret from Lemon Squeezy dashboard for HMAC-SHA256 signature validation'),
        },
        annotations: { title: 'Start Webhook Server', readOnlyHint: false },
    }, safe((args) => handleStartWebhook(args)));
    // stop_webhook
    server.registerTool('stop_webhook', {
        description: 'Stop the running Lemon Squeezy webhook server.',
        inputSchema: {
            force: z
                .boolean()
                .optional()
                .describe('Force stop even if events are being processed (default: false)'),
        },
        annotations: { title: 'Stop Webhook Server', destructiveHint: false },
    }, safe((args) => handleStopWebhook(args)));
    // webhook_status
    server.registerTool('webhook_status', {
        description: 'Show whether the webhook server is running and display recently received events.',
        inputSchema: {
            includeEvents: z
                .boolean()
                .optional()
                .describe('Include recent event log in the output (default: true)'),
        },
        annotations: { title: 'Webhook Status', readOnlyHint: true },
    }, safe((args) => Promise.resolve(handleWebhookStatus(args))));
}
//# sourceMappingURL=register-webhook-tools.js.map