Skip to main content
Glama
xiaonieli7

Flight Ticket MCP Server

by xiaonieli7

getAirportFlights

Query all flights within 30km of a specified airport using airport codes like PEK, PVG, or CAN to monitor departures and arrivals in real-time.

Instructions

机场周边航班查询 - 查询指定机场周边30公里范围内的所有航班。支持主要机场代码如PEK、PVG、CAN等

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
airport_codeYes
flight_typeNodeparture

Implementation Reference

  • The primary MCP tool handler for 'getAirportFlights', decorated with @mcp.tool() for registration and execution. Logs the call and delegates to the helper in simple_opensky_tools.
    @mcp.tool()
    def getAirportFlights(airport_code: str, flight_type: str = "departure"):
        """机场周边航班查询 - 查询指定机场周边30公里范围内的所有航班。支持主要机场代码如PEK、PVG、CAN等"""
        logger.debug(f"调用机场周边航班查询工具: airport_code={airport_code}, flight_type={flight_type}")
        return simple_opensky_tools.getAirportFlights(airport_code, flight_type)
  • Helper wrapper function that invokes the tracker instance's method for airport flights.
    def getAirportFlights(airport_code: str, flight_type: str = "departure") -> Dict[str, Any]:
        """
        查询机场周边的航班信息
        
        Args:
            airport_code: 机场代码 (如: "PEK", "PVG", "CAN")
            flight_type: 航班类型(此参数仅为兼容性,OpenSky返回所有航班)
            
        Returns:
            包含机场周边航班列表的字典
        """
        return simple_tracker.get_airport_area_flights(airport_code)
  • Core implementation logic: Maps airport code to coordinates, defines 30km bounding box, queries OpenSky API via get_all_states, and formats response with airport details.
    def get_airport_area_flights(self, airport_code: str) -> Dict[str, Any]:
        """获取机场区域的航班"""
        # 中国主要机场坐标(数据来源:中国开放数据平台等)
        airport_coords = {
    
            "PEK": (40.0801, 116.5844),  # 北京首都国际机场
            "PKX": (39.5098, 116.4107),  # 北京大兴国际机场
            "PVG": (31.1434, 121.8052),  # 上海浦东国际机场
            "SHA": (31.1979, 121.3364),  # 上海虹桥国际机场
            "CAN": (23.3925, 113.2989),  # 广州白云国际机场
            "SZX": (22.6393, 113.8107),  # 深圳宝安国际机场
            "CKG": (29.7194, 106.6419),  # 重庆江北国际机场
            "TSN": (39.1244, 117.3469),  # 天津滨海国际机场
            
    
            "CTU": (30.5786, 103.9472),  # 成都双流国际机场
            "TFU": (30.3114, 104.4419),  # 成都天府国际机场
            "KMG": (25.1019, 102.9292),  # 昆明长水国际机场
            "XIY": (34.4471, 108.7519),  # 西安咸阳国际机场
            "HGH": (30.2295, 120.4344),  # 杭州萧山国际机场
            "NKG": (31.7420, 118.8620),  # 南京禄口国际机场
            "WUH": (30.7838, 114.2081),  # 武汉天河国际机场
            "CSX": (28.1892, 113.2196),  # 长沙黄花国际机场
            "TAO": (36.2661, 120.3744),  # 青岛流亭国际机场
            "XMN": (24.5440, 118.1277),  # 厦门高崎国际机场
            "FOC": (25.9351, 119.6633),  # 福州长乐国际机场
            "NNG": (22.6083, 108.1722),  # 南宁吴圩国际机场
            "KWE": (26.5385, 106.8007),  # 贵阳龙洞堡国际机场
            "SJW": (38.2806, 114.6963),  # 石家庄正定国际机场
            "TYN": (37.7469, 112.6286),  # 太原武宿国际机场
            "HET": (40.8514, 111.8244),  # 呼和浩特白塔国际机场
            "SHE": (41.6398, 123.4836),  # 沈阳桃仙国际机场
            "CGQ": (43.9961, 125.6850),  # 长春龙嘉国际机场
            "HRB": (45.6234, 126.2507),  # 哈尔滨太平国际机场
            "NKQ": (25.6675, 100.2769),  # 南昌昌北国际机场(新增)
            "LHW": (34.7414, 113.8406),  # 兰州中川国际机场
            "INC": (38.8531, 106.0094),  # 银川河东国际机场
            "XNN": (36.5275, 102.0430),  # 西宁曹家堡机场
            "URC": (43.9071, 87.4744),   # 乌鲁木齐地窝堡国际机场
            
    
            "SYX": (18.3027, 109.4122),  # 三亚凤凰国际机场
            "HAK": (19.9349, 110.4590),  # 海口美兰国际机场
            "DLC": (38.9656, 121.5386),  # 大连周水子国际机场
            "YNT": (37.4017, 121.3717),  # 烟台蓬莱国际机场
            "WEH": (37.1871, 122.2286),  # 威海大水泊国际机场
            "JZH": (35.0286, 118.6414),  # 济南遥墙国际机场
            "LYG": (34.5714, 119.1286),  # 连云港白塔埠机场
            "YTY": (32.5631, 119.7197),  # 扬州泰州国际机场
            "WUX": (31.4944, 120.4292),  # 无锡硕放国际机场
            "NTG": (32.0708, 120.9764),  # 南通兴东国际机场
            "HFE": (31.7800, 117.2981),  # 合肥新桥国际机场
            "WNZ": (27.9122, 120.8522),  # 温州龙湾国际机场
            "NGB": (29.8267, 121.4619),  # 宁波栎社国际机场
            "YIW": (29.3447, 120.0322),  # 义乌机场
            
    
            "BHY": (49.2050, 119.8250),  # 北海福成机场
            "LZH": (24.2075, 109.3917),  # 柳州白莲机场
            "GXG": (24.7953, 110.0381),  # 桂林两江国际机场
            "ZUH": (22.0064, 113.3758),  # 珠海金湾机场
            "MXZ": (24.2783, 116.1222),  # 梅县机场
            "SWA": (23.5619, 116.5086),  # 汕头外砂机场
            "JYG": (24.1436, 116.6664),  # 揭阳潮汕机场
            "ZHA": (21.2144, 110.3583),  # 湛江机场
            "BAV": (23.7208, 106.9592),  # 百色巴马机场
        }
        
        if airport_code.upper() not in airport_coords:
            return {
                "status": "error",
                "message": f"不支持的机场代码: {airport_code}",
                "supported_airports": list(airport_coords.keys())
            }
        
        lat, lon = airport_coords[airport_code.upper()]
        
        # 创建机场周边边界框(约30公里范围)
        delta = 0.25  # 约30公里
        bbox = (lat - delta, lat + delta, lon - delta, lon + delta)
        
        result = self.get_all_states(bbox)
        
        if result.get("status") == "success":
            result["airport_code"] = airport_code.upper()
            result["airport_coordinates"] = {"latitude": lat, "longitude": lon}
            result["search_radius_km"] = 30
            result["message"] = f"{airport_code}机场周边找到 {result.get('flight_count', 0)} 架航班"
        
        return result
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 query scope (30km radius) and supported airport codes, but lacks critical details: whether this is a read-only operation, potential rate limits, authentication needs, error handling, or what the output format looks like. For a query tool with zero annotation coverage, this is insufficient.

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 concise and front-loaded: it states the core functionality in the first sentence and adds supporting details in the second. There's no wasted text, though it could be slightly more structured (e.g., bullet points for parameters).

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 the complexity (query tool with geographic filtering), lack of annotations, and no output schema, the description is incomplete. It misses behavioral traits (e.g., read-only status, rate limits), full parameter documentation, and output details. For a tool with two parameters and no structured support, this leaves significant gaps for an AI agent.

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 0%, so the description must compensate. It explains 'airport_code' by listing examples (PEK, PVG, CAN) and implies 'flight_type' through context (departures/arrivals), but doesn't detail allowed values or defaults. The description adds some meaning beyond the bare schema, but doesn't fully document both parameters, resulting in a baseline score.

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: '查询指定机场周边30公里范围内的所有航班' (query all flights within 30km of a specified airport). It specifies the verb (query) and resource (flights) with a geographic scope. However, it doesn't explicitly differentiate from sibling tools like 'getFlightsInArea' or 'getFlightInfo', which might have overlapping functionality.

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?

The description provides minimal usage guidance: it mentions supporting major airport codes like PEK, PVG, CAN, but offers no explicit advice on when to use this tool versus alternatives (e.g., 'getFlightsInArea' or 'getFlightInfo'). There's no mention of prerequisites, exclusions, or comparative context with siblings.

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/xiaonieli7/FlightTicketMCP'

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