maps_text_search
Search for points of interest using keywords to find locations, addresses, and related information on maps.
Instructions
关键词搜索 API 根据用户输入的关键字进行 POI 搜索,并返回相关的信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keywords | Yes | ||
| city | No | ||
| citylimit | No | false |
Implementation Reference
- amap_mcp_server/server.py:666-707 (handler)The handler function for the 'maps_text_search' tool. It performs a text-based POI search using the Amap Maps API v3/place/text endpoint, taking keywords, optional city, and citylimit parameters. It processes the response to return suggestions and POIs or errors.@mcp.tool() def maps_text_search(keywords: str, city: str = "", citylimit: str = "false") -> Dict[str, Any]: """关键词搜索 API 根据用户输入的关键字进行 POI 搜索,并返回相关的信息""" try: response = requests.get( "https://restapi.amap.com/v3/place/text", params={ "key": AMAP_MAPS_API_KEY, "keywords": keywords, "city": city, "citylimit": citylimit } ) response.raise_for_status() data = response.json() if data["status"] != "1": return {"error": f"Text Search failed: {data.get('info') or data.get('infocode')}"} suggestion_cities = [] if data.get("suggestion", {}).get("cities"): for city in data["suggestion"]["cities"]: suggestion_cities.append({"name": city.get("name")}) pois = [] for poi in data.get("pois", []): pois.append({ "id": poi.get("id"), "name": poi.get("name"), "address": poi.get("address"), "typecode": poi.get("typecode") }) return { "suggestion": { "keywords": data.get("suggestion", {}).get("keywords"), "cities": suggestion_cities }, "pois": pois } except requests.exceptions.RequestException as e: return {"error": f"Request failed: {str(e)}"}