@mapbox/mcp-server 0.13.0-dev → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -14
- package/dist/commonjs/cli.d.ts.map +1 -1
- package/dist/commonjs/cli.js +5 -2
- package/dist/commonjs/cli.js.map +1 -1
- package/dist/commonjs/resources/resourceRegistry.d.ts +1 -2
- package/dist/commonjs/resources/resourceRegistry.d.ts.map +1 -1
- package/dist/commonjs/resources/resourceRegistry.js +0 -2
- package/dist/commonjs/resources/resourceRegistry.js.map +1 -1
- package/dist/commonjs/resources/ui-apps/mapAppHtml.d.ts +3 -3
- package/dist/commonjs/resources/ui-apps/mapAppHtml.d.ts.map +1 -1
- package/dist/commonjs/resources/ui-apps/mapAppHtml.js +18 -4
- package/dist/commonjs/resources/ui-apps/mapAppHtml.js.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.d.ts +16 -0
- package/dist/commonjs/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.js +105 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.js.map +1 -1
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.d.ts.map +1 -1
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.input.schema.js +1 -1
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.input.schema.js.map +1 -1
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.js +7 -3
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.js.map +1 -1
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.d.ts.map +1 -1
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.js +2 -0
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.js.map +1 -1
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.input.schema.d.ts +3 -3
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.input.schema.d.ts.map +1 -1
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.input.schema.js +16 -2
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.input.schema.js.map +1 -1
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.js +15 -4
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
- package/dist/commonjs/utils/index.d.ts +2 -0
- package/dist/commonjs/utils/index.d.ts.map +1 -1
- package/dist/commonjs/utils/index.js +8 -1
- package/dist/commonjs/utils/index.js.map +1 -1
- package/dist/commonjs/utils/redactToken.d.ts +3 -0
- package/dist/commonjs/utils/redactToken.d.ts.map +1 -0
- package/dist/commonjs/utils/redactToken.js +55 -0
- package/dist/commonjs/utils/redactToken.js.map +1 -0
- package/dist/commonjs/utils/redactingSpanExporter.d.ts +24 -0
- package/dist/commonjs/utils/redactingSpanExporter.d.ts.map +1 -0
- package/dist/commonjs/utils/redactingSpanExporter.js +97 -0
- package/dist/commonjs/utils/redactingSpanExporter.js.map +1 -0
- package/dist/commonjs/utils/tracing.d.ts.map +1 -1
- package/dist/commonjs/utils/tracing.js +4 -1
- package/dist/commonjs/utils/tracing.js.map +1 -1
- package/dist/commonjs/utils/urlSafety.d.ts +23 -7
- package/dist/commonjs/utils/urlSafety.d.ts.map +1 -1
- package/dist/commonjs/utils/urlSafety.js +84 -66
- package/dist/commonjs/utils/urlSafety.js.map +1 -1
- package/dist/commonjs/version.json +3 -3
- package/dist/esm/cli.d.ts.map +1 -1
- package/dist/esm/cli.js +5 -2
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/resources/resourceRegistry.d.ts +1 -2
- package/dist/esm/resources/resourceRegistry.d.ts.map +1 -1
- package/dist/esm/resources/resourceRegistry.js +0 -2
- package/dist/esm/resources/resourceRegistry.js.map +1 -1
- package/dist/esm/resources/ui-apps/mapAppHtml.d.ts +3 -3
- package/dist/esm/resources/ui-apps/mapAppHtml.d.ts.map +1 -1
- package/dist/esm/resources/ui-apps/mapAppHtml.js +18 -4
- package/dist/esm/resources/ui-apps/mapAppHtml.js.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.d.ts +16 -0
- package/dist/esm/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.js +105 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.js.map +1 -1
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.d.ts.map +1 -1
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.input.schema.js +1 -1
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.input.schema.js.map +1 -1
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.js +7 -3
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.js.map +1 -1
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.d.ts.map +1 -1
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.js +2 -0
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.js.map +1 -1
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.input.schema.d.ts +3 -3
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.input.schema.d.ts.map +1 -1
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.input.schema.js +17 -3
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.input.schema.js.map +1 -1
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.js +15 -4
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
- package/dist/esm/utils/index.d.ts +2 -0
- package/dist/esm/utils/index.d.ts.map +1 -1
- package/dist/esm/utils/index.js +5 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/redactToken.d.ts +3 -0
- package/dist/esm/utils/redactToken.d.ts.map +1 -0
- package/dist/esm/utils/redactToken.js +52 -0
- package/dist/esm/utils/redactToken.js.map +1 -0
- package/dist/esm/utils/redactingSpanExporter.d.ts +24 -0
- package/dist/esm/utils/redactingSpanExporter.d.ts.map +1 -0
- package/dist/esm/utils/redactingSpanExporter.js +93 -0
- package/dist/esm/utils/redactingSpanExporter.js.map +1 -0
- package/dist/esm/utils/tracing.d.ts.map +1 -1
- package/dist/esm/utils/tracing.js +4 -1
- package/dist/esm/utils/tracing.js.map +1 -1
- package/dist/esm/utils/urlSafety.d.ts +23 -7
- package/dist/esm/utils/urlSafety.d.ts.map +1 -1
- package/dist/esm/utils/urlSafety.js +80 -66
- package/dist/esm/utils/urlSafety.js.map +1 -1
- package/dist/esm/version.json +3 -3
- package/package.json +2 -1
- package/dist/commonjs/resources/ui-apps/StaticMapUIResource.d.ts +0 -15
- package/dist/commonjs/resources/ui-apps/StaticMapUIResource.d.ts.map +0 -1
- package/dist/commonjs/resources/ui-apps/StaticMapUIResource.js +0 -262
- package/dist/commonjs/resources/ui-apps/StaticMapUIResource.js.map +0 -1
- package/dist/esm/resources/ui-apps/StaticMapUIResource.d.ts +0 -15
- package/dist/esm/resources/ui-apps/StaticMapUIResource.d.ts.map +0 -1
- package/dist/esm/resources/ui-apps/StaticMapUIResource.js +0 -258
- package/dist/esm/resources/ui-apps/StaticMapUIResource.js.map +0 -1
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ The Mapbox MCP Server transforms any AI agent or application into a geospatially
|
|
|
15
15
|
- **Route optimization** to find the optimal visiting order for multiple stops (traveling salesman problem)
|
|
16
16
|
- **Map matching** to snap GPS traces to the road network for clean route visualization
|
|
17
17
|
- **Isochrone generation** to visualize areas reachable within specific time or distance constraints
|
|
18
|
+
- **Live, interactive map rendering** (`render_map_tool`) to display routes, search results, and your own custom GeoJSON on a real Mapbox GL JS map directly inside the chat
|
|
18
19
|
- **Static map images** to create visual representations of locations, routes, and geographic data
|
|
19
20
|
- **Offline geospatial calculations** for distance, area, bearing, buffers, and spatial analysis without requiring API calls
|
|
20
21
|
|
|
@@ -52,6 +53,8 @@ For detailed setup instructions for different integrations, refer to the followi
|
|
|
52
53
|
- [Cursor AI IDE Setup](./docs/cursor-setup.md) - Setting up a development environment in Cursor AI IDE
|
|
53
54
|
- [Smolagents Integration](./docs/using-mcp-with-smolagents/README.md) - Example showing how to connect Smolagents AI agents to Mapbox's tools
|
|
54
55
|
- **[Importing Tools Directly](./docs/importing-tools.md)** - Use Mapbox tools in your own applications without running the MCP server
|
|
56
|
+
- **[`render_map_tool` Guide](./docs/render-map-tool.md)** - The map visualization primitive: full payload schema and how to render your own data standalone, without any other Mapbox tool
|
|
57
|
+
- **[Elicitations](./docs/elicitations.md)** - How `search_and_geocode_tool` and `directions_tool` ask the user to disambiguate results or pick a route, and how they fall back gracefully when the client doesn't support it
|
|
55
58
|
|
|
56
59
|
## Example Prompts
|
|
57
60
|
|
|
@@ -72,9 +75,11 @@ Try these prompts with Claude Desktop or other MCP clients after setup:
|
|
|
72
75
|
|
|
73
76
|
### Visualization & Maps
|
|
74
77
|
|
|
78
|
+
- "Using the Mapbox map render tool, show me directions from the Golden Gate Bridge to Union Square in San Francisco" — renders a live, interactive route on a real Mapbox map
|
|
75
79
|
- "Create a map image showing the route from Golden Gate Bridge to Fisherman's Wharf with markers at both locations"
|
|
76
80
|
- "Show me a satellite view of Manhattan with key landmarks marked"
|
|
77
81
|
- "Generate a map highlighting all Starbucks locations within a mile of downtown Seattle"
|
|
82
|
+
- "Show a fill polygon over these coordinates: [...], with a marker labeled 'Warehouse' at [...]" — renders your own GeoJSON directly via `render_map_tool`, no other Mapbox tool needed
|
|
78
83
|
|
|
79
84
|
### Analysis & Planning
|
|
80
85
|
|
|
@@ -133,24 +138,18 @@ Access the complete list of available category IDs for use with the category sea
|
|
|
133
138
|
- **Clients with native MCP resource support**: Use the `resources/read` MCP protocol method
|
|
134
139
|
- **Clients without resource support**: Use the `resource_reader_tool` with the resource URI
|
|
135
140
|
|
|
136
|
-
## Rich Map Previews (
|
|
141
|
+
## Rich Map Previews (`render_map_tool`)
|
|
137
142
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
This server implements the **MCP Apps** protocol (`@modelcontextprotocol/ext-apps`), which renders a self-contained HTML app panel directly inside the chat. Supported clients show an interactive map with a Fullscreen toggle:
|
|
143
|
+
Every geospatial tool in this server (directions, isochrone, search, and more) can display its result as a live, interactive Mapbox GL JS map via **`render_map_tool`** — the server's single visualization primitive. It renders through the **MCP Apps** protocol (`@modelcontextprotocol/ext-apps`) as a self-contained HTML panel directly inside the chat, with a Fullscreen toggle, in supported clients:
|
|
141
144
|
|
|
142
145
|
- **Claude Desktop** ✅
|
|
143
146
|
- **VS Code with GitHub Copilot** ✅
|
|
144
147
|
- **Claude Code** ✅
|
|
145
148
|
- **[Goose](https://github.com/block/goose)** ✅
|
|
146
149
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
### Legacy: MCP-UI
|
|
150
|
+
**You don't need any of this server's other tools to use it.** `render_map_tool` also accepts hand-composed GeoJSON directly — your own polygons, markers, and routes — with no dependency on `directions_tool`, `isochrone_tool`, or any other Mapbox API call. See **[the full `render_map_tool` guide](./docs/render-map-tool.md)** for the payload schema and a complete standalone example.
|
|
150
151
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
MCP-UI is enabled by default. To disable it, pass `--disable-mcp-ui` as a command-line flag or set `ENABLE_MCP_UI=false`. See the [MCP-UI documentation](./docs/mcp-ui.md) for details.
|
|
152
|
+
If you need a guaranteed static image in clients without MCP Apps support, use `static_map_image_tool` instead — it returns a base64-encoded PNG/JPEG that every client can display.
|
|
154
153
|
|
|
155
154
|
#### CLIENT_NEEDS_RESOURCE_FALLBACK
|
|
156
155
|
|
|
@@ -210,17 +209,30 @@ Calculate the distance between two geographic coordinates using the Haversine fo
|
|
|
210
209
|
|
|
211
210
|
**Example Usage**: "What's the distance between San Francisco (37.7749°N, 122.4194°W) and New York (40.7128°N, 74.0060°W)?"
|
|
212
211
|
|
|
213
|
-
####
|
|
212
|
+
#### Points Within Polygon Tool
|
|
214
213
|
|
|
215
|
-
Test
|
|
214
|
+
Test one or more points against a polygon or multipolygon, returning only those inside. Handles a single point or a batch in one call.
|
|
216
215
|
|
|
217
216
|
**Features**:
|
|
218
217
|
|
|
219
218
|
- Works with complex polygons including holes
|
|
220
219
|
- Supports multipolygons
|
|
221
|
-
-
|
|
220
|
+
- Batch-tests any number of points in one call
|
|
221
|
+
- Useful for geofencing, delivery zone validation, and customer segmentation
|
|
222
|
+
|
|
223
|
+
**Example Usage**: "Which of these delivery addresses are inside our service area?"
|
|
222
224
|
|
|
223
|
-
|
|
225
|
+
#### Destination Tool
|
|
226
|
+
|
|
227
|
+
Calculate a destination point given a starting point, bearing, and distance using geodesic (great-circle) offset.
|
|
228
|
+
|
|
229
|
+
**Features**:
|
|
230
|
+
|
|
231
|
+
- Straight-line offset, not a routed path
|
|
232
|
+
- Useful for "find a point 5km north of X" or constructing search offsets
|
|
233
|
+
- No API calls required
|
|
234
|
+
|
|
235
|
+
**Example Usage**: "What's the point 10km northeast of the Space Needle?"
|
|
224
236
|
|
|
225
237
|
#### Bearing Tool
|
|
226
238
|
|
|
@@ -307,6 +319,61 @@ Reduce the number of vertices in a line or polygon using the Douglas-Peucker alg
|
|
|
307
319
|
|
|
308
320
|
**Example Usage**: "Simplify this complex boundary to reduce the number of points"
|
|
309
321
|
|
|
322
|
+
#### Length Tool
|
|
323
|
+
|
|
324
|
+
Measure the total length of a line defined by a series of coordinates.
|
|
325
|
+
|
|
326
|
+
**Features**:
|
|
327
|
+
|
|
328
|
+
- Supports kilometers, miles, meters, and feet
|
|
329
|
+
- Useful for measuring a drawn route, path, or boundary without a routing API call
|
|
330
|
+
|
|
331
|
+
**Example Usage**: "How long is this hiking trail?"
|
|
332
|
+
|
|
333
|
+
#### Convex Tool
|
|
334
|
+
|
|
335
|
+
Compute the convex hull of a set of points — the smallest convex polygon containing all of them.
|
|
336
|
+
|
|
337
|
+
**Features**:
|
|
338
|
+
|
|
339
|
+
- Useful for bounding-area analysis or estimating coverage area
|
|
340
|
+
- Works offline without API calls
|
|
341
|
+
|
|
342
|
+
**Example Usage**: "What's the smallest polygon that contains all of these store locations?"
|
|
343
|
+
|
|
344
|
+
#### Nearest Point Tool
|
|
345
|
+
|
|
346
|
+
Find the nearest point in a collection to a given target point.
|
|
347
|
+
|
|
348
|
+
**Features**:
|
|
349
|
+
|
|
350
|
+
- More efficient than calling `distance_tool` for each candidate and sorting
|
|
351
|
+
- Useful for finding the closest store, stop, or landmark to a location
|
|
352
|
+
|
|
353
|
+
**Example Usage**: "Which of these stores is closest to my current location?"
|
|
354
|
+
|
|
355
|
+
#### Nearest Point on Line Tool
|
|
356
|
+
|
|
357
|
+
Snap a point to the nearest position on a line or route, returning that point and the distance to it.
|
|
358
|
+
|
|
359
|
+
**Features**:
|
|
360
|
+
|
|
361
|
+
- Useful for "which point on this route is closest to my location?" or map-matching without an API call
|
|
362
|
+
|
|
363
|
+
**Example Usage**: "Where on this hiking trail am I closest to right now?"
|
|
364
|
+
|
|
365
|
+
#### Union, Intersect, and Difference Tools
|
|
366
|
+
|
|
367
|
+
Combine or compare two or more polygons — `union_tool` merges them into one geometry, `intersect_tool` finds the area they share, and `difference_tool` subtracts one from another.
|
|
368
|
+
|
|
369
|
+
**Features**:
|
|
370
|
+
|
|
371
|
+
- Useful for combining service areas, finding coverage overlap, or computing exclusion zones (e.g. "what's covered by zone A but not zone B?")
|
|
372
|
+
- Works entirely offline — no API calls required
|
|
373
|
+
- Each returns a `render_map_tool` reference so the result can be visualized directly
|
|
374
|
+
|
|
375
|
+
**Example Usage**: "Combine these two delivery zones into one coverage area" / "Where do these two isochrones overlap?" / "What part of this service area isn't covered by our 15-minute isochrone?"
|
|
376
|
+
|
|
310
377
|
### Mapbox API Tools
|
|
311
378
|
|
|
312
379
|
#### Category List Tool (Deprecated)
|
|
@@ -355,6 +422,25 @@ Performs reverse geocoding using the [Mapbox geocoding V6 API](https://docs.mapb
|
|
|
355
422
|
- Support for multiple languages
|
|
356
423
|
- Rich location context information
|
|
357
424
|
|
|
425
|
+
#### Ground location tool
|
|
426
|
+
|
|
427
|
+
Answers "what's near this coordinate" questions in a single call — place name, nearby points of interest, and travel-time reachability — sourced from live Mapbox data with citations. Use this instead of chaining `reverse_geocode_tool` with a web search.
|
|
428
|
+
|
|
429
|
+
**Features**:
|
|
430
|
+
|
|
431
|
+
- Classifies the query (routing, neighborhood context, POI search, or region/reachability) and fetches only the relevant data
|
|
432
|
+
- Nearby POI search by category, when requested
|
|
433
|
+
- Travel-time reachability summary (isochrone-based)
|
|
434
|
+
- Returns a `render_map_tool` reference with the grounded location and nearby POIs plotted
|
|
435
|
+
|
|
436
|
+
**Example Usage**: "What neighborhood is this coordinate in, and are there any coffee shops nearby?"
|
|
437
|
+
|
|
438
|
+
#### Place details tool
|
|
439
|
+
|
|
440
|
+
Retrieves detailed information about a specific place using its Mapbox ID — photos, opening hours, ratings, phone numbers, and website URLs. Use after `search_and_geocode_tool`, `category_search_tool`, or `reverse_geocode_tool` to get more detail on a specific result.
|
|
441
|
+
|
|
442
|
+
**Example Usage**: "Tell me more about that first coffee shop result — hours, phone number, and website"
|
|
443
|
+
|
|
358
444
|
#### Directions tool
|
|
359
445
|
|
|
360
446
|
Fetches routing directions using the [Mapbox Directions API](https://docs.mapbox.com/api/navigation/directions/). Features include:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAGA,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,iBAAiB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAGA,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,iBAAiB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAoCD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EAAE,EACd,WAAW,EAAE,cAAc,GAC1B,iBAAiB,CAsCnB"}
|
package/dist/commonjs/cli.js
CHANGED
|
@@ -7,10 +7,13 @@ const OPTIONS = [
|
|
|
7
7
|
'--help, -h Show this help message',
|
|
8
8
|
'--version, -v Show the server version',
|
|
9
9
|
'--enable-tools Enable only the comma-separated tools',
|
|
10
|
-
'--disable-tools Disable the comma-separated tools'
|
|
11
|
-
'--disable-mcp-ui Disable MCP-UI resources'
|
|
10
|
+
'--disable-tools Disable the comma-separated tools'
|
|
12
11
|
];
|
|
13
12
|
const OPTIONS_WITH_VALUES = new Set(['--enable-tools', '--disable-tools']);
|
|
13
|
+
// --disable-mcp-ui is no longer a real option (MCP-UI support was removed
|
|
14
|
+
// entirely — see docs/mcp-ui.md) but stays recognized-and-ignored here, not
|
|
15
|
+
// in OPTIONS, so an existing launch config that still passes it keeps
|
|
16
|
+
// starting instead of hard-failing on "Unknown option".
|
|
14
17
|
const KNOWN_FLAGS = new Set([
|
|
15
18
|
'--help',
|
|
16
19
|
'-h',
|
package/dist/commonjs/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../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AE,GAAG,WAAW,CAAC,OAAO,IAAI;SACnC,CAAC;IACJ,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEpB,IAAI,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,CAAC,EAAE,CAAC;YACJ,SAAS;QACX,CAAC;QAED,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACjD,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,CAAC;gBACX,KAAK,EAAE,mBAAmB,GAAG,IAAI;aAClC,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,CAAC;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -2,10 +2,9 @@ import { CategoryListResource } from './category-list/CategoryListResource.js';
|
|
|
2
2
|
import { TemporaryDataResource } from './temporary/TemporaryDataResource.js';
|
|
3
3
|
import { ComputeResource } from './compute/ComputeResource.js';
|
|
4
4
|
import { InlinePayloadResource } from './inline-payload/InlinePayloadResource.js';
|
|
5
|
-
import { StaticMapUIResource } from './ui-apps/StaticMapUIResource.js';
|
|
6
5
|
import { MapAppUIResource } from './ui-apps/MapAppUIResource.js';
|
|
7
6
|
import { VersionResource } from './version/VersionResource.js';
|
|
8
|
-
export declare const ALL_RESOURCES: readonly [CategoryListResource, TemporaryDataResource, ComputeResource, InlinePayloadResource,
|
|
7
|
+
export declare const ALL_RESOURCES: readonly [CategoryListResource, TemporaryDataResource, ComputeResource, InlinePayloadResource, MapAppUIResource, VersionResource];
|
|
9
8
|
export type ResourceInstance = (typeof ALL_RESOURCES)[number];
|
|
10
9
|
export declare function getAllResources(): readonly ResourceInstance[];
|
|
11
10
|
export declare function getResourceByUri(uri: string): ResourceInstance | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceRegistry.d.ts","sourceRoot":"","sources":["../../../src/resources/resourceRegistry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"resourceRegistry.d.ts","sourceRoot":"","sources":["../../../src/resources/resourceRegistry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAI/D,eAAO,MAAM,aAAa,mIAShB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D,wBAAgB,eAAe,IAAI,SAAS,gBAAgB,EAAE,CAE7D;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAkB1E"}
|
|
@@ -10,7 +10,6 @@ const CategoryListResource_js_1 = require("./category-list/CategoryListResource.
|
|
|
10
10
|
const TemporaryDataResource_js_1 = require("./temporary/TemporaryDataResource.js");
|
|
11
11
|
const ComputeResource_js_1 = require("./compute/ComputeResource.js");
|
|
12
12
|
const InlinePayloadResource_js_1 = require("./inline-payload/InlinePayloadResource.js");
|
|
13
|
-
const StaticMapUIResource_js_1 = require("./ui-apps/StaticMapUIResource.js");
|
|
14
13
|
const MapAppUIResource_js_1 = require("./ui-apps/MapAppUIResource.js");
|
|
15
14
|
const VersionResource_js_1 = require("./version/VersionResource.js");
|
|
16
15
|
const httpPipeline_js_1 = require("../utils/httpPipeline.js");
|
|
@@ -21,7 +20,6 @@ exports.ALL_RESOURCES = [
|
|
|
21
20
|
new TemporaryDataResource_js_1.TemporaryDataResource(),
|
|
22
21
|
new ComputeResource_js_1.ComputeResource(),
|
|
23
22
|
new InlinePayloadResource_js_1.InlinePayloadResource(),
|
|
24
|
-
new StaticMapUIResource_js_1.StaticMapUIResource(),
|
|
25
23
|
// Single shared map renderer, targeted exclusively by render_map_tool.
|
|
26
24
|
new MapAppUIResource_js_1.MapAppUIResource({ httpRequest: httpPipeline_js_1.httpRequest }),
|
|
27
25
|
new VersionResource_js_1.VersionResource()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceRegistry.js","sourceRoot":"","sources":["../../../src/resources/resourceRegistry.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;
|
|
1
|
+
{"version":3,"file":"resourceRegistry.js","sourceRoot":"","sources":["../../../src/resources/resourceRegistry.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAyBlC,0CAEC;AAED,4CAkBC;AA7CD,kCAAkC;AAClC,qFAA+E;AAC/E,mFAA6E;AAC7E,qEAA+D;AAC/D,wFAAkF;AAClF,uEAAiE;AACjE,qEAA+D;AAC/D,8DAAuD;AAEvD,oCAAoC;AACvB,QAAA,aAAa,GAAG;IAC3B,oCAAoC;IACpC,IAAI,8CAAoB,CAAC,EAAE,WAAW,EAAX,6BAAW,EAAE,CAAC;IACzC,IAAI,gDAAqB,EAAE;IAC3B,IAAI,oCAAe,EAAE;IACrB,IAAI,gDAAqB,EAAE;IAC3B,uEAAuE;IACvE,IAAI,sCAAgB,CAAC,EAAE,WAAW,EAAX,6BAAW,EAAE,CAAC;IACrC,IAAI,oCAAe,EAAE;CACb,CAAC;AAIX,SAAgB,eAAe;IAC7B,OAAO,qBAAa,CAAC;AACvB,CAAC;AAED,SAAgB,gBAAgB,CAAC,GAAW;IAC1C,yBAAyB;IACzB,MAAM,UAAU,GAAG,qBAAa,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;IAC1E,IAAI,UAAU;QAAE,OAAO,UAAU,CAAC;IAElC,gFAAgF;IAChF,6EAA6E;IAC7E,wEAAwE;IACxE,0EAA0E;IAC1E,iEAAiE;IACjE,OAAO,qBAAa,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QACrC,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAChD,MAAM,UAAU,GACd,aAAa,KAAK,CAAC,CAAC;YAClB,CAAC,CAAC,QAAQ,CAAC,GAAG;YACd,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;QAC3C,OAAO,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { MapAppPayload } from '../../utils/mapAppPayload.js';
|
|
2
2
|
/**
|
|
3
|
-
* Render the generic Mapbox MCP App HTML —
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Render the generic Mapbox MCP App HTML — served by the MCP Apps resource
|
|
4
|
+
* (`MapAppUIResource`) that `render_map_tool` targets exclusively via
|
|
5
|
+
* postMessage delivery.
|
|
6
6
|
*
|
|
7
7
|
* The iframe is a thin renderer over Mapbox GL JS. Tools produce a
|
|
8
8
|
* `MapAppPayload` (see src/utils/mapAppPayload.ts) and the iframe
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapAppHtml.d.ts","sourceRoot":"","sources":["../../../../src/resources/ui-apps/mapAppHtml.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE;;;;;;;;;GASG;AAMH,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,aAAa,CAAC;CAC7B,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"mapAppHtml.d.ts","sourceRoot":"","sources":["../../../../src/resources/ui-apps/mapAppHtml.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE;;;;;;;;;GASG;AAMH,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,aAAa,CAAC;CAC7B,GAAG,MAAM,CA6kDT"}
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
exports.MAPBOX_GL_VERSION = void 0;
|
|
6
6
|
exports.renderMapAppHtml = renderMapAppHtml;
|
|
7
7
|
/**
|
|
8
|
-
* Render the generic Mapbox MCP App HTML —
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Render the generic Mapbox MCP App HTML — served by the MCP Apps resource
|
|
9
|
+
* (`MapAppUIResource`) that `render_map_tool` targets exclusively via
|
|
10
|
+
* postMessage delivery.
|
|
11
11
|
*
|
|
12
12
|
* The iframe is a thin renderer over Mapbox GL JS. Tools produce a
|
|
13
13
|
* `MapAppPayload` (see src/utils/mapAppPayload.ts) and the iframe
|
|
@@ -626,6 +626,11 @@ ${initialDataScript}
|
|
|
626
626
|
if (typeof params.exclude !== 'string') return false;
|
|
627
627
|
if (!/^[A-Za-z0-9_,.() -]+$/.test(params.exclude)) return false;
|
|
628
628
|
}
|
|
629
|
+
if (params.selectedRouteIndex !== undefined && params.selectedRouteIndex !== null) {
|
|
630
|
+
if (typeof params.selectedRouteIndex !== 'number') return false;
|
|
631
|
+
if (!isFinite(params.selectedRouteIndex) || params.selectedRouteIndex < 0) return false;
|
|
632
|
+
if (Math.floor(params.selectedRouteIndex) !== params.selectedRouteIndex) return false;
|
|
633
|
+
}
|
|
629
634
|
return true;
|
|
630
635
|
}
|
|
631
636
|
|
|
@@ -747,7 +752,16 @@ ${initialDataScript}
|
|
|
747
752
|
return res.json();
|
|
748
753
|
})
|
|
749
754
|
.then(function(data) {
|
|
750
|
-
var
|
|
755
|
+
var routes = (data && data.routes) || [];
|
|
756
|
+
// If elicitation resolved to a specific route server-side, draw that
|
|
757
|
+
// same one out of the freshly re-fetched alternatives — falling back
|
|
758
|
+
// to the first route if the index is out of range (e.g. the API
|
|
759
|
+
// returned fewer alternatives this time around), same fallback
|
|
760
|
+
// philosophy as selectedMapboxId in the search self-fetch.
|
|
761
|
+
var route =
|
|
762
|
+
(typeof params.selectedRouteIndex === 'number' &&
|
|
763
|
+
routes[params.selectedRouteIndex]) ||
|
|
764
|
+
routes[0];
|
|
751
765
|
var coords = route ? pickRouteGeometryClient(route) : null;
|
|
752
766
|
if (!coords) {
|
|
753
767
|
showError('Directions API returned no route.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapAppHtml.js","sourceRoot":"","sources":["../../../../src/resources/ui-apps/mapAppHtml.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,k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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAmgD1C,CAAC;AACT,CAAC;AAED,SAAS,eAAe,CAAC,CAAS;IAChC,OAAO,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -17,6 +17,22 @@ export declare class DirectionsTool extends MapboxApiBasedTool<typeof Directions
|
|
|
17
17
|
constructor(params: {
|
|
18
18
|
httpRequest: HttpRequest;
|
|
19
19
|
});
|
|
20
|
+
private formatDuration;
|
|
21
|
+
private formatDistance;
|
|
22
|
+
/** One-line label for a route option in the Stage 2 elicitation form. */
|
|
23
|
+
private describeRoute;
|
|
24
|
+
/**
|
|
25
|
+
* When multiple route alternatives come back, let the user pick one via
|
|
26
|
+
* MCP elicitation rather than handing all of them to the model. Returns
|
|
27
|
+
* the selected route's index (to thread through the self-fetch ref so the
|
|
28
|
+
* map preview draws the same route) and mutates nothing — the caller
|
|
29
|
+
* applies the filtered `routes` array itself.
|
|
30
|
+
*
|
|
31
|
+
* Mirrors search_and_geocode_tool's disambiguation elicitation: silent,
|
|
32
|
+
* best-effort fallback to "return everything" on decline, on an
|
|
33
|
+
* unsupported client, or on any elicitation error.
|
|
34
|
+
*/
|
|
35
|
+
private elicitRouteSelection;
|
|
20
36
|
protected execute(input: z.infer<typeof DirectionsInputSchema>, accessToken: string): Promise<CallToolResult>;
|
|
21
37
|
}
|
|
22
38
|
//# sourceMappingURL=DirectionsTool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectionsTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/directions-tool/DirectionsTool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EACL,wBAAwB,
|
|
1
|
+
{"version":3,"file":"DirectionsTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/directions-tool/DirectionsTool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EACL,wBAAwB,EAGzB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAQzD,qBAAa,cAAe,SAAQ,kBAAkB,CACpD,OAAO,qBAAqB,EAC5B,OAAO,wBAAwB,CAChC;IACC,IAAI,SAAqB;IACzB,WAAW,SAMkE;IAC7E,WAAW;;;;;;MAMT;gBACU,MAAM,EAAE;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE;IAQhD,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,cAAc;IAMtB,yEAAyE;IACzE,OAAO,CAAC,aAAa;IA6BrB;;;;;;;;;;OAUG;YACW,oBAAoB;cA6ClB,OAAO,CACrB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,EAC5C,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,cAAc,CAAC;CAkS3B"}
|
|
@@ -36,6 +36,91 @@ class DirectionsTool extends MapboxApiBasedTool_js_1.MapboxApiBasedTool {
|
|
|
36
36
|
httpRequest: params.httpRequest
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
+
formatDuration(seconds) {
|
|
40
|
+
const hours = Math.floor(seconds / 3600);
|
|
41
|
+
const minutes = Math.round((seconds % 3600) / 60);
|
|
42
|
+
return hours > 0 ? `${hours}h ${minutes}min` : `${minutes}min`;
|
|
43
|
+
}
|
|
44
|
+
formatDistance(meters) {
|
|
45
|
+
const km = (meters / 1000).toFixed(1);
|
|
46
|
+
const miles = (meters / 1609.34).toFixed(1);
|
|
47
|
+
return `${km}km (${miles}mi)`;
|
|
48
|
+
}
|
|
49
|
+
/** One-line label for a route option in the Stage 2 elicitation form. */
|
|
50
|
+
describeRoute(route) {
|
|
51
|
+
const duration = this.formatDuration(route.duration);
|
|
52
|
+
const distance = this.formatDistance(route.distance);
|
|
53
|
+
const roads = route.leg_summaries?.[0] || 'Route';
|
|
54
|
+
let traffic = '';
|
|
55
|
+
const c = route.congestion_information;
|
|
56
|
+
if (c) {
|
|
57
|
+
const total = c.length_low + c.length_moderate + c.length_heavy + c.length_severe;
|
|
58
|
+
const heavyPct = total > 0
|
|
59
|
+
? Math.round(((c.length_heavy + c.length_severe) / total) * 100)
|
|
60
|
+
: 0;
|
|
61
|
+
traffic =
|
|
62
|
+
heavyPct > 20
|
|
63
|
+
? ` ⚠️ Heavy traffic (${heavyPct}%)`
|
|
64
|
+
: c.length_moderate > 0
|
|
65
|
+
? ' 🟡 Moderate traffic'
|
|
66
|
+
: ' ✅ Light traffic';
|
|
67
|
+
}
|
|
68
|
+
const incidentCount = route.incidents_summary?.length ?? 0;
|
|
69
|
+
const incidents = incidentCount > 0 ? ` • ${incidentCount} incident(s)` : '';
|
|
70
|
+
return `${duration} via ${roads} • ${distance}${traffic}${incidents}`;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* When multiple route alternatives come back, let the user pick one via
|
|
74
|
+
* MCP elicitation rather than handing all of them to the model. Returns
|
|
75
|
+
* the selected route's index (to thread through the self-fetch ref so the
|
|
76
|
+
* map preview draws the same route) and mutates nothing — the caller
|
|
77
|
+
* applies the filtered `routes` array itself.
|
|
78
|
+
*
|
|
79
|
+
* Mirrors search_and_geocode_tool's disambiguation elicitation: silent,
|
|
80
|
+
* best-effort fallback to "return everything" on decline, on an
|
|
81
|
+
* unsupported client, or on any elicitation error.
|
|
82
|
+
*/
|
|
83
|
+
async elicitRouteSelection(routes) {
|
|
84
|
+
if (!this.server || routes.length < 2)
|
|
85
|
+
return undefined;
|
|
86
|
+
try {
|
|
87
|
+
const options = routes.map((route, index) => ({
|
|
88
|
+
value: String(index),
|
|
89
|
+
label: this.describeRoute(route)
|
|
90
|
+
}));
|
|
91
|
+
const result = await this.server.server.elicitInput({
|
|
92
|
+
mode: 'form',
|
|
93
|
+
message: `Found ${routes.length} routes. Choose your preferred route:`,
|
|
94
|
+
requestedSchema: {
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: {
|
|
97
|
+
selectedIndex: {
|
|
98
|
+
type: 'string',
|
|
99
|
+
title: 'Select Route',
|
|
100
|
+
description: 'Choose the route that best fits your needs',
|
|
101
|
+
enum: options.map((o) => o.value),
|
|
102
|
+
enumNames: options.map((o) => o.label)
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
required: ['selectedIndex']
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
if (result.action === 'accept' && result.content?.selectedIndex) {
|
|
109
|
+
const index = parseInt(String(result.content.selectedIndex), 10);
|
|
110
|
+
if (Number.isInteger(index) && index >= 0 && index < routes.length) {
|
|
111
|
+
return index;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// Elicitation isn't supported by every MCP client (Claude Desktop
|
|
117
|
+
// doesn't, for example). Falling back to "return all routes" is the
|
|
118
|
+
// expected behavior — silent, since Claude Desktop's UI flags tool
|
|
119
|
+
// calls that emit notifications/message at any level as visually
|
|
120
|
+
// failed even when the JSON-RPC response is isError: false.
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
39
124
|
async execute(input, accessToken) {
|
|
40
125
|
// Validate exclude parameter against the actual routing_profile
|
|
41
126
|
// This is needed because some exclusions are only driving specific
|
|
@@ -180,6 +265,21 @@ class DirectionsTool extends MapboxApiBasedTool_js_1.MapboxApiBasedTool {
|
|
|
180
265
|
this.log('warning', `DirectionsTool: Response validation failed: ${error}`);
|
|
181
266
|
validatedData = cleanedData;
|
|
182
267
|
}
|
|
268
|
+
// When the API returns multiple route alternatives, let the user pick
|
|
269
|
+
// one via elicitation rather than handing every option to the model.
|
|
270
|
+
// selectedRouteIndex (into the *original* routes array) is threaded
|
|
271
|
+
// through the self-fetch ref below so the map preview draws the same
|
|
272
|
+
// route the user picked, not just whichever the API returns first.
|
|
273
|
+
let selectedRouteIndex;
|
|
274
|
+
if (validatedData.routes && validatedData.routes.length >= 2) {
|
|
275
|
+
selectedRouteIndex = await this.elicitRouteSelection(validatedData.routes);
|
|
276
|
+
if (selectedRouteIndex !== undefined) {
|
|
277
|
+
validatedData = {
|
|
278
|
+
...validatedData,
|
|
279
|
+
routes: [validatedData.routes[selectedRouteIndex]]
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}
|
|
183
283
|
// Check response size and conditionally create temporary resource
|
|
184
284
|
const RESPONSE_SIZE_THRESHOLD = 50 * 1024; // 50KB
|
|
185
285
|
const responseText = JSON.stringify(validatedData, null, 2);
|
|
@@ -191,10 +291,14 @@ class DirectionsTool extends MapboxApiBasedTool_js_1.MapboxApiBasedTool {
|
|
|
191
291
|
// (already visible to the LLM), so unlike a mapbox://temp/ ref there's
|
|
192
292
|
// nothing server-side that a restart or a rehydrated conversation could
|
|
193
293
|
// invalidate. Works regardless of input.geometries since the self-fetch
|
|
194
|
-
// always forces geometries=geojson itself.
|
|
294
|
+
// always forces geometries=geojson itself. selectedRouteIndex (when
|
|
295
|
+
// elicitation resolved to one route) tells the client which of the
|
|
296
|
+
// freshly re-fetched alternatives to draw — see selectedMapboxId in
|
|
297
|
+
// search_and_geocode_tool for the equivalent pattern.
|
|
195
298
|
const selfFetchRef = (0, selfFetchRef_js_1.buildSelfFetchRef)('directions', {
|
|
196
299
|
coordinates: input.coordinates,
|
|
197
300
|
routing_profile: input.routing_profile,
|
|
301
|
+
selectedRouteIndex,
|
|
198
302
|
alternatives: input.alternatives,
|
|
199
303
|
exclude: input.exclude,
|
|
200
304
|
depart_at: input.depart_at,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectionsTool.js","sourceRoot":"","sources":["../../../../src/tools/directions-tool/DirectionsTool.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAElC,6CAA0C;AAE1C,oEAA8D;AAE9D,iEAA2D;AAC3D,iFAA2E;AAC3E,qFAAyE;AACzE,
|
|
1
|
+
{"version":3,"file":"DirectionsTool.js","sourceRoot":"","sources":["../../../../src/tools/directions-tool/DirectionsTool.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAElC,6CAA0C;AAE1C,oEAA8D;AAE9D,iEAA2D;AAC3D,iFAA2E;AAC3E,qFAAyE;AACzE,uFAI2C;AAE3C,yFAAmF;AACnF,uEAA4D;AAC5D,iEAAgE;AAChE,yDAA+D;AAE/D,2DAA2D;AAE3D,MAAa,cAAe,SAAQ,0CAGnC;IACC,IAAI,GAAG,iBAAiB,CAAC;IACzB,WAAW,GACT,yFAAyF;QACzF,8FAA8F;QAC9F,yEAAyE;QACzE,uFAAuF;QACvF,wFAAwF;QACxF,0EAA0E,CAAC;IAC7E,WAAW,GAAG;QACZ,KAAK,EAAE,iBAAiB;QACxB,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;KACpB,CAAC;IACF,YAAY,MAAoC;QAC9C,KAAK,CAAC;YACJ,WAAW,EAAE,sD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DetailsTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EACL,wBAAwB,EAEzB,MAAM,qCAAqC,CAAC;AAI7C,qBAAa,gBAAiB,SAAQ,kBAAkB,CACtD,OAAO,uBAAuB,EAC9B,OAAO,wBAAwB,CAChC;IACC,IAAI,SAAwB;IAC5B,WAAW,SACmT;IAC9T,WAAW;;;;;;MAMT;gBAEU,MAAM,EAAE;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE;IAQhD,OAAO,CAAC,eAAe;IA0DvB,OAAO,CAAC,mBAAmB;cAiGX,OAAO,CACrB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,EAC9C,WAAW,EAAE,MAAM,EAEnB,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"PlaceDetailsTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/place-details-tool/PlaceDetailsTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EACL,wBAAwB,EAEzB,MAAM,qCAAqC,CAAC;AAI7C,qBAAa,gBAAiB,SAAQ,kBAAkB,CACtD,OAAO,uBAAuB,EAC9B,OAAO,wBAAwB,CAChC;IACC,IAAI,SAAwB;IAC5B,WAAW,SACmT;IAC9T,WAAW;;;;;;MAMT;gBAEU,MAAM,EAAE;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE;IAQhD,OAAO,CAAC,eAAe;IA0DvB,OAAO,CAAC,mBAAmB;cAiGX,OAAO,CACrB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,EAC9C,WAAW,EAAE,MAAM,EAEnB,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,cAAc,CAAC;CAkD3B"}
|
|
@@ -17,7 +17,7 @@ exports.PlaceDetailsInputSchema = zod_1.default.object({
|
|
|
17
17
|
attribute_sets: zod_1.default
|
|
18
18
|
.array(zod_1.default.enum(['basic', 'photos', 'visit', 'venue']))
|
|
19
19
|
.optional()
|
|
20
|
-
.describe('Which attribute sets to include in the response. Options: "basic" (address/coordinates
|
|
20
|
+
.describe('Which attribute sets to include in the response. Options: "basic" (name/address/coordinates — always requested from the API regardless of whether you list it here, since it\'s required for a valid response), "photos" (place photo URLs), "visit" (opening hours, rating, price level, popularity), "venue" (phone number, website URL, social media links). When not specified, only basic attributes are returned.'),
|
|
21
21
|
language: zod_1.default
|
|
22
22
|
.string()
|
|
23
23
|
.optional()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaceDetailsTool.input.schema.js","sourceRoot":"","sources":["../../../../src/tools/place-details-tool/PlaceDetailsTool.input.schema.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;;;;AAElC,8CAAoB;AAEpB;;GAEG;AACU,QAAA,uBAAuB,GAAG,aAAC,CAAC,MAAM,CAAC;IAC9C,SAAS,EAAE,aAAC;SACT,MAAM,EAAE;SACR,QAAQ,CACP,0MAA0M,CAC3M;IACH,cAAc,EAAE,aAAC;SACd,KAAK,CAAC,aAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;SACpD,QAAQ,EAAE;SACV,QAAQ,CACP,
|
|
1
|
+
{"version":3,"file":"PlaceDetailsTool.input.schema.js","sourceRoot":"","sources":["../../../../src/tools/place-details-tool/PlaceDetailsTool.input.schema.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;;;;AAElC,8CAAoB;AAEpB;;GAEG;AACU,QAAA,uBAAuB,GAAG,aAAC,CAAC,MAAM,CAAC;IAC9C,SAAS,EAAE,aAAC;SACT,MAAM,EAAE;SACR,QAAQ,CACP,0MAA0M,CAC3M;IACH,cAAc,EAAE,aAAC;SACd,KAAK,CAAC,aAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;SACpD,QAAQ,EAAE;SACV,QAAQ,CACP,yZAAyZ,CAC1Z;IACH,QAAQ,EAAE,aAAC;SACR,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,sHAAsH,CACvH;IACH,SAAS,EAAE,aAAC;SACT,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;SACtD,QAAQ,EAAE;SACV,QAAQ,CACP,4NAA4N,CAC7N;CACJ,CAAC,CAAC"}
|
|
@@ -158,9 +158,13 @@ class PlaceDetailsTool extends MapboxApiBasedTool_js_1.MapboxApiBasedTool {
|
|
|
158
158
|
_context) {
|
|
159
159
|
const url = new URL(`${MapboxApiBasedTool_js_1.MapboxApiBasedTool.mapboxApiEndpoint}search/details/v1/retrieve/${encodeURIComponent(input.mapbox_id)}`);
|
|
160
160
|
url.searchParams.append('access_token', accessToken);
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
// "basic" (name, feature_type, address, coordinates) is what the
|
|
162
|
+
// Details API calls its default attribute set, and this tool's output
|
|
163
|
+
// schema requires `properties.name`/`properties.feature_type` — so it
|
|
164
|
+
// must always be requested, even if the caller's attribute_sets omits
|
|
165
|
+
// it, or the API response fails output validation.
|
|
166
|
+
const attributeSets = new Set(['basic', ...(input.attribute_sets ?? [])]);
|
|
167
|
+
url.searchParams.append('attribute_sets', Array.from(attributeSets).join(','));
|
|
164
168
|
if (input.language) {
|
|
165
169
|
url.searchParams.append('language', input.language);
|
|
166
170
|
}
|