Skip to main content
Glama

airbnb_search

Search Airbnb listings using filters for location, dates, guests, and price to find available accommodations with direct booking links.

Instructions

Search for Airbnb listings with various filters and pagination. Provide direct links to the user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationYesLocation to search for (city, state, etc.)
placeIdNoGoogle Maps Place ID (overrides the location parameter)
checkinNoCheck-in date (YYYY-MM-DD)
checkoutNoCheck-out date (YYYY-MM-DD)
adultsNoNumber of adults
childrenNoNumber of children
infantsNoNumber of infants
petsNoNumber of pets
minPriceNoMinimum price for the stay
maxPriceNoMaximum price for the stay
cursorNoBase64-encoded string used for Pagination
ignoreRobotsTextNoIgnore robots.txt rules for this request

Implementation Reference

  • The main execution function for the airbnb_search tool. Constructs the Airbnb search URL based on input parameters (location, dates, guests, prices, cursor), checks robots.txt compliance, fetches the page, parses the embedded JSON data using Cheerio, extracts and formats search results including listing IDs and direct URLs, handles pagination info, and returns structured JSON response or error.
    async function handleAirbnbSearch(params: any) {
      const {
        location,
        placeId,
        checkin,
        checkout,
        adults = 1,
        children = 0,
        infants = 0,
        pets = 0,
        minPrice,
        maxPrice,
        cursor,
        ignoreRobotsText = false,
      } = params;
    
      const searchUrl = new URL(`${BASE_URL}/s/${encodeURIComponent(location)}/homes`);
      
      if (placeId) searchUrl.searchParams.append("place_id", placeId);
      if (checkin) searchUrl.searchParams.append("checkin", checkin);
      if (checkout) searchUrl.searchParams.append("checkout", checkout);
      
      const adults_int = parseInt(adults.toString());
      const children_int = parseInt(children.toString());
      const infants_int = parseInt(infants.toString());
      const pets_int = parseInt(pets.toString());
      
      const totalGuests = adults_int + children_int;
      if (totalGuests > 0) {
        searchUrl.searchParams.append("adults", adults_int.toString());
        searchUrl.searchParams.append("children", children_int.toString());
        searchUrl.searchParams.append("infants", infants_int.toString());
        searchUrl.searchParams.append("pets", pets_int.toString());
      }
      
      if (minPrice) searchUrl.searchParams.append("price_min", minPrice.toString());
      if (maxPrice) searchUrl.searchParams.append("price_max", maxPrice.toString());
      if (cursor) {
        searchUrl.searchParams.append("cursor", cursor);
      }
    
      const path = searchUrl.pathname + searchUrl.search;
      if (!ignoreRobotsText && !isPathAllowed(path)) {
        log('warn', 'Search blocked by robots.txt', { path, url: searchUrl.toString() });
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              error: robotsErrorMessage,
              url: searchUrl.toString(),
              suggestion: "Consider enabling 'ignore_robots_txt' in extension settings if needed for testing"
            }, null, 2)
          }],
          isError: true
        };
      }
    
      const allowSearchResultSchema = {
        demandStayListing : {
          id: true,
          description: true,
          location: true,
        },
        badges: {
          text: true,
        },
        structuredContent: {
          mapCategoryInfo: {
            body: true
          },
          mapSecondaryLine: {
            body: true
          },
          primaryLine: {
            body: true
          },
          secondaryLine: {
            body: true
          },
        },
        avgRatingA11yLabel: true,
        listingParamOverrides: true,
        structuredDisplayPrice: {
          primaryLine: {
            accessibilityLabel: true,
          },
          secondaryLine: {
            accessibilityLabel: true,
          },
          explanationData: {
            title: true,
            priceDetails: {
              items: {
                description: true,
                priceString: true
              }
            }
          }
        },
      };
    
      try {
        log('info', 'Performing Airbnb search', { location, checkin, checkout, adults, children });
    
        const response = await fetchWithUserAgent(searchUrl.toString());
        const html = await response.text();
        const $ = cheerio.load(html);
    
        let staysSearchResults: any = {};
        
        try {
          const scriptElement = $("#data-deferred-state-0").first();
          if (scriptElement.length === 0) {
            throw new Error("Could not find data script element - page structure may have changed");
          }
          
          const scriptContent = $(scriptElement).text();
          if (!scriptContent) {
            throw new Error("Data script element is empty");
          }
          
          const clientData = JSON.parse(scriptContent).niobeClientData[0][1];
          const results = clientData.data.presentation.staysSearch.results;
          cleanObject(results);
          
          staysSearchResults = {
            searchResults: results.searchResults
              .map((result: any) => flattenArraysInObject(pickBySchema(result, allowSearchResultSchema)))
              .map((result: any) => {
                const id = atob(result.demandStayListing.id).split(":")[1];
                return {id, url: `${BASE_URL}/rooms/${id}`, ...result }
              }),
            paginationInfo: results.paginationInfo
          }
          
          log('info', 'Search completed successfully', { 
            resultCount: staysSearchResults.searchResults?.length || 0 
          });
        } catch (parseError) {
          log('error', 'Failed to parse search results', {
            error: parseError instanceof Error ? parseError.message : String(parseError),
            url: searchUrl.toString()
          });
          
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                error: "Failed to parse search results from Airbnb. The page structure may have changed.",
                details: parseError instanceof Error ? parseError.message : String(parseError),
                searchUrl: searchUrl.toString()
              }, null, 2)
            }],
            isError: true
          };
        }
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              searchUrl: searchUrl.toString(),
              ...staysSearchResults
            }, null, 2)
          }],
          isError: false
        };
      } catch (error) {
        log('error', 'Search request failed', {
          error: error instanceof Error ? error.message : String(error),
          url: searchUrl.toString()
        });
        
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              error: error instanceof Error ? error.message : String(error),
              searchUrl: searchUrl.toString(),
              timestamp: new Date().toISOString()
            }, null, 2)
          }],
          isError: true
        };
      }
    }
  • Tool definition object AIRBNB_SEARCH_TOOL including name, description, and detailed inputSchema with properties for location/placeId, check-in/out dates, guest counts (adults,children,infants,pets), price range, cursor for pagination, and ignoreRobotsText flag. Required: location.
    const AIRBNB_SEARCH_TOOL = {
      name: "airbnb_search",
      description: "Search for Airbnb listings with various filters and pagination. Provide direct links to the user",
      inputSchema: {
        type: "object",
        properties: {
          location: {
            type: "string",
            description: "Location to search for (city, state, etc.)"
          },
          placeId: {
            type: "string",
            description: "Google Maps Place ID (overrides the location parameter)"
          },
          checkin: {
            type: "string",
            description: "Check-in date (YYYY-MM-DD)"
          },
          checkout: {
            type: "string",
            description: "Check-out date (YYYY-MM-DD)"
          },
          adults: {
            type: "number",
            description: "Number of adults"
          },
          children: {
            type: "number",
            description: "Number of children"
          },
          infants: {
            type: "number",
            description: "Number of infants"
          },
          pets: {
            type: "number",
            description: "Number of pets"
          },
          minPrice: {
            type: "number",
            description: "Minimum price for the stay"
          },
          maxPrice: {
            type: "number",
            description: "Maximum price for the stay"
          },
          cursor: {
            type: "string",
            description: "Base64-encoded string used for Pagination"
          },
          ignoreRobotsText: {
            type: "boolean",
            description: "Ignore robots.txt rules for this request"
          }
        },
        required: ["location"]
      }
    };
  • index.ts:137-141 (registration)
    AIRBNB_TOOLS array that includes AIRBNB_SEARCH_TOOL (and related tools), used by the listTools request handler to expose available tools.
    const AIRBNB_TOOLS = [
      AIRBNB_SEARCH_TOOL,
      AIRBNB_LISTING_DETAILS_TOOL,
      ...photoAnalysisTools,
    ];
  • index.ts:629-631 (registration)
    setRequestHandler for ListToolsRequestSchema that returns the AIRBNB_TOOLS array, registering the tool for discovery.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: AIRBNB_TOOLS,
    }));
  • index.ts:656-658 (registration)
    In the CallToolRequestSchema handler's switch statement, case for 'airbnb_search' that invokes handleAirbnbSearch with the tool arguments.
    case "airbnb_search": {
      result = await handleAirbnbSearch(request.params.arguments);
      break;
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'pagination' (implied via the 'cursor' parameter) and 'Provide direct links to the user' which adds some context about output behavior. However, it lacks critical details such as rate limits, authentication requirements, error handling, or what the search results include (e.g., listing summaries vs. full details). For a search tool with 12 parameters, this is insufficient.

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?

The description is a single, efficient sentence that front-loads the core purpose ('Search for Airbnb listings') and includes key features. It avoids unnecessary words, though it could be slightly more structured by separating functional aspects from output instructions. Every part earns its place, but it's not perfectly optimized for quick scanning.

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

Completeness2/5

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

Given the complexity (12 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain the return format beyond 'direct links', leaving the agent uncertain about what data is provided (e.g., listings, prices, availability). For a search tool with rich filtering options, more context on results and behavior is needed to be fully helpful.

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 description coverage is 100%, so the schema already documents all 12 parameters thoroughly. The description adds minimal value by mentioning 'various filters and pagination', which aligns with parameters like 'minPrice', 'maxPrice', and 'cursor', but doesn't provide additional semantics beyond what the schema states. Baseline 3 is appropriate as the schema does the heavy lifting.

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?

The description clearly states the verb ('Search') and resource ('Airbnb listings'), and mentions key capabilities ('various filters and pagination'). It distinguishes from sibling tools like 'airbnb_listing_details' by focusing on search rather than detailed information retrieval. However, it doesn't explicitly differentiate from 'analyzeListingPhotos' or 'getListingPhotos' which might also involve search-related functions.

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?

The description provides no guidance on when to use this tool versus alternatives like 'airbnb_listing_details' for specific listings, or how it relates to photo analysis tools. It mentions 'Provide direct links to the user' which hints at output format but doesn't clarify usage context or exclusions. No explicit when/when-not statements are present.

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/iclickfreedownloads/mcp-server-airbnb'

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