search_stays
Search for available hotel stays by entering location, dates, guest count, and room requirements to find accommodation options.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| location | Yes | City, airport code, or area to search for stays | |
| check_in_date | Yes | Check-in date (YYYY-MM-DD) | |
| check_out_date | Yes | Check-out date (YYYY-MM-DD) | |
| guests | Yes | Number of guests | |
| rooms | No | Number of rooms | |
| radius_km | No | Search radius in kilometers |
Implementation Reference
- src/server.ts:186-201 (handler)MCP tool handler for 'search_stays' that invokes the DuffelStaysClient searchOffers method and formats the JSON response for MCP.async (params: StaySearch) => { try { const response = await staysClient.searchOffers(params); return { content: [ { type: 'text', text: JSON.stringify(response, null, 2) } ] }; } catch (error) { console.error(`Error searching stays: ${error}`); throw error; } }
- src/models/staySearch.ts:4-11 (schema)Zod schema defining the input parameters for the search_stays tool.export const staySearchSchema = z.object({ location: z.string().describe('City, airport code, or area to search for stays'), check_in_date: z.string().describe('Check-in date (YYYY-MM-DD)'), check_out_date: z.string().describe('Check-out date (YYYY-MM-DD)'), guests: z.number().int().min(1).describe('Number of guests'), rooms: z.number().int().min(1).optional().describe('Number of rooms'), radius_km: z.number().optional().describe('Search radius in kilometers'), });
- src/server.ts:183-202 (registration)Registration of the 'search_stays' tool on the MCP server using server.tool() with schema and handler.server.tool( 'search_stays', staySearchSchema.shape, async (params: StaySearch) => { try { const response = await staysClient.searchOffers(params); return { content: [ { type: 'text', text: JSON.stringify(response, null, 2) } ] }; } catch (error) { console.error(`Error searching stays: ${error}`); throw error; } } );
- src/api/duffelStaysClient.ts:60-81 (helper)Implementation of the stay search logic in DuffelStaysClient, making API call to Duffel and processing the response.async searchOffers(params: StaySearchParams): Promise<StayOfferResponse> { // Duffel API docs: https://duffel.com/docs/api/v2/offers const response = await this.client.post('/offers', { location: params.location, check_in_date: params.check_in_date, check_out_date: params.check_out_date, guests: params.guests, rooms: params.rooms, radius_km: params.radius_km, }); // Adapt to Duffel's real response structure const offers = (response.data.data || []).map((offer: any) => ({ offer_id: offer.id, hotel_id: offer.hotel?.id || '', hotel_name: offer.hotel?.name || '', address: offer.hotel?.address?.line_1 || '', price: offer.total_amount ? { amount: offer.total_amount, currency: offer.currency } : { amount: '', currency: '' }, room_type: offer.room_type || '', cancellation_policy: offer.cancellation_policy || '', })); return { offers }; }