/ Cases / Tourism / AI agent
Any AI agent can search tours, check availability, get an exact quote and hold a booking for 48 hours. The person pays on the website.
8
MCP tools
48 h
booking hold
/ The problem
More and more travelers plan with an AI assistant. If the assistant can't see your availability or your exact price, it recommends someone else.
/ What we built
/ How it works
/ Real code
server.registerTool('hold_booking', {
title: 'Hold a booking (unpaid)',
description: 'Reserve a tour under the customer\'s name WITHOUT payment. Returns checkout_url with their details filled in; the person must pay there to confirm. The hold expires in 48 hours if unpaid and does not reserve the departure until paid. Only call this after the person has agreed and given their name and email. Calling it again with the same email, tour and date updates the same hold.',
inputSchema: z.object({
tour_id: tourId, date,
start_time: z.string().describe('HH:MM, one of the tour start times.'),
...people, price_option: priceOption,
customer_name: z.string().min(2).describe('Full name of the person traveling.'),
customer_email: z.string().describe('Their email. Needed later to check the booking status.'),
// …
notes: z.string().max(300).optional().describe('Allergies, special occasion, hotel.'),
lang,
}),
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
}, async (a) => guard(async () => {
// Mismo límite y MISMA clave que POST /api/agent/bookings: 10 por minuto por IP entre las dos puertas.
if (!rateLimit(`${deps.ip}:/api/agent/bookings`, 10, 60000).ok) return { status: 429, body: { error: 'Too many requests. Please try again in a minute.', code: 'rate_limited' } };
// …
return createAgentBooking(deps.supabase(), {
tour_id: a.tour_id, date: a.date, start_time: a.start_time,
adults: a.adults, children: a.children, infants: a.infants, price_option: a.price_option,
customer: { name: a.customer_name, email: a.customer_email, phone: a.customer_phone },
notes: a.notes, lang: a.lang, agent: 'MCP',
});
}));
■ An MCP tool an AI agent can call: it holds the booking unpaid, is idempotent and shares its per-IP rate limit with the REST API.
/ Stack