Skip to main content
Glama
raoulbia-ai

MCP Server for Intercom

search_tickets_by_customer

Retrieve customer support tickets by email or ID with optional date filters to analyze their interaction history efficiently within the MCP Server for Intercom.

Instructions

Searches for tickets by customer email or ID with optional date filtering.

Required: customerIdentifier (email/ID) Optional: startDate, endDate (DD/MM/YYYY format)

Use when analyzing a customer's support history.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customerIdentifierYesCustomer email or ID to search for
endDateNoOptional end date in DD/MM/YYYY format (e.g., '21/01/2025')
startDateNoOptional start date in DD/MM/YYYY format (e.g., '15/01/2025')

Implementation Reference

  • The main handler function in ToolHandlers class that executes the tool: validates args with schema, fetches tickets via IntercomService.getTicketsByCustomer, formats MCP-compliant response, and handles errors.
    async handleSearchTicketsByCustomer(args: unknown) {
        try {
            console.error("Handling search_tickets_by_customer request");
            
            // Validate and parse arguments
            const validatedArgs = SearchTicketsByCustomerSchema.parse(args);
            
            const customerIdentifier = validatedArgs.customerIdentifier;
            const startDateStr = validatedArgs.startDate;
            const endDateStr = validatedArgs.endDate;
            
            // Create Intercom service and retrieve tickets
            const intercomService = new IntercomService(this.API_BASE_URL, this.authToken);
            const tickets = await intercomService.getTicketsByCustomer(
                customerIdentifier,
                startDateStr,
                endDateStr
            );
            
            console.error(`Retrieved ${tickets.length} tickets for customer: ${customerIdentifier}`);
            
            return this.formatResponse(tickets);
        } catch (error) {
            console.error('Error handling search_tickets_by_customer:', error);
            
            // Enhanced error message for validation errors
            if (error instanceof Error && error.message.includes("customerIdentifier")) {
                return this.formatErrorResponse(error, 
                    `${error.message}\n\nPlease provide a valid customer email or ID, and optional dates in DD/MM/YYYY format (e.g., 15/01/2025)`
                );
            }
            
            return this.formatErrorResponse(error);
        }
    }
  • Zod schema defining and validating input parameters for the tool: required customerIdentifier (email/ID), optional startDate/endDate with DD/MM/YYYY format validation and transformation to ISO.
    export const SearchTicketsByCustomerSchema = z.object({
        // Required customer identifier parameter
        customerIdentifier: z.string({
            required_error: "customerIdentifier is required (email or ID)"
        }),
        
        // Optional date range parameters in DD/MM/YYYY format
        startDate: z.string().optional().refine(val => !val || /^\d{2}\/\d{2}\/\d{4}$/.test(val), {
            message: "startDate must be in DD/MM/YYYY format (e.g., 15/01/2025)"
        }),
        
        endDate: z.string().optional().refine(val => !val || /^\d{2}\/\d{2}\/\d{4}$/.test(val), {
            message: "endDate must be in DD/MM/YYYY format (e.g., 21/01/2025)"
        })
    }).transform(data => {
        console.error("Raw arguments received:", JSON.stringify(data));
        
        try {
            // Convert DD/MM/YYYY to ISO strings if provided
            if (data.startDate) {
                data.startDate = validateAndTransformDate(data.startDate, true);
            }
            
            if (data.endDate) {
                data.endDate = validateAndTransformDate(data.endDate, false);
            }
            
            // Validate date range if both dates are provided
            if (data.startDate && data.endDate) {
                validateDateRange(data.startDate, data.endDate);
            }
            
        } catch (e) {
            // Throw error to be caught by the handler
            console.error(`Error processing date parameters: ${e}`);
            throw new Error(`${e instanceof Error ? e.message : 'Invalid date format'} - Please provide dates in DD/MM/YYYY format (e.g., 15/01/2025)`);
        }
        
        console.error("Final parameters:", JSON.stringify(data));
        return data;
    });
  • src/index.ts:73-93 (registration)
    MCP server capabilities registration declaring the tool's description and input schema for protocol advertisement.
    search_tickets_by_customer: {
        description: "Searches for tickets by customer email or ID with optional date filtering.",
        parameters: {
            type: "object",
            required: ["customerIdentifier"],
            properties: {
                customerIdentifier: {
                    type: "string",
                    description: "Customer email or ID to search for"
                },
                startDate: {
                    type: "string",
                    description: "Optional start date in DD/MM/YYYY format (e.g., '15/01/2025')"
                },
                endDate: {
                    type: "string",
                    description: "Optional end date in DD/MM/YYYY format (e.g., '21/01/2025')"
                }
            }
        }
    },
  • Dispatch logic in call_tool request handler that routes execution to the specific tool handler method.
    case "search_tickets_by_customer":
        console.error("Handling search_tickets_by_customer request");
        return await toolHandlers.handleSearchTicketsByCustomer(args);
  • Tool metadata returned in list_tools response, including detailed description and input schema.
                    {
                        name: "search_tickets_by_customer",
                        description: `Searches for tickets by customer email or ID with optional date filtering.
    
    Required: customerIdentifier (email/ID)
    Optional: startDate, endDate (DD/MM/YYYY format) 
    
    Use when analyzing a customer's support history.`,
                        inputSchema: {
                            type: "object",
                            required: ["customerIdentifier"],
                            properties: {
                                customerIdentifier: {
                                    type: "string",
                                    description: "Customer email or ID to search for"
                                },
                                startDate: {
                                    type: "string",
                                    description: "Optional start date in DD/MM/YYYY format (e.g., '15/01/2025')"
                                },
                                endDate: {
                                    type: "string",
                                    description: "Optional end date in DD/MM/YYYY format (e.g., '21/01/2025')"
                                }
                            }
                        },
                    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions the tool is for searching (implying read-only), it doesn't disclose important behavioral traits like whether this is a safe read operation, if it requires specific permissions, rate limits, pagination behavior, or what the response format looks like. The description adds minimal behavioral context beyond the basic function.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with three sentences that are front-loaded with the core purpose. Each sentence earns its place by providing purpose, parameter guidance, and usage context. Minor improvements could include combining the parameter details into a single sentence for better flow.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is somewhat complete but has gaps. It covers the purpose and basic usage but lacks details on behavioral traits, response format, and explicit differentiation from sibling tools. The absence of annotations and output schema increases the need for more comprehensive description, which isn't fully met.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents all parameters. The description adds some value by explicitly labeling parameters as 'Required' and 'Optional' and specifying the date format, but this information is largely redundant with the schema. The baseline score of 3 reflects adequate but not exceptional added semantic value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool searches for tickets by customer email or ID with optional date filtering, providing a specific verb ('searches') and resource ('tickets'). It distinguishes from sibling tools like 'search_tickets_by_status' by specifying customer-based search, though it doesn't explicitly mention how it differs from 'search_conversations_by_customer' beyond the resource type.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use the tool ('when analyzing a customer's support history'), which helps guide usage. However, it doesn't explicitly state when NOT to use it or mention specific alternatives among the sibling tools, such as when to choose 'search_conversations_by_customer' instead.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/raoulbia-ai/mcp-server-for-intercom'

If you have feedback or need assistance with the MCP directory API, please join our Discord server