Skip to main content
Glama
Pradumnasaraf

Aviationstack MCP Server

random_cities_detailed_info

Retrieve detailed metadata for a specified number of random cities. Use to obtain random geographic data for testing or exploration.

Instructions

Return detailed metadata for random cities.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
number_of_citiesYesNumber of random cities to return.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Input schema (Pydantic model) for the random_cities_detailed_info tool, validating number_of_cities is a positive integer with 'extra=forbid'.
    class RandomCitiesDetailedInfoInput(BaseModel):
        """Input schema for random_cities_detailed_info tool."""
    
        model_config = ConfigDict(extra="forbid")
    
        number_of_cities: int = Field(
            ...,
            description="Number of random cities to return.",
            gt=0,
        )
  • Core handler: validates input, fetches 'cities' endpoint data via fetch_flight_data, samples randomly with _sample_data, extracts detailed fields (gmt, city_id, iata_code, country_iso2, geoname_id, latitude, longitude, timezone, city_name), and returns JSON.
    def random_cities_detailed_info(number_of_cities: int) -> str:
        """Get detailed info for random cities."""
        try:
            _validate_positive_int(number_of_cities, "number_of_cities")
            data = fetch_flight_data("cities", {"limit": number_of_cities})
            sampled_cities = _sample_data(data.get("data", []), number_of_cities)
    
            cities = []
            for city in sampled_cities:
                cities.append(
                    {
                        "gmt": city.get("gmt"),
                        "city_id": city.get("city_id"),
                        "iata_code": city.get("iata_code"),
                        "country_iso2": city.get("country_iso2"),
                        "geoname_id": city.get("geoname_id"),
                        "latitude": city.get("latitude"),
                        "longitude": city.get("longitude"),
                        "timezone": city.get("timezone"),
                        "city_name": city.get("city_name"),
                    }
                )
            return json.dumps(cities)
        except requests.RequestException as exc:
            return _error_response("fetching cities", exc)
        except (KeyError, ValueError, TypeError) as exc:
            return _error_response("fetching cities", exc)
  • Tool registration using @mcp.tool decorator with name 'random_cities_detailed_info', description, and the wrapper function that validates input and delegates to the core handler.
    @mcp.tool(
        name="random_cities_detailed_info",
        description="Return detailed metadata for random cities.",
    )
    def random_cities_detailed_info_tool(
        number_of_cities: Annotated[
            int, Field(description="Number of random cities to return.", gt=0)
        ],
    ) -> str:
        """Tool wrapper for random_cities_detailed_info."""
        validated_input = RandomCitiesDetailedInfoInput(number_of_cities=number_of_cities)
        return random_cities_detailed_info(number_of_cities=validated_input.number_of_cities)
  • Helper: validates positive integer, used to ensure number_of_cities > 0.
    def _validate_positive_int(value: int, param_name: str) -> None:
        if value <= 0:
            raise ValueError(f"'{param_name}' must be greater than 0.")
  • Helper: randomly samples up to count items from a list, used to pick random cities from API results.
    def _sample_data(items: list[dict[str, Any]], count: int) -> list[dict[str, Any]]:
        _validate_positive_int(count, "count")
        number_to_fetch = min(count, len(items))
        return random.sample(items, number_to_fetch)
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'random' but does not explain the randomness nature (e.g., selection algorithm, independence of calls). No side effects or required permissions are noted.

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?

One sentence, front-loaded with action and resource, no unnecessary words. Very concise and easy to parse.

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?

Despite having an output schema, the description is too minimal. It does not explain what metadata is included, nor how randomness behaves. For a tool with multiple siblings, more context is needed to differentiate use cases.

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% (the parameter has a clear description). The tool description adds no additional meaning beyond that, so baseline score of 3 is appropriate.

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 returns detailed metadata for random cities, distinguishing it from sibling tools like random_countries_detailed_info. However, 'detailed metadata' is vague and could specify what fields are included.

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?

No guidance on when to use this tool versus alternatives like flight-related tools. No conditions or exclusions are provided, leaving the agent without context for appropriate invocation.

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/Pradumnasaraf/aviationstack-mcp'

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