maps_text_search
Search for points of interest using keywords to find locations like restaurants, gas stations, or other facilities in specified cities.
Instructions
关键词搜,根据用户传入关键词,搜索出相关的POI
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keywords | Yes | 搜索关键词 | |
| city | No | 查询城市 | |
| types | No | POI类型,比如加油站 |
Implementation Reference
- build/index.js:743-795 (handler)Core handler function for maps_text_search tool. Makes API call to Amap's place/text endpoint with keywords, city, citylimit, processes response including suggestions and POIs, handles errors, and returns formatted content.async function handleTextSearch(keywords, city = "", citylimit = "false") { const url = new URL("https://restapi.amap.com/v3/place/text"); url.searchParams.append("key", AMAP_MAPS_API_KEY); url.searchParams.append("keywords", keywords); url.searchParams.append("city", city); url.searchParams.append("citylimit", citylimit); 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: `Text Search failed: ${data.info || data.infocode}`, }], isError: true, }; } let resciytes = data.suggestion && data.suggestion.ciytes ? data.suggestion.ciytes.map((city) => { return { name: city.name, }; }) : []; return { content: [{ type: "text", text: JSON.stringify( { suggestion: { keywords: data.suggestion.keywords, ciytes: resciytes, }, pois: data.pois.map((poi) => { return { id: poi.id, name: poi.name, address: poi.address, typecode: poi.typecode, photos: poi.photos && poi.photos.length > 0 ? poi.photos[0] : undefined, }; }), }, null, 2, ), }], isError: false, }; }
- build/index.js:188-209 (schema)Schema definition for the maps_text_search tool, including name, description, inputSchema with properties keywords (required), city, types.const TEXT_SEARCH_TOOL = { name: "maps_text_search", description: "关键词搜,根据用户传入关键词,搜索出相关的POI", inputSchema: { type: "object", properties: { keywords: { type: "string", description: "搜索关键词", }, city: { type: "string", description: "查询城市", }, types: { type: "string", description: "POI类型,比如加油站", }, }, required: ["keywords"], }, };
- build/index.js:848-850 (registration)Registration via ListToolsRequestSchema handler that returns the list of tools including maps_text_search.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: MAPS_TOOLS, }));
- build/index.js:894-897 (registration)Dispatch registration in the CallToolRequestSchema switch statement that calls the handler for maps_text_search.case "maps_text_search": { const { keywords, city, citylimit } = request.params.arguments; return await handleTextSearch(keywords, city, citylimit); }
- build/streamable-http.js:832-852 (schema)Identical schema definition in the HTTP server version.const TEXT_SEARCH_TOOL = { name: "maps_text_search", description: "关键词搜,根据用户传入关键词,搜索出相关的POI", inputSchema: { type: "object", properties: { keywords: { type: "string", description: "搜索关键词", }, city: { type: "string", description: "查询城市", }, types: { type: "string", description: "POI类型,比如加油站", }, }, required: ["keywords"], },