/**
 * Intercom Segments Tools
 */

import { z } from 'zod';
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import type { IntercomClient } from '../clients/intercom.js';

// Tool definitions
export function getTools(client: IntercomClient): Array<{
  definition: Tool;
  handler: (args: Record<string, unknown>) => Promise<unknown>;
}> {
  return [
    {
      definition: {
        name: 'intercom_list_segments',
        description: 'List all segments in your workspace. Segments are predefined groups of contacts or companies.',
        inputSchema: {
          type: 'object',
          properties: {
            include_count: {
              type: 'boolean',
              description: 'Include member count in the response (may slow down request)',
            },
          },
        },
      },
      handler: async (args) => {
        const params = args as { include_count?: boolean };
        return client.listSegments(params);
      },
    },

    {
      definition: {
        name: 'intercom_get_segment',
        description: 'Retrieve a specific segment by ID with detailed information.',
        inputSchema: {
          type: 'object',
          properties: {
            id: {
              type: 'string',
              description: 'Segment ID',
            },
          },
          required: ['id'],
        },
      },
      handler: async (args) => {
        const { id } = args as { id: string };
        return client.getSegment(id as any);
      },
    },
  ];
}
