MCP Tools Reference: mapstools.googleapis.com

工具:search_places

当用户的请求是查找地点、商家、地址、位置、兴趣点或任何其他与 Google 地图相关的搜索时,请调用此工具。

输入要求(关键)

  1. text_query(字符串 - 必需):主要搜索查询。这必须清楚地定义用户正在寻找的内容。

    • 示例'restaurants in New York''coffee shops near Golden Gate Park''SF MoMA''1600 Amphitheatre Pkwy, Mountain View, CA, USA''pets friendly parks in Manhattan, New York''date night restaurants in Chicago''accessible public libraries in Los Angeles'
    • 对于特定地点详情:请添加所请求的属性(例如,'Google Store Mountain View opening hours''SF MoMa phone number''Shoreline Park Mountain View address')。
  2. location_bias(对象 - 可选):使用此参数可优先显示特定地理区域附近的结果。

    • 格式{"location_bias": {"circle": {"center": {"latitude": [value], "longitude": [value]}, "radius_meters": [value (optional)]}}}
    • 用法
      • 偏向 5 公里半径{"location_bias": {"circle": {"center": {"latitude": 34.052235, "longitude": -118.243683}, "radius_meters": 5000}}}
      • 强烈偏向中心点{"location_bias": {"circle": {"center": {"latitude": 34.052235, "longitude": -118.243683}}}}(省略 radius_meters)。
  3. language_code(字符串 - 可选):显示搜索结果摘要所用的语言。

    • 格式:一个双字母语言代码 (ISO 639-1),可以选择后跟一个下划线和一个双字母国家/地区代码 (ISO 3166-1 alpha-2),例如:enjaen_USzh_CNes_MX。如果未提供语言代码,结果将以英语显示。
  4. region_code(字符串 - 可选):用户的 Unicode CLDR 地区代码。此参数用于显示地点详情,例如特定于区域的地点名称(如果有)。此参数可能会根据适用法律影响结果。

    • 格式:双字母国家/地区代码 (ISO 3166-1 alpha-2),例如 USCA

Instructions for Tool Call:

  • 位置信息(严重):搜索内容必须包含足够的位置信息。如果位置不明确(例如,仅为“披萨店”),您必须text_query 中指定位置(例如,“纽约的披萨店”)或使用 location_bias 参数。如果需要消除歧义,请添加城市、省/直辖市/自治区和地区/国家/地区名称。

  • 始终提供尽可能具体且贴合上下文的 text_query

  • 仅当明确提供坐标时,或者当从用户的已知情境推断位置信息对于获得更好的结果是适当必要的时,才使用 location_bias

以下示例演示了如何使用 curl 调用 search_places MCP 工具。

Curl 请求
                  
curl --location 'https://mapstools.googleapis.com/mcp' \
--header 'content-type: application/json' \
--header 'accept: application/json, text/event-stream' \
--data '{
  "method": "tools/call",
  "params": {
    "name": "search_places",
    "arguments": {
      // provide these details according to the tool's MCP specification
    }
  },
  "jsonrpc": "2.0",
  "id": 1
}'
                

输入架构

针对 SearchText 的请求消息。

SearchTextRequest

JSON 表示法
{
  "textQuery": string,
  "languageCode": string,
  "regionCode": string,
  "pageSize": integer,
  "pageToken": string,

  // Union field _location_bias can be only one of the following:
  "locationBias": {
    object (LocationBias)
  }
  // End of list of possible types for union field _location_bias.
}
字段
textQuery

string

必需。文本查询。

languageCode

string

可选。请求返回摘要时使用的语言。如果未指定或无法识别语言代码,则返回首选语言为英语的摘要。

例如,“en”表示英语。

当前支持的语言列表:https://developers.google.com/maps/faq#languagesupport

regionCode

string

可选。请求来源地的 Unicode 国家/地区代码 (CLDR)。此参数用于显示地点详情,例如特定于区域的地点名称(如果有)。此参数可能会根据适用法律影响结果。

