Skip to main content
Glama

random_cities_detailed_info

Retrieve detailed information for random cities to support aviation data analysis and flight planning.

Instructions

MCP tool to get random cities detailed info.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
number_of_citiesYes

Implementation Reference

  • The handler function decorated with @mcp.tool() implements the random_cities_detailed_info tool. It fetches city data from the Aviationstack API /v1/cities endpoint, samples random cities, extracts detailed info, and returns as JSON string.
    @mcp.tool() def random_cities_detailed_info(number_of_cities: int) -> str: """MCP tool to get random cities detailed info.""" try: data = fetch_flight_data('http://api.aviationstack.com/v1/cities', { 'limit': number_of_cities }) data_list = data.get('data', []) number_of_cities_to_fetch = min(number_of_cities, len(data_list)) # Sample random cities from the data list sampled_cities = random.sample(data_list, number_of_cities_to_fetch) 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 e: return f"Request error: {str(e)}" except (KeyError, ValueError, TypeError) as e: return f"Error fetching cities: {str(e)}"

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