Skip to main content
Glama
aixi134

mcp-meituan-ip

by aixi134

get-latlng

Convert latitude and longitude coordinates into detailed location information using this tool, ideal for pinpointing precise addresses or geographic data.

Instructions

根据经纬度获取详细位置信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latYes
lngYes

Implementation Reference

  • Core handler function that executes the get-latlng tool logic: queries Meituan API with lat/lng and returns structured CityDetailData.
    def get_latlng(lat: str, lng: str) -> CityDetailData:
        api_url = f'https://apimobile.meituan.com/group/v1/city/latlng/{lat},{lng}'
        params = {
            "tag": 0
        }
        response = requests.get(api_url, params=params)
    
        response.raise_for_status()  # 检查请求是否成功(4xx/5xx 会抛出异常)
    
        data = response.json()["data"]  # 解析 JSON
    
    
    
        # 构建 CityDetailData 对象
        location = CityDetailData(
            detail= data["detail"],
            parentArea= data["parentArea"],
            cityPinyin= data["cityPinyin"],
            lng= data["lng"],
            isForeign= data["isForeign"],
            dpCityId= data["dpCityId"],
            country= data["country"],
            isOpen= data["isOpen"],
            city= data["city"],
            id= data["id"],
            openCityName= data["openCityName"],
            originCityID= data["originCityID"],
            area= data["area"],
            areaName= data["areaName"],
            province= data["province"],
            district= data["district"],
            lat= data["lat"]
        )
    
        return location
  • Registers the get-latlng tool with MCP server including name, description, and JSON input schema.
    types.Tool(
        name="get-latlng",
        description="根据经纬度获取详细位置信息",
        inputSchema={
            "type": "object",
            "properties": {
                "lat": {"type": "string"},
                "lng": {"type": "string"},
            },
            "required": ["lat", "lng"],
        },
    )
  • Tool dispatch handler case that validates arguments, calls get_latlng function, and formats response.
    case 'get-latlng':
        if not all(
                k in arguments
                for k in ["lat", "lng"]
        ):
            raise ValueError("Missing required arguments")
        result = get_latlng(lat= arguments['lat'], lng= arguments['lng'])
        # 转换为字典后序列化
        location_dict = asdict(result)
        # Notify clients that resources have changed
        await server.request_context.session.send_resource_list_changed()
  • Pydantic-style dataclass defining the output schema/structure for get-latlng response.
    class CityDetailData:
        detail: str
        parentArea: int
        cityPinyin: str
        lng: float
        isForeign: bool
        dpCityId: int
        country: str
        isOpen: bool
        city: str
        id: int
        openCityName: str
        originCityID: int
        area: int
        areaName: str
        province: str
        district: str
        lat: float
Install Server

Other Tools

Related 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/aixi134/mcp-meituan-ip'

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