Skip to main content
Glama

create_booking

Book a Turo car rental by providing listing ID, dates, and optional message to host. Returns confirmation details and price breakdown.

Instructions

Create a new car booking/reservation on Turo. Requires the user to be logged in to their Turo account. Returns booking confirmation details and price breakdown.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
listing_idYesThe Turo listing ID to book
start_dateYesRental start date in YYYY-MM-DD format
end_dateYesRental end date in YYYY-MM-DD format
message_to_hostNoOptional message to send to the host with your booking request

Implementation Reference

  • The handler function that executes the booking process on Turo by automating browser interactions.
    export async function createBooking(params: CreateBookingParams): Promise<BookingResult> {
      const page = await newPage();
    
      try {
        // Navigate to the listing page
        const listingUrl = `https://turo.com/us/en/car-rental/united-states/vehicles/${params.listing_id}`;
        await page.goto(listingUrl, { waitUntil: "domcontentloaded", timeout: 30000 });
        await waitForNavigation(page);
        await sleep(2000);
    
        // Check if user is logged in
        const isLoggedIn = await page.evaluate(() => {
          const loginEl = document.querySelector(
            '[class*="login"], [class*="sign-in"], [href*="/login"]'
          );
          return !loginEl;
        });
    
        if (!isLoggedIn) {
          return {
            booking_id: "",
            status: "error",
            listing_id: params.listing_id,
            start_date: params.start_date,
            end_date: params.end_date,
            total_price: 0,
            breakdown: {
              daily_rate: 0,
              days: 0,
              subtotal: 0,
              turo_fee: 0,
              taxes: 0,
              total: 0,
            },
            confirmation_url: undefined,
          };
        }
    
        // Set booking dates via URL parameters
        const bookingUrl = new URL(listingUrl);
        bookingUrl.searchParams.set("startDate", params.start_date);
        bookingUrl.searchParams.set("endDate", params.end_date);
        bookingUrl.searchParams.set("startTime", "10:00");
        bookingUrl.searchParams.set("endTime", "10:00");
    
        await page.goto(bookingUrl.toString(), {
          waitUntil: "domcontentloaded",
          timeout: 30000,
        });
        await waitForNavigation(page);
        await sleep(2000);
    
        // Extract price breakdown before booking
        const priceInfo = await page.evaluate(() => {
          const getText = (selector: string): string => {
            const el = document.querySelector(selector) as HTMLElement | null;
            return el?.textContent?.trim() || "";
          };
    
          const parsePrice = (text: string): number => {
            const match = text.match(/\$?([\d,]+\.?\d*)/);
            return match ? parseFloat(match[1].replace(",", "")) : 0;
          };
    
          // Try to extract breakdown items
          const breakdownItems: Record<string, number> = {};
          document
            .querySelectorAll('[class*="breakdown"] li, [class*="price"] li, [class*="summary"] li')
            .forEach((item) => {
              const labelEl = item.querySelector(
                '[class*="label"], [class*="name"], span:first-child'
              ) as HTMLElement | null;
              const valueEl = item.querySelector(
                '[class*="value"], [class*="amount"], span:last-child'
              ) as HTMLElement | null;
              if (labelEl && valueEl) {
                const label = labelEl.textContent?.trim().toLowerCase() || "";
                const value = parsePrice(valueEl.textContent || "");
                breakdownItems[label] = value;
              }
            });
    
          const dailyRateEl = document.querySelector(
            '[class*="dailyRate"], [class*="daily-rate"]'
          ) as HTMLElement | null;
          const daily_rate = parsePrice(dailyRateEl?.textContent || "") || breakdownItems["daily rate"] || 0;
    
          const totalEl = document.querySelector(
            '[class*="total"], [class*="Total"]'
          ) as HTMLElement | null;
          const total = parsePrice(totalEl?.textContent || "") || 0;
    
          return { breakdownItems, daily_rate, total };
        });
    
        // Look for the Book button
        const bookButton = await page.$(
          '[data-testid="book-button"], [class*="bookButton"], button[class*="book"]'
        );
    
        if (!bookButton) {
          return {
            booking_id: "",
            status: "unavailable",
            listing_id: params.listing_id,
            start_date: params.start_date,
            end_date: params.end_date,
            total_price: priceInfo.total,
            breakdown: buildBreakdown(priceInfo),
          };
        }
    
        // Add message to host if provided
        if (params.message_to_host) {
          const messageBox = await page.$(
            'textarea[class*="message"], textarea[placeholder*="message"], [class*="messageHost"] textarea'
          );
          if (messageBox) {
            await messageBox.click();
            await messageBox.fill(params.message_to_host);
          }
        }
    
        // Click book button
        await bookButton.click();
        await waitForNavigation(page);
        await sleep(3000);
    
        // Extract confirmation details
        const confirmation = await page.evaluate(() => {
          const urlMatch = window.location.href.match(/\/reservations\/([a-zA-Z0-9-]+)/);
          const bookingId = urlMatch ? urlMatch[1] : "";
    
          const statusEl = document.querySelector(
            '[class*="status"], [class*="confirmation"]'
          ) as HTMLElement | null;
          const status = statusEl?.textContent?.trim() || (bookingId ? "confirmed" : "pending");
    
          return { booking_id: bookingId, status, url: window.location.href };
        });
    
        const startDate = new Date(params.start_date);
        const endDate = new Date(params.end_date);
        const days = Math.ceil(
          (endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24)
        );
    
        const breakdown = buildBreakdown(priceInfo, days);
    
        return {
          booking_id: confirmation.booking_id,
          status: confirmation.status || "pending",
          listing_id: params.listing_id,
          start_date: params.start_date,
          end_date: params.end_date,
          total_price: breakdown.total || priceInfo.total,
          breakdown,
          confirmation_url: confirmation.url,
        };
      } finally {
        await page.close();
      }
    }
  • Type definition for the input parameters of the create_booking tool.
    export interface CreateBookingParams {
      listing_id: string;
      start_date: string;
      end_date: string;
      message_to_host?: string;
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden and successfully discloses authentication requirements and return value structure ('booking confirmation details and price breakdown'). However, it omits important behavioral traits like financial commitment implications, cancellation policies, or failure modes when vehicles are unavailable.

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?

Three tightly constructed sentences follow a logical progression: purpose (sentence 1), prerequisites (sentence 2), and return values (sentence 3). No redundant or filler content exists; every clause provides distinct operational context.

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 compensates for missing output schema by describing return contents ('booking confirmation details and price breakdown') and covers the critical authentication context. Could be improved by noting the financial/destructive nature of booking creation or error handling scenarios.

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%, with all four parameters (listing_id, start_date, end_date, message_to_host) fully documented in the input schema. The description adds no supplementary parameter guidance, meeting the baseline expectation when the schema is self-sufficient.

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?

The description uses specific verb 'Create' with clear resource 'car booking/reservation on Turo'. It clearly distinguishes this creation tool from siblings like search_cars (discovery), get_car_details (inspection), and manage_booking (modification of existing bookings).

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

Usage Guidelines4/5

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

States the critical prerequisite that 'the user [must be] logged in to their Turo account,' providing essential context for invocation. However, it does not explicitly contrast with manage_booking to clarify when to create new vs. modify existing bookings.

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-turo'

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