Skip to main content
Glama

maps_regeocode

Convert Gaode Map latitude-longitude coordinates into administrative address information to identify location details from geographic points.

Instructions

将一个高德经纬度坐标转换为行政区划地址信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationYes

Implementation Reference

  • 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)}"}
  • Registers the maps_regeocode function as a tool in the FastMCP server instance.
    @mcp.tool()
  • 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]:
        """将一个高德经纬度坐标转换为行政区划地址信息"""
  • Global API key setup used by all tools including maps_regeocode.
    AMAP_MAPS_API_KEY = get_api_key()

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/sugarforever/amap-mcp-server'

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