Skip to main content
Glama

Search Hotels With Details

search_hotels_with_details
Read-onlyIdempotent

Search for hotels and retrieve detailed rates, availability, and cancellation policies for multiple properties in one call, enabling easy comparison.

Instructions

Search + parallel detail fetch for the top N hotels in one call.

Use when the user wants to COMPARE rooms, rates, or cancellation policies across multiple hotels. Costs 1 + N RPCs. max_hotels is HARD-CAPPED at 15.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
check_inYes
check_outYes
max_hotelsNoTop-N hotels to enrich with detail. Hard cap = 15. Default 5.
adultsNo
childrenNo
child_agesNo
currencyNoUSD
sort_byNoRELEVANCE
hotel_classNo
amenitiesNo
brandsNo
min_guest_ratingNo
free_cancellationNo
eco_certifiedNo
special_offersNo
price_minNo
price_maxNo
property_typeNoHOTELS

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The actual handler function for search_hotels_with_details tool. It collects arguments, builds a SearchHotelsWithDetailsParams object, and delegates to _execute_search_hotels_with_details_from_params.
    def _search_hotels_with_details_impl(
        query: Annotated[str, Field()],
        check_in: Annotated[str, Field()],
        check_out: Annotated[str, Field()],
        max_hotels: Annotated[
            int,
            Field(
                ge=1,
                le=HARD_MAX_HOTELS_WITH_DETAILS,
                description=(f"Top-N hotels to enrich with detail. Hard cap = {HARD_MAX_HOTELS_WITH_DETAILS}. Default 5."),
            ),
        ] = CONFIG.default_max_hotels_with_details,
        adults: Annotated[int, Field(ge=1)] = CONFIG.default_adults,
        children: Annotated[int, Field(ge=0, le=8)] = CONFIG.default_children,
        child_ages: Annotated[list[int] | None, Field()] = None,
        currency: Annotated[str, Field(min_length=3, max_length=3)] = CONFIG.default_currency,
        sort_by: Annotated[SortByLiteral, Field()] = CONFIG.default_sort_by,
        hotel_class: Annotated[list[int] | None, Field()] = None,
        amenities: Annotated[list[str] | None, Field()] = None,
        brands: Annotated[list[str] | None, Field()] = None,
        min_guest_rating: Annotated[float | None, Field(ge=3.5, le=4.5)] = None,
        free_cancellation: bool = False,
        eco_certified: bool = False,
        special_offers: bool = False,
        price_min: Annotated[int | None, Field(ge=0)] = None,
        price_max: Annotated[int | None, Field(ge=0)] = None,
        property_type: Annotated[PropertyTypeLiteral, Field()] = "HOTELS",
    ) -> dict[str, Any]:
        """placeholder — overwritten via __doc__ assignment below."""
        params = SearchHotelsWithDetailsParams(
            query=query,
            check_in=check_in,
            check_out=check_out,
            max_hotels=max_hotels,
            adults=adults,
            children=children,
            child_ages=child_ages,
            currency=currency,
            sort_by=sort_by,
            hotel_class=hotel_class,
            amenities=amenities,
            brands=brands,
            min_guest_rating=min_guest_rating,
            free_cancellation=free_cancellation,
            eco_certified=eco_certified,
            special_offers=special_offers,
            price_min=price_min,
            price_max=price_max,
            property_type=property_type,
        )
        return _execute_search_hotels_with_details_from_params(params)
  • Registration of search_hotels_with_details as an MCP tool via @mcp.tool decorator. Docstring is assigned programmatically to allow f-string expansion with the HARD_MAX constant.
    _search_hotels_with_details_impl.__doc__ = f"""Search + parallel detail fetch for the top N hotels in one call.
    
    Use when the user wants to COMPARE rooms, rates, or cancellation
    policies across multiple hotels. Costs 1 + N RPCs. max_hotels is
    HARD-CAPPED at {HARD_MAX_HOTELS_WITH_DETAILS}.
    """
    _search_hotels_with_details_impl.__name__ = "search_hotels_with_details"
    _search_hotels_with_details_impl.__qualname__ = "search_hotels_with_details"
    
    search_hotels_with_details = mcp.tool(
        name="search_hotels_with_details",
        annotations={
            "title": "Search Hotels With Details",
            "readOnlyHint": True,
            "idempotentHint": True,
        },
    )(_search_hotels_with_details_impl)
  • Core executor: converts params to filters, calls search_with_details on the SearchHotels client, and serializes result+detail for each enriched hotel.
    def _execute_search_hotels_with_details_from_params(
        params: SearchHotelsWithDetailsParams,
    ) -> dict[str, Any]:
        try:
            shp = SearchHotelsParams(**params.model_dump(exclude={"max_hotels"}))
            filters = _build_filters_from_search_params(shp)
            enriched = _get_search_hotels_cls()().search_with_details(filters, max_hotels=params.max_hotels)
            items = []
            for er in enriched:
                items.append(
                    {
                        "ok": er.ok,
                        "result": _serialize_hotel_result(er.result),
                        "detail": _serialize_hotel_detail(er.detail) if er.detail else None,
                        "error": er.error,
                        "error_kind": er.error_kind,
                        "is_retryable": er.is_retryable,
                    }
                )
            return {"success": True, "count": len(items), "items": items}
        except (BatchExecuteError, TransientBatchExecuteError) as e:
            return {"success": False, "error": f"{type(e).__name__}: {e}", "items": []}
  • Pydantic model defining all input parameters for search_hotels_with_details, including validation for child_ages matching children count.
    class SearchHotelsWithDetailsParams(BaseModel):
        query: str = Field(description="City or property query.")
        check_in: str = Field(description="YYYY-MM-DD — REQUIRED.")
        check_out: str = Field(description="YYYY-MM-DD after check_in — REQUIRED.")
        max_hotels: int = Field(
            default=CONFIG.default_max_hotels_with_details,
            ge=1,
            le=HARD_MAX_HOTELS_WITH_DETAILS,
            description=f"Top-N to enrich. HARD CAP = {HARD_MAX_HOTELS_WITH_DETAILS}.",
        )
        adults: int = Field(default=CONFIG.default_adults, ge=1)
        children: int = Field(default=CONFIG.default_children, ge=0, le=8)
        child_ages: list[int] | None = Field(default=None)
        currency: str = Field(default=CONFIG.default_currency, min_length=3, max_length=3)
        sort_by: SortByLiteral = CONFIG.default_sort_by
        hotel_class: list[int] | None = None
        amenities: list[str] | None = None
        brands: list[str] | None = None
        min_guest_rating: float | None = Field(default=None, ge=3.5, le=4.5)
        free_cancellation: bool = False
        eco_certified: bool = False
        special_offers: bool = False
        price_min: int | None = Field(default=None, ge=0)
        price_max: int | None = Field(default=None, ge=0)
        property_type: PropertyTypeLiteral = "HOTELS"
    
        @model_validator(mode="after")
        def _child_ages_matches_children(self):
            _validate_child_ages(self.children, self.child_ages)
            return self
  • Canonical hard cap constant (15) for max_hotels parameter used across validation and documentation.
    HARD_MAX_HOTELS_WITH_DETAILS = 15
Behavior5/5

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

Annotations already declare readOnlyHint=true and idempotentHint=true. Description adds that it performs parallel detail fetch (multiple RPCs) and imposes a hard cap of 15 on max_hotels, providing transparent behavioral context beyond annotations.

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 sentences: first states purpose, second gives usage guidance and constraints. Extremely concise and front-loaded; no wasted words.

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

Completeness5/5

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

Despite high complexity (19 parameters, sibling tools), the description covers purpose, usage context, cost, and hard cap. Output schema exists but does not need description. Complete enough for an agent to decide when and how to 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?

With schema description coverage at only 5%, the description compensates slightly by mentioning max_hotels cap and default, but does not explain the many other parameters. However, the tool's purpose is clear and many parameters are standard, so a baseline of 3 is appropriate.

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 clearly states the tool combines search with parallel detail fetch for top N hotels. It distinguishes itself from siblings 'search_hotels' (likely just search) and 'get_hotel_details' (single hotel) by explicitly mentioning the combined functionality.

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

Usage Guidelines5/5

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

Explicitly states when to use: when user wants to compare rooms, rates, or cancellation policies across multiple hotels. Also warns about cost (1 + N RPCs) and hard cap on max_hotels, guiding appropriate usage.

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/him229/stays'

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