Skip to main content
Glama
masx200

AMap Maps MCP Server

by masx200

maps_ip_location

Locate the geographic position of any IP address to determine its physical location for location-based services and geographic analysis.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipYesIP地址

Implementation Reference

  • The handler function that executes the maps_ip_location tool logic. It fetches the IP location from Amap API using the provided IP, handles errors, and returns formatted JSON response.
    async function handleIPLocation(ip) { const url = new URL("https://restapi.amap.com/v3/ip"); url.searchParams.append("ip", ip); url.searchParams.append("key", AMAP_MAPS_API_KEY); url.searchParams.append("source", "ts_mcp"); const response = await fetch(url.toString()); const data = await response.json(); if (data.status !== "1") { return { content: [{ type: "text", text: `IP Location failed: ${data.info || data.infocode}`, }], isError: true, }; } return { content: [{ type: "text", text: JSON.stringify( { province: data.province, city: data.city, adcode: data.adcode, rectangle: data.rectangle, }, null, 2, ), }], isError: false, }; }
  • The input schema definition for the maps_ip_location tool, defining the expected 'ip' parameter.
    const IP_LOCATION_TOOL = { name: "maps_ip_location", description: "IP 定位根据用户输入的 IP 地址,定位 IP 的所在位置", inputSchema: { type: "object", properties: { ip: { type: "string", description: "IP地址", }, }, required: ["ip"], }, };
  • build/index.js:862-865 (registration)
    The switch case in the CallToolRequestHandler that registers and dispatches to the handleIPLocation function for the tool.
    case "maps_ip_location": { const { ip } = request.params.arguments; return await handleIPLocation(ip); }
  • build/index.js:247-250 (registration)
    The tools array registration where IP_LOCATION_TOOL is included for list tools request.
    const MAPS_TOOLS = [ REGEOCODE_TOOL, GEO_TOOL, IP_LOCATION_TOOL,
  • Duplicate handler dispatch case in the streamable HTTP server version.
    case "maps_ip_location": { const { ip } = request.params.arguments; return await handleIPLocation(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/masx200/amap-maps-mcp-server'

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