MCP Tools Reference: mapstools.googleapis.com

工具:compute_routes

計算指定起點和目的地之間的路線。支援的交通方式:DRIVE (預設)、WALK。

輸入規定 (重要):必須同時提供出發地目的地。您必須使用下列其中一種方法,在各自的欄位中提供這些資訊:

  • 地址: (字串,例如 「巴黎艾菲爾鐵塔」)。注意:輸入的地址越精細或具體,結果就越準確。

  • 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": {
      // provide these details according to the tool's MCP specification
    }
  },
  "jsonrpc": "2.0",
  "id": 1
}'
                

輸入結構定義

ComputeRoutesRequest。

ComputeRoutesRequest

JSON 表示法
{
  "origin": {
    object (Waypoint)
  },
  "destination": {
    object (Waypoint)
  },
  "travelMode": enum (RouteTravelMode)
}
欄位
origin

object (Waypoint)

必填。起點路線控點。

destination

object (Waypoint)

必填。目的地航點。

travelMode

enum (RouteTravelMode)

(選用步驟) 指定交通方式。

途經點

JSON 表示法
{

  // Union field location_type can be only one of the following:
  "latLng": {
    object (google.type.LatLng)
  },
  "placeId": string,
  "address": string
  // End of list of possible types for union field location_type.
}
欄位
聯集欄位 location_type。表示位置的不同方式。location_type 只能是下列其中一項:
latLng

object (google.type.LatLng)

使用地理座標指定的點。

placeId

string

與途中的地點相關聯的地點 ID。

address

string

使用者可理解的地址或 Plus Code。詳情請參閱 https://plus.codes

LatLng

JSON 表示法
{
  "latitude": number,
  "longitude": number
}
欄位
latitude

number

緯度度數,必須介於 [-90.0, +90.0] 的範圍之間。

longitude

number

經度度數,必須介於 [-180.0, +180.0] 的範圍之間。

輸出內容的結構定義

ComputeRoutesResponse。

ComputeRoutesResponse

JSON 表示法
{
  "routes": [
    {
      object (Route)
    }
  ]
}
欄位
routes[]

object (Route)

包含所要求起點和目的地之間的路線。目前只會傳回一條路線。

路線

JSON 表示法
{
  "distanceMeters": integer,
  "duration": string
}
欄位
distanceMeters

integer

路線的移動距離 (以公尺為單位)。

duration

string (Duration format)

導覽路線所需的時間長度。

時間長度以秒為單位,最多可有 9 個小數位數,並應以「s」結尾,例如:"3.5s"

時間長度

JSON 表示法
{
  "seconds": string,
  "nanos": integer
}
欄位
seconds

string (int64 format)

時間範圍的秒數 (可為負值)。必須介於 -315,576,000,000 到 +315,576,000,000 之間 (含這兩個值)。注意:這些界限是根據以下計算得出:60 秒/分鐘 * 60 分鐘/小時 * 24 小時/天 * 365.25 天/年 * 10000 年

nanos

integer

時間跨度的小數部分 (以奈秒為單位),可為正數或負數。如果時間長度不到一秒,系統會以 0 seconds 欄位和正數或負數 nanos 欄位表示。如果時間長度為一秒以上,nanos 欄位的非零值必須與 seconds 欄位相同。值必須介於 -999,999,999 和 +999,999,999 之間 (含)。

工具註解

破壞性提示:❌ | 等冪提示:❌ | 唯讀提示:✅ | 開放世界提示:❌