Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
hotel_idYesHotel ID from search_hotels results
check_inYesCheck-in date in YYYY-MM-DD format
check_outYesCheck-out date in YYYY-MM-DD format
guest_first_nameYesPrimary guest first name
guest_last_nameYesPrimary guest last name
guest_emailYesGuest email for booking confirmation
payment_methodYesPayment method (e.g. 'credit_card', 'debit_card')

Implementation Reference

  • 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: {
  • 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",
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. Adds valuable context about post-booking behavior (Price Drop Guarantee) and implies financial/sensitive data handling, but omits idempotency, cancellation policy, return value structure, or error states for this destructive operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences with clear front-loading of core action. Efficient structure, though the Price Drop Guarantee sentence provides platform context rather than tool behavior, slightly diluting focus.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for basic invocation but incomplete for a financial transaction tool: lacks description of return values (confirmation data, errors), auth requirements, or modification capabilities given zero annotations and no output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, establishing baseline 3. Description adds semantic grouping ('guest details and payment information') but does not extend individual parameter semantics beyond what schema already documents (e.g., no format examples for payment_method).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States specific verb ('Initiate') + resource ('hotel booking') + platform ('Hopper'), clearly distinguishing from siblings like 'search_hotels' (query vs. transaction) and 'book_flight' (different resource).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Implies prerequisites via 'Requires guest details and payment information,' indicating when the tool is ready to use, but lacks explicit comparison to siblings (e.g., 'Use search_hotels first to obtain hotel_id').

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/markswendsen-code/mcp-hopper'

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