maps_regeocode
Convert Gaode Map latitude-longitude coordinates into administrative address information to identify location details from geographic points.
Instructions
将一个高德经纬度坐标转换为行政区划地址信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| location | Yes |
Implementation Reference
- amap_mcp_server/server.py:20-42 (handler)The core handler function for the 'maps_regeocode' tool. It takes a location string (coordinates), calls the Amap regeocode API, and returns province, city, district or error.def maps_regeocode(location: str) -> Dict[str, Any]: """将一个高德经纬度坐标转换为行政区划地址信息""" try: response = requests.get( "https://restapi.amap.com/v3/geocode/regeo", params={ "key": AMAP_MAPS_API_KEY, "location": location } ) response.raise_for_status() data = response.json() if data["status"] != "1": return {"error": f"RGeocoding failed: {data.get('info') or data.get('infocode')}"} return { "province": data["regeocode"]["addressComponent"]["province"], "city": data["regeocode"]["addressComponent"]["city"], "district": data["regeocode"]["addressComponent"]["district"] } except requests.exceptions.RequestException as e: return {"error": f"Request failed: {str(e)}"}
- amap_mcp_server/server.py:19-19 (registration)Registers the maps_regeocode function as a tool in the FastMCP server instance.@mcp.tool()
- amap_mcp_server/server.py:20-21 (schema)Function signature and docstring define the input schema (location: str) and purpose; output inferred as Dict[str, Any]. Used by FastMCP to generate tool schema.def maps_regeocode(location: str) -> Dict[str, Any]: """将一个高德经纬度坐标转换为行政区划地址信息"""
- amap_mcp_server/server.py:15-15 (helper)Global API key setup used by all tools including maps_regeocode.AMAP_MAPS_API_KEY = get_api_key()