Skip to main content
Glama

request_booking_link

Generate a booking link for a selected flight option to complete the reservation process after expressing booking intent.

Instructions

Request link for booking a flight option. This tool generates a booking link for a specific flight option.This tool is recommended to be used after the user expressed intention to book the flight option.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
search_idYesSearch ID from the previous search_flights tool.
offer_idYesOffer ID of the flight option for which to request a booking link.
agency_idYesInternal agency ID for generating booking link.

Implementation Reference

  • The main handler function for the 'request_booking_link' tool, including decorator, parameters with schema via Field, and logic to fetch booking link from Travelpayouts API using cached search results.
    @mcp.tool(
        description="Request link for booking a flight option. " \
        "This tool generates a booking link for a specific flight option." \
        "This tool is recommended to be used after the user expressed intention to book the flight option." \
    )
    async def request_booking_link(
        search_id: str = Field(..., description="Search ID from the previous search_flights tool."),
        offer_id: str = Field(..., description="Offer ID of the flight option for which to request a booking link."),
        agency_id: str = Field(..., description="Internal agency ID for generating booking link.")
    ) -> str:
        """Request a booking link for a specific flight option."""
        
        batch = search_results_cache.get(search_id)
        if not batch:
            raise ToolError(f"No search results found for search_id: {search_id}. " \
                            "It may have expired after 10 minutes. " \
                            "Please perform a search first using the `search_flights` tool.")
        
        proposal = batch.get_proposal_by_id(offer_id)
        if not proposal:
            raise ToolError(f"No flight details found for offer_id: {offer_id} in search_id: {search_id}.")
        
        terms = proposal.terms[agency_id]
        
        get_book_link_api_url = f"https://api.travelpayouts.com/v1/flight_searches/{search_id}/clicks/{terms.url}.json?marker={MARKER}"
        async with httpx.AsyncClient(timeout=40) as client:
            response = await client.get(get_book_link_api_url)
            if response.status_code != 200:
                raise ToolError(f"Aviasales API returned non-200 status code: {response.status_code}", raw_response=response.text)
            data = response.json()
            if not data or "url" not in data:
                raise ToolError("Booking link not found in the response from Aviasales API.")
            book_link = data["url"]
            agency_name = batch.gates_info.get(agency_id).label if batch.gates_info.get(agency_id) else ''
            return f"Booking link on {agency_name}: {book_link}"
  • Helper method on ProposalsBatchModel used to retrieve the specific Proposal instance by its sign (offer_id). Essential for accessing the flight proposal data in the handler.
    def get_proposal_by_id(self, proposal_id: str) -> Optional[Proposal]:
        for proposal in self.proposals:
            if proposal.sign == proposal_id:
                return proposal
        return None
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'generates a booking link' but lacks details on what this entails—e.g., whether it initiates a booking process, requires user authentication, has rate limits, or returns a temporary/permanent link. For a tool with no annotations and potential side effects (generating links), this is a significant gap in transparency.

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 appropriately sized with two sentences that are front-loaded: the first states the purpose, and the second provides usage context. There's no wasted text, but it could be slightly more structured (e.g., bullet points for clarity).

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 no annotations, no output schema, and a tool that likely has behavioral implications (generating booking links), the description is incomplete. It lacks details on what the tool returns (e.g., URL format, expiration), error conditions, or prerequisites beyond the parameters. This leaves gaps for an AI agent to understand the full context of use.

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 three parameters (search_id, offer_id, agency_id) with clear descriptions. The description adds no additional meaning beyond what the schema provides, such as explaining how these IDs interrelate or their format. Baseline 3 is appropriate when 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 tool's purpose: 'generates a booking link for a specific flight option' (verb+resource). It distinguishes from sibling tools like search_flights and get_flight_options by focusing on booking link generation rather than searching or retrieving details. However, it doesn't explicitly differentiate from get_flight_option_details beyond the booking link aspect.

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?

The description provides clear context for when to use this tool: 'after the user expressed intention to book the flight option.' This establishes a logical sequence with search_flights. However, it doesn't explicitly mention when NOT to use it or name specific alternatives among the siblings, such as clarifying that get_flight_option_details is for information only, not booking.

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/maratsarbasov/flights-mcp'

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