Skip to main content
Glama

maps_ip_location

Locate geographic positions using IP addresses with the Gaode Maps MCP server tool.

Instructions

IP 定位根据用户输入的 IP 地址,定位 IP 的所在位置

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipYes

Implementation Reference

  • The handler function for the 'maps_ip_location' tool. It takes an IP address as input, queries the Amap IP geolocation API (https://restapi.amap.com/v3/ip), and returns location details including province, city, adcode, and bounding rectangle. Includes error handling for API failures.
    @mcp.tool() def maps_ip_location(ip: str) -> Dict[str, Any]: """IP 定位根据用户输入的 IP 地址,定位 IP 的所在位置""" try: response = requests.get( "https://restapi.amap.com/v3/ip", params={ "key": AMAP_MAPS_API_KEY, "ip": ip } ) response.raise_for_status() data = response.json() if data["status"] != "1": return {"error": f"IP Location failed: {data.get('info') or data.get('infocode')}"} return { "province": data.get("province"), "city": data.get("city"), "adcode": data.get("adcode"), "rectangle": data.get("rectangle") } except requests.exceptions.RequestException as e: return {"error": f"Request failed: {str(e)}"}
  • The @mcp.tool() decorator registers the maps_ip_location function as an MCP tool.
    @mcp.tool()
  • Function signature defines input schema (ip: str) and output (Dict[str, Any]). Docstring provides tool description in Chinese.
    def maps_ip_location(ip: str) -> Dict[str, Any]: """IP 定位根据用户输入的 IP 地址,定位 IP 的所在位置"""

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