Skip to main content
Glama

search_hotels

Find hotels with price predictions, ratings, amenities, and buy/wait recommendations for your travel dates and destination.

Instructions

Search for hotels on Hopper with price predictions. Returns hotel options with ratings, amenities, and Hopper's buy/wait recommendation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
destinationYesCity name or destination (e.g. Paris, New York, Tokyo)
check_inYesCheck-in date in YYYY-MM-DD format
check_outYesCheck-out date in YYYY-MM-DD format
guestsNoNumber of guests (default: 2)
roomsNoNumber of rooms (default: 1)
min_priceNoMinimum price per night in USD
max_priceNoMaximum price per night in USD

Implementation Reference

  • The searchHotels function implements the tool logic, navigating to Hopper's hotel search page, waiting for the results, and scraping hotel data.
    async function searchHotels(params: HotelSearchParams): Promise<string> {
      const page = await session.newPage();
      try {
        const url =
          `https://www.hopper.com/hotels/${encodeURIComponent(params.destination)}` +
          `?checkin=${params.check_in}&checkout=${params.check_out}` +
          `&guests=${params.guests ?? 2}&rooms=${params.rooms ?? 1}`;
    
        await page.goto(url, { waitUntil: "domcontentloaded", timeout: 30000 });
        await page.waitForTimeout(3000);
    
        const hotels = await page.evaluate(() => {
          const results: Array<{
            id: string;
            name: string;
            rating: number;
            stars: number;
            price_per_night: number;
            total_price: number;
            currency: string;
            address: string;
            amenities: string[];
            prediction: string;
          }> = [];
    
          const cards = document.querySelectorAll("[data-testid*='hotel'], .hotel-card, [class*='HotelResult']");
          cards.forEach((card, i) => {
            const text = card.textContent ?? "";
            const priceMatch = text.match(/\$(\d[\d,]*)/);
            const starsMatch = text.match(/(\d)\s*star/i);
            const ratingMatch = text.match(/(\d+\.?\d*)\s*\/\s*10|(\d+\.?\d*)\s*out/);
            results.push({
              id: `hotel_${i + 1}`,
              name: card.querySelector("h2, h3, [class*='name'], [class*='title']")?.textContent?.trim() ?? `Hotel ${i + 1}`,
              rating: ratingMatch ? parseFloat(ratingMatch[1] ?? ratingMatch[2]) : 8.0,
              stars: starsMatch ? parseInt(starsMatch[1]) : 3,
              price_per_night: priceMatch ? parseInt(priceMatch[1].replace(",", "")) : 0,
              total_price: 0,
              currency: "USD",
              address: card.querySelector("[class*='address'], [class*='location']")?.textContent?.trim() ?? "",
              amenities: [],
              prediction: text.match(/book now|wait|prices rising/i)?.[0]?.toLowerCase() ?? "watch",
            });
          });
    
          return results.slice(0, 10);
        });
    
        const result = {
          search_params: params,
          hotels: hotels.length > 0 ? hotels : generateMockHotels(params),
  • src/index.ts:607-624 (registration)
    The tool registration for search_hotels, including its description and input schema.
    {
      name: "search_hotels",
      description:
        "Search for hotels on Hopper with price predictions. Returns hotel options with ratings, amenities, and Hopper's buy/wait recommendation.",
      inputSchema: {
        type: "object",
        properties: {
          destination: { type: "string", description: "City name or destination (e.g. Paris, New York, Tokyo)" },
          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" },
          guests: { type: "number", description: "Number of guests (default: 2)" },
          rooms: { type: "number", description: "Number of rooms (default: 1)" },
          min_price: { type: "number", description: "Minimum price per night in USD" },
          max_price: { type: "number", description: "Maximum price per night in USD" },
        },
        required: ["destination", "check_in", "check_out"],
      },
    },
Behavior3/5

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

Without annotations, description carries full burden. It effectively discloses return contents (ratings, amenities, buy/wait recommendation) since no output schema exists. However, fails to declare safety characteristics (read-only/non-destructive) or operational constraints like rate limits.

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

Conciseness5/5

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

Two efficient sentences with zero waste. First sentence establishes purpose and unique value prop (price predictions); second sentence details return value. Perfectly front-loaded.

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

Completeness4/5

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

Appropriately complete for a 7-parameter search tool with full schema coverage. Compensates for missing output schema by detailing return fields. Minor gap: lacks explicit read-only declaration expected in absence of annotations.

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?

Input schema has 100% description coverage with clear examples (date formats, defaults). Description adds no additional parameter-specific semantics, but baseline 3 is appropriate given schema completeness.

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

Purpose4/5

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

Clear verb 'Search' and resource 'hotels on Hopper'. Distinguishes from generic search via 'price predictions' and specific platform mention. Lacks explicit distinction from sibling 'book_hotel' (browse vs purchase workflow), preventing a 5.

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

Usage Guidelines2/5

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

Provides no guidance on when to use this tool versus siblings like 'book_hotel' (search first, then book) or 'get_price_forecast' (direct forecast vs hotel listing with forecast). No prerequisites or exclusions stated.

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