Skip to main content
Glama
Yang-Charles

Amap (Gaode Maps) MCP Server

by Yang-Charles

search_nearby

Search for nearby points of interest (POIs) using coordinates and keywords. Find restaurants, shops, or other locations within a specified radius on Gaode Maps.

Instructions

根据经纬度和关键词进行周边搜索,返回指定半径内的 POI 列表。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationYes中心点经纬度,格式为 'lng,lat',如 '116.397128,39.916527'
keywordsNo搜索关键词,例如: '餐厅'。
typesNoPOI 分类码,多个分类用逗号分隔
radiusNo搜索半径(米),最大50000
page_numNo页码,从1开始
page_sizeNo每页数量,最大25

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataNo
metaNo
errorNo
successYes

Implementation Reference

  • MCP tool handler for 'search_nearby'. Registers the tool with @mcp.tool and implements the logic by calling the underlying GdSDK.search_nearby method, handles errors, and wraps response in ApiResponse.
    @mcp.tool(name="search_nearby", description="根据经纬度和关键词进行周边搜索,返回指定半径内的 POI 列表。")
    async def search_nearby(
            location: Annotated[str, Field(description="中心点经纬度,格式为 'lng,lat',如 '116.397128,39.916527'")],
            keywords: Annotated[str, Field(description="搜索关键词,例如: '餐厅'。", min_length=0)] = "",
            types: Annotated[str, Field(description="POI 分类码,多个分类用逗号分隔")] = "",
            radius: Annotated[int, Field(description="搜索半径(米),最大50000", ge=0, le=50000)] = 1000,
            page_num: Annotated[int, Field(description="页码,从1开始", ge=1)] = 1,
            page_size: Annotated[int, Field(description="每页数量,最大25", ge=1, le=25)] = 20,
    ) -> ApiResponse:
      """
       周边搜索。
    
       Args:
           location (str): 中心点经纬度,格式为 "lng,lat"。
           keywords (str, optional): 搜索关键词,默认为空。
           types (str, optional): POI 分类,默认为空。
           radius (int, optional): 搜索半径(米),最大 50000,默认为 1000。
           page_num (int, optional): 页码,默认为 1。
           page_size (int, optional): 每页数量,最大 25,默认为 10。
    
       Returns:
           dict: 包含搜索结果的字典。
      """
      logger.info(f"Searching nearby: location={location}, keywords={keywords}, types={types}, radius={radius}, page_num={page_num}, page_size={page_size}")
      try:
        result = await sdk.search_nearby(location=location, keywords=keywords, types=types, radius=radius, page_num=page_num, page_size=page_size)
        if not result:
          return ApiResponse.fail("搜索结果为空,请检查日志,系统异常请检查相关日志,日志默认路径为/var/log/build_mcp。")
        logger.info(f"Search nearby result: {result}")
        return ApiResponse.ok(data=result, meta={
          "location": location,
          "keywords": keywords,
          "types": types,
          "radius": radius,
          "page_num": page_num,
          "page_size": page_size
        })
      except Exception as e:
        logger.error(f"Error searching nearby: {e}")
        return ApiResponse.fail(str(e))
  • Pydantic model defining the output schema for the tool responses, used by search_nearby handler.
    class ApiResponse(BaseModel, Generic[T]):
      success: bool
      data: Optional[T] = None
      error: Optional[str] = None
      meta: Optional[Dict[str, Any]] = None
    
      @classmethod
      def ok(cls, data: T, meta: Dict[str, Any] = None) -> "ApiResponse[T]":
        return cls(success=True, data=data, meta=meta)
    
      @classmethod
      def fail(cls, error: str, meta: Dict[str, Any] = None) -> "ApiResponse[None]":
        return cls(success=False, error=error, meta=meta)
  • Supporting utility in GdSDK class that performs the actual HTTP request to Amap API for nearby POI search, with retry logic.
    async def search_nearby(self, location: str, keywords: str = "", types: str = "", radius: int = 1000, page_num: int = 1, page_size: int = 20) -> dict | None:
      """
      周边搜索(新版 POI)
      https://lbs.amap.com/api/webservice/guide/api-advanced/newpoisearch#t4
    
      Args:
          location (str): 中心点经纬度,格式为 "lng,lat"
          keywords (str, optional): 搜索关键词
          types (str, optional): POI 分类
          radius (int, optional): 搜索半径(米),最大 50000,默认 1000
          page_num (int, optional): 页码,默认 1
          page_size (int, optional): 每页数量,默认 20,最大 25
    
      Returns:
          dict | None: 搜索结果,失败时返回 None
      """
      url = f"{self.base_url}/v5/place/around"
      params = {
        "key": self.api_key,
        "location": location,
        "keywords": keywords,
        "types": types,
        "radius": radius,
        "page_num": page_num,
        "page_size": page_size,
      }
    
      result = await self._request_with_retry(
        method="GET",
        url=url,
        params=params,
      )
    
      if result and result.get("status") == "1":
        return result
      else:
        self.logger.error(f"周边搜索失败: {result}")
        return None
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the basic operation (search and return POI list) but doesn't describe important behavioral aspects like whether this is a read-only operation, potential rate limits, authentication requirements, error conditions, or what happens when no results are found. For a search tool with 6 parameters and no annotation coverage, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states the core functionality without unnecessary words. It's appropriately sized for the tool's complexity and front-loads the essential information (search based on location/keywords, returns POIs within radius). Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that there's an output schema (which should document return values), no annotations, and 100% schema coverage for parameters, the description provides adequate basic context. However, for a search tool with pagination parameters and no behavioral annotations, the description could better address usage patterns, result limitations, or common scenarios. It's minimally viable but lacks depth for optimal agent understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 6 parameters thoroughly. The description mentions '经纬度和关键词' (longitude/latitude and keywords) and '指定半径' (specified radius), which aligns with parameters in the schema but doesn't add meaningful semantic context beyond what's already in the parameter descriptions. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '根据经纬度和关键词进行周边搜索,返回指定半径内的 POI 列表' (Search nearby based on longitude/latitude and keywords, returning a list of POIs within a specified radius). It specifies the verb ('搜索' - search), resource ('POI 列表' - POI list), and scope ('周边' - nearby/within radius). However, it doesn't explicitly differentiate from the sibling tool 'locate_ip', which appears to be a different type of location tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention the sibling tool 'locate_ip' or any other potential alternatives. There's no information about prerequisites, appropriate contexts, or when this tool would be preferred over other search or location tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Yang-Charles/build-mcp'

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