MCP Tools Reference: mapstools.googleapis.com

MCP 工具参考文档:

本文档介绍了用于调用 Google 远程模型上下文协议 (MCP) 工具的面向外部的 REST API 端点。此 API 充当外部 HTTP 客户端(例如 curl 或 Web 服务)与内部 MCP 服务器之间的安全代理。

获取 MCP 工具规范

如需获取 MCP 服务器中所有工具的 MCP 工具规范,请使用 `tools/list` 方法。以下示例演示了如何使用 curl 列出 MCP 服务器中当前可用的所有工具及其规范。

Curl 请求
curl --location 'https://mapstools.googleapis.com/mcp'
--header 'content-type: application/json'
--header 'accept: application/json, text/event-stream'
--data '{
    "method": "tools/list",
    "jsonrpc": "2.0",
    "id": 1
}'
                  

工具: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: {
      // please fill these details according to tools MCP specification
    }
  },
  "jsonrpc": "2.0",
  "id": 1
}'
                

工具:lookup_weather

提供任何地点的天气实况、每小时预报和每日预报。请使用此工具咨询所有与天气相关的问题。

可获取的具体数据:温度(当前温度、体感温度、最高/最低温度、热指数)、风(风速、阵风、风向)、天体事件(日出/日落、月相)、降水(类型、概率、降水量/QPF)、大气状况(紫外线指数、湿度、云量、雷暴概率)和地理编码位置地址。

输入要求(关键)

  • 当前状况:仅需要位置信息(例如城市或地址)。请勿指定日期或小时。

  • 每小时天气预报:需要位置和小时(0-23)。如果用户询问特定时间的天气,或使用“未来几小时”或“今天晚些时候”等字词,请使用此 intent。

  • 每日天气预报:需要提供位置信息和完整日期。

日期处理(严重):用户提供的日期和时间必须采用所请求位置的本地时区。日期必须分解为单独的整数形参:年、月和日。这些参数的必需格式为:{"year": , "month": , "day": }

以下示例演示了如何使用 curl 调用 lookup_weather 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": lookup_weather,
    arguments: {
      // please fill these details according to tools MCP specification
    }
  },
  "jsonrpc": "2.0",
  "id": 1
}'
                

工具:compute_routes

计算指定出发地和目的地之间的出行路线。支持的出行方式:DRIVE(默认)、WALK。

输入要求(严重):需要同时提供出发地目的地。必须使用以下方法之一在相应字段中嵌套提供每个参数:

  • address:(字符串,例如 “巴黎埃菲尔铁塔”)。注意:输入的地址越精细或越具体,结果就越好。

  • lat_lng::(对象,{"latitude": number, "longitude": number})

  • place_id:(字符串,例如 'ChIJOwE_Id1w5EAR4Q27FkL6T_0') 注意:此 ID 可通过 search_places 工具获取。允许使用任何输入类型组合(例如,按地址指定出发地,按 lat_lng 指定目的地)。如果缺少出发地或目的地,您必须先询问用户以明确信息,然后再尝试调用该工具。

工具调用示例:{"origin":{"address":"Eiffel Tower"},"destination":{"place_id":"ChIJt_5xIthw5EARoJ71mGq7t74"},"travel_mode":"DRIVE"}

以下示例演示了如何使用 curl 调用 compute_routes 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": compute_routes,
    arguments: {
      // please fill these details according to tools MCP specification
    }
  },
  "jsonrpc": "2.0",
  "id": 1
}'