Skip to main content
Glama

maps_ip_location

Locate geographic positions using IP addresses to determine physical locations and map coordinates for network analysis and location-based services.

Instructions

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

Input Schema

NameRequiredDescriptionDefault
ipYes

Input Schema (JSON Schema)

{ "properties": { "ip": { "title": "Ip", "type": "string" } }, "required": [ "ip" ], "type": "object" }

Implementation Reference

  • The main handler function for the 'maps_ip_location' tool. It queries the Amap IP location API with the provided IP address and returns location details like province, city, adcode, and rectangle. The @mcp.tool() decorator registers the tool and infers the schema from the function signature (ip: str) and docstring.
    @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)}"}

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