Skip to main content
Glama

search_stays

Find and book hotels by specifying location, dates, guests, and rooms to plan travel accommodations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationYesCity, airport code, or area to search for stays
check_in_dateYesCheck-in date (YYYY-MM-DD)
check_out_dateYesCheck-out date (YYYY-MM-DD)
guestsYesNumber of guests
roomsNoNumber of rooms
radius_kmNoSearch radius in kilometers

Implementation Reference

  • The main handler function for the 'search_stays' tool, which invokes the DuffelStaysClient.searchOffers method and formats the response as MCP content.
    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; } }
  • Zod schema definition for the input parameters of the search_stays tool (staySearchSchema).
    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:184-202 (registration)
    Registration of the 'search_stays' tool on the MCP server using server.tool(), including the inline handler.
    '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; } } );
  • The searchOffers method in DuffelStaysClient that performs the actual API call to Duffel's stays endpoint and processes the response into StayOffer format.
    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 }; }

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/AkekaratP/flights-mcp-ts'

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