Optimize Multi-Stop Route
optimization_toolFinds an optimal travel-time route through 2–12 coordinates by solving the Traveling Salesman Problem, with start, end, and roundtrip options.
Instructions
Find the optimal (shortest by travel time) route through a set of 2-12 coordinates. Solves the Traveling Salesman Problem to determine the best visiting order. Supports options for starting point, ending point, and whether to return to start.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"coordinates": "<coordinates>"
},
"name": "optimization_tool"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| steps | No | Whether to include turn-by-turn instructions | |
| source | No | Location to start the trip. IMPORTANT: If you set roundtrip=false you MUST set source="first" (and destination="last"). The Mapbox V1 API rejects roundtrip=false with source="any". "any" allows the optimizer to pick any coordinate as the start (only valid when roundtrip=true). | any |
| profile | No | Routing profile to use for optimization | mapbox/driving |
| language | No | Language for instructions (if steps=true). ISO 639-1 code (e.g., "en", "es"). | |
| overview | No | Detail level of route geometry | simplified |
| roundtrip | No | Whether to return to the starting point. Default true returns a closed loop through the coordinates. Set false for one-way trips — REQUIRES source="first" AND destination="last" together. Passing roundtrip=false without both endpoint constraints will fail. | |
| geometries | No | Format for route geometry | geojson |
| annotations | No | Additional metadata to include for each route segment | |
| coordinates | Yes | Array of {longitude, latitude} coordinate pairs to optimize a route through. The V1 API supports 2-12 coordinates and returns the optimal visiting order. | |
| destination | No | Location to end the trip. IMPORTANT: If you set roundtrip=false you MUST set destination="last" (and source="first"). The Mapbox V1 API rejects roundtrip=false with destination="any". "any" allows the optimizer to pick any coordinate as the end (only valid when roundtrip=true). | any |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Status code (e.g., "Ok" for success, error code otherwise) | |
| trips | Yes | Array containing the optimized trip (typically 1 trip for all waypoints) | |
| message | No | Error message if code is not "Ok" | |
| waypoints | Yes | Input coordinates snapped to the road network in optimized order | |
| mapboxRender | No | Map-payload reference for `render_map_tool`. Surfaced so the LLM can chain the next call without re-emitting geometry. |