create_program
Create new travel programs in the LumbreTravel system by specifying program name, start and end dates, and agency ID.
Instructions
Crea un nuevo programa de viajes. Antes de crear un nuevo programa se debe preguntar al si quiere que primero se busque el programa a ver si existe. Si no se especifica la fecha de inicio o fin del programa, no la asumas, pide al usuario que la especifique. Si no se especifica el ID de la agencia, pide al usuario que la especifique.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Nombre del programa | |
| startDate | Yes | Fecha de inicio del programa (DD-MM-YYYY), salvo que el usuario lo indique las fechas siempre deben ser en el futuro | |
| endDate | Yes | Fecha de fin del programa (DD-MM-YYYY), salvo que el usuario lo indique las fechas siempre deben ser en el futuro. Y la fecha de fin debe ser mayor que la fecha de inicio | |
| agencyId | Yes | ID de la agencia a asociar con este programa |
Implementation Reference
- src/handlers/tools.handler.ts:1170-1191 (handler)Handler function for the 'create_program' tool. Extracts arguments, formats dates, calls apiService.createProgram, and returns formatted response.case 'create_program': { const { name, startDate, endDate, agencyId } = args const program = await this.apiService.createProgram({ name, startDate: formatDate(startDate), endDate: formatDate(endDate), agency: { id: agencyId } }) return { content: [{ type: 'text', text: `Programa "${name}" creado exitosamente.\n\nDetalles del programa:\n${JSON.stringify(program, null, 2)}` }] } }
- Input schema definition and description for the 'create_program' tool in the listTools response.name: 'create_program', description: 'Crea un nuevo programa de viajes. Antes de crear un nuevo programa se debe preguntar al si quiere que primero se busque el programa a ver si existe. Si no se especifica la fecha de inicio o fin del programa, no la asumas, pide al usuario que la especifique. Si no se especifica el ID de la agencia, pide al usuario que la especifique.', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Nombre del programa' }, startDate: { type: 'string', description: 'Fecha de inicio del programa (DD-MM-YYYY), salvo que el usuario lo indique las fechas siempre deben ser en el futuro' }, endDate: { type: 'string', description: 'Fecha de fin del programa (DD-MM-YYYY), salvo que el usuario lo indique las fechas siempre deben ser en el futuro. Y la fecha de fin debe ser mayor que la fecha de inicio' }, agencyId: { type: 'string', description: 'ID de la agencia a asociar con este programa' } }, required: ['name', 'startDate', 'endDate', 'agencyId'] } },
- src/services/api.service.ts:106-119 (helper)Helper method in ApiService that performs the HTTP POST request to the backend API endpoint for creating a program.async createProgram (data: { name: string startDate: string endDate: string agency: { id: string } }) { const headers = await this.getHeaders() const response = await fetch(`${API_CONFIG.baseUrl}/integrations/mcp/programs/create`, { method: 'POST', headers: { ...headers, 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) return await this.handleResponse<any>(response) }
- src/index.ts:42-47 (registration)Registers the callTool handler on the MCP server, which dispatches to the specific tool handler based on name, including 'create_program'.// Configure handlers for tools this.server.setRequestHandler( CallToolRequestSchema, async (request) => await this.toolsHandler.callTool(request.params.name, request.params.arguments, this.server) )
- src/utils/date.utils.ts:4-45 (helper)Utility function formatDate used in the handler to convert input dates to DD-MM-YYYY format before sending to API.export function formatDate (dateStr: unknown): string { // Type validation if (typeof dateStr !== 'string') { throw new McpError( ErrorCode.InvalidParams, 'Date must be a string in YYYY-MM-DD format' ) } // Try to parse the date with different formats const formats = [ 'YYYY-MM-DD', 'MM/DD/YYYY', 'DD MMMM YYYY', 'YYYY-MM-DDTHH:mm:ss.SSSZ', 'DD-MM-YYYY' ] const parsedDate = moment(dateStr, formats, true) // Check if the date is valid if (!parsedDate.isValid()) { throw new McpError( ErrorCode.InvalidParams, `Invalid date format: ${dateStr}` ) } // Additional validation for impossible dates const month = parsedDate.month() + 1 // moment uses 0-11 for months const day = parsedDate.date() if (month > 12 || month < 1 || day > 31 || day < 1) { throw new McpError( ErrorCode.InvalidParams, `Invalid date format: ${dateStr}` ) } // Return in the desired format return parsedDate.format('DD-MM-YYYY') }