book_hotel
Book hotels through Hopper with guest details and payment. Get Price Drop Guarantee refunds if rates decrease after booking.
Instructions
Initiate a hotel booking on Hopper. Requires guest details and payment information. Hopper's Price Drop Guarantee refunds the difference if prices fall post-booking.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hotel_id | Yes | Hotel ID from search_hotels results | |
| check_in | Yes | Check-in date in YYYY-MM-DD format | |
| check_out | Yes | Check-out date in YYYY-MM-DD format | |
| guest_first_name | Yes | Primary guest first name | |
| guest_last_name | Yes | Primary guest last name | |
| guest_email | Yes | Guest email for booking confirmation | |
| payment_method | Yes | Payment method (e.g. 'credit_card', 'debit_card') |
Implementation Reference
- src/index.ts:392-416 (handler)The async handler function that implements the hotel booking logic by navigating to the Hopper website and checking for authentication requirements.
async function bookHotel(params: BookHotelParams): Promise<string> { const page = await session.newPage(); try { const url = `https://www.hopper.com/hotels/book/${params.hotel_id}`; await page.goto(url, { waitUntil: "domcontentloaded", timeout: 30000 }); await page.waitForTimeout(2000); const pageStatus = await page.evaluate(() => ({ title: document.title, url: window.location.href, requiresAuth: !!document.querySelector("[class*='login'], [class*='signin'], [href*='/login']"), })); if (pageStatus.requiresAuth) { return JSON.stringify({ status: "authentication_required", hotel_id: params.hotel_id, message: "Booking requires a Hopper account. Please sign in at hopper.com.", next_steps: [ "1. Create a free Hopper account at https://www.hopper.com/signup", "2. Search for your hotel and select it", "3. Choose your room type and complete the booking form", "4. Hopper's Price Drop Guarantee refunds the difference if prices fall after booking", ], guest_info_collected: { - src/index.ts:59-66 (schema)The TypeScript interface defining the required parameters for the book_hotel tool.
interface BookHotelParams { hotel_id: string; check_in: string; check_out: string; guest_first_name: string; guest_last_name: string; guest_email: string; payment_method: string; - src/index.ts:683-698 (registration)The registration block where the 'book_hotel' tool is defined for the MCP server, including its description and input schema.
name: "book_hotel", description: "Initiate a hotel booking on Hopper. Requires guest details and payment information. Hopper's Price Drop Guarantee refunds the difference if prices fall post-booking.", inputSchema: { type: "object", properties: { hotel_id: { type: "string", description: "Hotel ID from search_hotels results" }, check_in: { type: "string", description: "Check-in date in YYYY-MM-DD format" }, check_out: { type: "string", description: "Check-out date in YYYY-MM-DD format" }, guest_first_name: { type: "string", description: "Primary guest first name" }, guest_last_name: { type: "string", description: "Primary guest last name" }, guest_email: { type: "string", description: "Guest email for booking confirmation" }, payment_method: { type: "string", description: "Payment method (e.g. 'credit_card', 'debit_card')" }, }, required: [ "hotel_id",