例如,“US”表示美国。

如需了解详情,请参阅 https://www.unicode.org/cldr/charts/latest/supplemental/territory_language_information.html

请注意,目前不支持 3 位数的地区代码。

pageSize

integer

可选。要返回的地点数量上限。服务返回的值可能小于此值。

pageToken

string

可选。从之前的 SearchText 调用接收的页面令牌。利用其进行后续页面检索。

联合字段 _location_bias

_location_bias 只能是下列其中一项:

locationBias

object (LocationBias)

用于使搜索结果偏向于特定区域的可选参数。如果 text_query 中包含明确的位置信息,则系统会使用该位置信息来调整搜索结果,而不是使用此字段。

LocationBias

JSON 表示法
{
  "circle": {
    object (Circle)
  }
}
字段
circle

object (Circle)

可选。由中心点和半径定义的圆。radius_meters 是可选设置,如果未设置,结果将偏向中心点。

圆形

JSON 表示法
{
  "center": {
    object (google.type.LatLng)
  },

  // Union field _radius_meters can be only one of the following:
  "radiusMeters": number
  // End of list of possible types for union field _radius_meters.
}
字段
center

object (google.type.LatLng)

必需。圆的中心点。

联合字段 _radius_meters

_radius_meters 只能是下列其中一项:

radiusMeters

number

圆的半径(以米为单位)。半径必须在 50,000 米以内。

LatLng

JSON 表示法
{
  "latitude": number,
  "longitude": number
}
字段
latitude

number

纬度(以度为单位)。它必须在 [-90.0, +90.0] 范围内。

longitude

number

经度(以度为单位)。它必须在 [-180.0, +180.0] 范围内。

输出架构

针对 SearchText 的响应消息。

SearchTextResponse

JSON 表示法
{
  "places": [
    {
      object (PlaceView)
    }
  ],
  "summary": string,
  "nextPageToken": string
}
字段
places[]

object (PlaceView)

仅限输出。摘要中提及的地点的列表。

summary

string

仅限输出。搜索结果的自然语言摘要。摘要可能包含从零开始的引用,例如“[0]”“[1]”“[2]”等。这些引用会映射到 places 字段中的相应位置。

nextPageToken

string

可选。可作为 page_token 发送并用于检索下一页的令牌。

PlaceView

JSON 表示法
{
  "place": string,
  "id": string,
  "googleMapsLinks": {
    object (GoogleMapsLinks)
  },

  // Union field _location can be only one of the following:
  "location": {
    object (google.type.LatLng)
  }
  // End of list of possible types for union field _location.
}
字段
place

string

底层地点的资源名称,格式为“places/{id}”。

id

string

底层地点的地点 ID。

googleMapsLinks

object (GoogleMapsLinks)

用于触发不同 Google 地图操作的链接。

联合字段 _location

_location 只能是下列其中一项:

location

object (google.type.LatLng)

相应地点的地理坐标。

LatLng

JSON 表示法
{
  "latitude": number,
  "longitude": number
}
字段
latitude

number

纬度(以度为单位)。它必须在 [-90.0, +90.0] 范围内。

longitude

number

经度(以度为单位)。它必须在 [-180.0, +180.0] 范围内。

JSON 表示法
{
  "directionsUrl": string,
  "placeUrl": string,
  "writeAReviewUrl": string,
  "reviewsUrl": string,
  "photosUrl": string
}
字段
directionsUrl

string

用于显示前往相应地点的路线的链接。该链接仅填充目的地位置,并使用默认出行方式 DRIVE

placeUrl

string

用于显示相应地点的链接。

writeAReviewUrl

string

用于在 Google 地图上为此地点撰写评价的链接。

reviewsUrl

string

用于在 Google 地图上显示相应地点的评价的链接。

photosUrl

string

用于在 Google 地图上显示相应地点的评价的链接。

工具注释

破坏性提示:❌ | 等幂性提示:❌ | 只读提示:✅ | 开放世界提示:❌