Skip to main content
Glama
masx200

AMap Maps MCP Server

by masx200

maps_ip_location

Find geographic locations from IP addresses using AMap Maps API. Input an IP to get detailed positioning data for Chinese locations.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipYesIP地址

Implementation Reference

  • Handler function that performs IP geolocation by querying the Amap API with the provided IP address and returns the province, city, adcode, and rectangle.
    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, }; }
  • Tool schema definition including name, description, and input schema requiring an 'ip' string 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)
    Dispatch case in the CallToolRequestSchema handler that extracts 'ip' argument and calls handleIPLocation.
    case "maps_ip_location": { const { ip } = request.params.arguments; return await handleIPLocation(ip); }
  • build/index.js:247-260 (registration)
    MAPS_TOOLS array registration including IP_LOCATION_TOOL, returned by ListToolsRequestSchema handler.
    const MAPS_TOOLS = [ REGEOCODE_TOOL, GEO_TOOL, IP_LOCATION_TOOL, WEATHER_TOOL, SEARCH_DETAIL_TOOL, BICYCLING_TOOL, WALKING_TOOL, DRIVING_TOOl, TRANSIT_INTEGRATED_TOOL, DISTANCE_TOOL, TEXT_SEARCH_TOOL, AROUND_SEARCH_TOOL, ];

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