@mapbox/mcp-server 0.12.6 → 0.12.7
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/dist/commonjs/resources/ui-apps/DirectionsAppUIResource.d.ts +3 -2
- package/dist/commonjs/resources/ui-apps/DirectionsAppUIResource.d.ts.map +1 -1
- package/dist/commonjs/resources/ui-apps/DirectionsAppUIResource.js +5 -3
- package/dist/commonjs/resources/ui-apps/DirectionsAppUIResource.js.map +1 -1
- package/dist/commonjs/resources/ui-apps/directionsAppHtml.d.ts +20 -8
- package/dist/commonjs/resources/ui-apps/directionsAppHtml.d.ts.map +1 -1
- package/dist/commonjs/resources/ui-apps/directionsAppHtml.js +198 -18
- package/dist/commonjs/resources/ui-apps/directionsAppHtml.js.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.input.schema.d.ts.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.input.schema.js +6 -2
- package/dist/commonjs/tools/directions-tool/DirectionsTool.input.schema.js.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.js +52 -109
- package/dist/commonjs/tools/directions-tool/DirectionsTool.js.map +1 -1
- package/dist/commonjs/tools/directions-tool/buildDirectionsRequestUrl.d.ts +29 -0
- package/dist/commonjs/tools/directions-tool/buildDirectionsRequestUrl.d.ts.map +1 -0
- package/dist/commonjs/tools/directions-tool/buildDirectionsRequestUrl.js +63 -0
- package/dist/commonjs/tools/directions-tool/buildDirectionsRequestUrl.js.map +1 -0
- package/dist/commonjs/version.json +3 -3
- package/dist/esm/resources/ui-apps/DirectionsAppUIResource.d.ts +3 -2
- package/dist/esm/resources/ui-apps/DirectionsAppUIResource.d.ts.map +1 -1
- package/dist/esm/resources/ui-apps/DirectionsAppUIResource.js +5 -3
- package/dist/esm/resources/ui-apps/DirectionsAppUIResource.js.map +1 -1
- package/dist/esm/resources/ui-apps/directionsAppHtml.d.ts +20 -8
- package/dist/esm/resources/ui-apps/directionsAppHtml.d.ts.map +1 -1
- package/dist/esm/resources/ui-apps/directionsAppHtml.js +198 -18
- package/dist/esm/resources/ui-apps/directionsAppHtml.js.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.input.schema.d.ts.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.input.schema.js +6 -2
- package/dist/esm/tools/directions-tool/DirectionsTool.input.schema.js.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.js +52 -109
- package/dist/esm/tools/directions-tool/DirectionsTool.js.map +1 -1
- package/dist/esm/tools/directions-tool/buildDirectionsRequestUrl.d.ts +29 -0
- package/dist/esm/tools/directions-tool/buildDirectionsRequestUrl.d.ts.map +1 -0
- package/dist/esm/tools/directions-tool/buildDirectionsRequestUrl.js +60 -0
- package/dist/esm/tools/directions-tool/buildDirectionsRequestUrl.js.map +1 -0
- package/dist/esm/version.json +3 -3
- package/package.json +1 -1
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.DirectionsTool = void 0;
|
|
6
|
-
const node_url_1 = require("node:url");
|
|
7
6
|
const node_crypto_1 = require("node:crypto");
|
|
8
7
|
const server_1 = require("@mcp-ui/server");
|
|
9
8
|
const MapboxApiBasedTool_js_1 = require("../MapboxApiBasedTool.js");
|
|
10
9
|
const cleanResponseData_js_1 = require("./cleanResponseData.js");
|
|
11
|
-
const
|
|
10
|
+
const buildDirectionsRequestUrl_js_1 = require("./buildDirectionsRequestUrl.js");
|
|
12
11
|
const DirectionsTool_input_schema_js_1 = require("./DirectionsTool.input.schema.js");
|
|
13
12
|
const DirectionsTool_output_schema_js_1 = require("./DirectionsTool.output.schema.js");
|
|
14
13
|
const temporaryResourceManager_js_1 = require("../../utils/temporaryResourceManager.js");
|
|
@@ -20,9 +19,11 @@ const directionsAppHtml_js_1 = require("../../resources/ui-apps/directionsAppHtm
|
|
|
20
19
|
class DirectionsTool extends MapboxApiBasedTool_js_1.MapboxApiBasedTool {
|
|
21
20
|
name = 'directions_tool';
|
|
22
21
|
description = 'Fetches directions from Mapbox API based on provided coordinates and direction method. ' +
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
22
|
+
'This tool always attaches an interactive map preview UI to its result; the map fetches and ' +
|
|
23
|
+
'renders its own route independently, so it works regardless of the geometries parameter. ' +
|
|
24
|
+
'Use geometries="none" (default) for compact text/data responses (distance, duration, ' +
|
|
25
|
+
'turn-by-turn instructions). Use geometries="geojson" only when you need the raw route ' +
|
|
26
|
+
'coordinates in the response yourself.';
|
|
26
27
|
annotations = {
|
|
27
28
|
title: 'Directions Tool',
|
|
28
29
|
readOnlyHint: true,
|
|
@@ -160,63 +161,11 @@ class DirectionsTool extends MapboxApiBasedTool_js_1.MapboxApiBasedTool {
|
|
|
160
161
|
isError: true
|
|
161
162
|
};
|
|
162
163
|
}
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const queryParams = new node_url_1.URLSearchParams();
|
|
169
|
-
queryParams.append('access_token', accessToken);
|
|
170
|
-
// Only add geometries parameter if not 'none'
|
|
171
|
-
if (input.geometries !== 'none') {
|
|
172
|
-
queryParams.append('geometries', input.geometries);
|
|
173
|
-
}
|
|
174
|
-
queryParams.append('alternatives', input.alternatives.toString());
|
|
175
|
-
// Add annotations parameter
|
|
176
|
-
if (input.routing_profile === 'mapbox/driving-traffic') {
|
|
177
|
-
// congestion is available only when driving
|
|
178
|
-
queryParams.append('annotations', 'distance,congestion,speed');
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
queryParams.append('annotations', 'distance,speed');
|
|
182
|
-
}
|
|
183
|
-
// For annotations to work, overview must be set to 'full'
|
|
184
|
-
queryParams.append('overview', 'full');
|
|
185
|
-
// Add depart_at or arrive_by parameter if provided, converting format if needed
|
|
186
|
-
if (input.depart_at) {
|
|
187
|
-
const formattedDateTime = (0, dateUtils_js_1.formatIsoDateTime)(input.depart_at);
|
|
188
|
-
queryParams.append('depart_at', formattedDateTime);
|
|
189
|
-
}
|
|
190
|
-
else if (input.arrive_by) {
|
|
191
|
-
const formattedDateTime = (0, dateUtils_js_1.formatIsoDateTime)(input.arrive_by);
|
|
192
|
-
queryParams.append('arrive_by', formattedDateTime);
|
|
193
|
-
}
|
|
194
|
-
// Add vehicle dimension parameters if provided
|
|
195
|
-
if (input.max_height !== undefined) {
|
|
196
|
-
queryParams.append('max_height', input.max_height.toString());
|
|
197
|
-
}
|
|
198
|
-
if (input.max_width !== undefined) {
|
|
199
|
-
queryParams.append('max_width', input.max_width.toString());
|
|
200
|
-
}
|
|
201
|
-
if (input.max_weight !== undefined) {
|
|
202
|
-
queryParams.append('max_weight', input.max_weight.toString());
|
|
203
|
-
}
|
|
204
|
-
queryParams.append('steps', 'true');
|
|
205
|
-
let queryString = queryParams.toString();
|
|
206
|
-
// Add exclude parameter if provided (ensuring proper encoding of special characters)
|
|
207
|
-
if (input.exclude) {
|
|
208
|
-
// Custom encoding function to match the expected format in tests
|
|
209
|
-
const customEncodeForExclude = (str) => {
|
|
210
|
-
return str
|
|
211
|
-
.replace(/,/g, '%2C') // Encode comma
|
|
212
|
-
.replace(/\(/g, '%28') // Encode opening parenthesis
|
|
213
|
-
.replace(/\)/g, '%29') // Encode closing parenthesis
|
|
214
|
-
.replace(/ /g, '%20'); // Encode space as %20, not +
|
|
215
|
-
};
|
|
216
|
-
const excludeEncoded = customEncodeForExclude(input.exclude);
|
|
217
|
-
queryString += `&exclude=${excludeEncoded}`;
|
|
218
|
-
}
|
|
219
|
-
const url = `${MapboxApiBasedTool_js_1.MapboxApiBasedTool.mapboxApiEndpoint}directions/v5/${input.routing_profile}/${encodedCoords}?${queryString}`;
|
|
164
|
+
const url = (0, buildDirectionsRequestUrl_js_1.buildDirectionsRequestUrl)({
|
|
165
|
+
input,
|
|
166
|
+
accessToken,
|
|
167
|
+
apiEndpoint: MapboxApiBasedTool_js_1.MapboxApiBasedTool.mapboxApiEndpoint
|
|
168
|
+
});
|
|
220
169
|
const response = await this.httpRequest(url);
|
|
221
170
|
if (!response.ok) {
|
|
222
171
|
const errorMessage = await this.getErrorMessage(response);
|
|
@@ -242,6 +191,20 @@ class DirectionsTool extends MapboxApiBasedTool_js_1.MapboxApiBasedTool {
|
|
|
242
191
|
this.log('warning', `DirectionsTool: Response validation failed: ${error}`);
|
|
243
192
|
validatedData = cleanedData;
|
|
244
193
|
}
|
|
194
|
+
let uiResourceBlock;
|
|
195
|
+
if ((0, toolConfig_js_1.isMcpUiEnabled)()) {
|
|
196
|
+
const inlineHtml = await tryRenderInlineUiHtml(input, accessToken, this.httpRequest);
|
|
197
|
+
if (inlineHtml) {
|
|
198
|
+
uiResourceBlock = (0, server_1.createUIResource)({
|
|
199
|
+
uri: `ui://mapbox/directions/${(0, node_crypto_1.randomUUID)()}`,
|
|
200
|
+
content: { type: 'rawHtml', htmlString: inlineHtml },
|
|
201
|
+
encoding: 'text',
|
|
202
|
+
uiMetadata: {
|
|
203
|
+
'preferred-frame-size': ['100%', '500px']
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
245
208
|
// Check response size and conditionally create temporary resource
|
|
246
209
|
const RESPONSE_SIZE_THRESHOLD = 50 * 1024; // 50KB
|
|
247
210
|
const responseText = JSON.stringify(validatedData, null, 2);
|
|
@@ -290,8 +253,13 @@ ${responseSize > RESPONSE_SIZE_THRESHOLD ? `\n⚠️ Full response (${Math.round
|
|
|
290
253
|
legs: undefined
|
|
291
254
|
}))
|
|
292
255
|
};
|
|
256
|
+
const content = [
|
|
257
|
+
{ type: 'text', text: summaryText }
|
|
258
|
+
];
|
|
259
|
+
if (uiResourceBlock)
|
|
260
|
+
content.push(uiResourceBlock);
|
|
293
261
|
return {
|
|
294
|
-
content
|
|
262
|
+
content,
|
|
295
263
|
structuredContent: summaryStructuredContent,
|
|
296
264
|
isError: false
|
|
297
265
|
};
|
|
@@ -300,22 +268,8 @@ ${responseSize > RESPONSE_SIZE_THRESHOLD ? `\n⚠️ Full response (${Math.round
|
|
|
300
268
|
const content = [
|
|
301
269
|
{ type: 'text', text: responseText }
|
|
302
270
|
];
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
// carries a renderable GeoJSON geometry — i.e. geometries=geojson.
|
|
306
|
-
if ((0, toolConfig_js_1.isMcpUiEnabled)()) {
|
|
307
|
-
const inlineHtml = await tryRenderInlineUiHtml(validatedData, accessToken, this.httpRequest);
|
|
308
|
-
if (inlineHtml) {
|
|
309
|
-
content.push((0, server_1.createUIResource)({
|
|
310
|
-
uri: `ui://mapbox/directions/${(0, node_crypto_1.randomUUID)()}`,
|
|
311
|
-
content: { type: 'rawHtml', htmlString: inlineHtml },
|
|
312
|
-
encoding: 'text',
|
|
313
|
-
uiMetadata: {
|
|
314
|
-
'preferred-frame-size': ['100%', '500px']
|
|
315
|
-
}
|
|
316
|
-
}));
|
|
317
|
-
}
|
|
318
|
-
}
|
|
271
|
+
if (uiResourceBlock)
|
|
272
|
+
content.push(uiResourceBlock);
|
|
319
273
|
return {
|
|
320
274
|
content,
|
|
321
275
|
structuredContent: validatedData,
|
|
@@ -325,25 +279,14 @@ ${responseSize > RESPONSE_SIZE_THRESHOLD ? `\n⚠️ Full response (${Math.round
|
|
|
325
279
|
}
|
|
326
280
|
exports.DirectionsTool = DirectionsTool;
|
|
327
281
|
/**
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
282
|
+
* Render the same DirectionsAppHtml as the MCP Apps resource, but with the
|
|
283
|
+
* call's input parameters baked in so the iframe can self-fetch the route
|
|
284
|
+
* from the Directions API — MCP-UI clients don't fetch external resources,
|
|
285
|
+
* so this is what makes the map work for them too. Attached unconditionally;
|
|
286
|
+
* the only failure mode is no public token being resolvable, in which case
|
|
287
|
+
* the caller falls back to text-only output.
|
|
333
288
|
*/
|
|
334
|
-
async function tryRenderInlineUiHtml(
|
|
335
|
-
const route = data.routes?.[0];
|
|
336
|
-
const geometry = route?.geometry;
|
|
337
|
-
// Accept either a GeoJSON LineString object or a polyline string — the
|
|
338
|
-
// iframe normalizes both shapes before rendering.
|
|
339
|
-
const hasGeojson = geometry &&
|
|
340
|
-
typeof geometry === 'object' &&
|
|
341
|
-
geometry.type === 'LineString' &&
|
|
342
|
-
Array.isArray(geometry.coordinates);
|
|
343
|
-
const hasPolyline = typeof geometry === 'string' && geometry.length > 0;
|
|
344
|
-
if (!hasGeojson && !hasPolyline) {
|
|
345
|
-
return undefined;
|
|
346
|
-
}
|
|
289
|
+
async function tryRenderInlineUiHtml(input, accessToken, httpRequest) {
|
|
347
290
|
const publicToken = await (0, mapboxPublicToken_js_1.resolveMapboxPublicToken)({
|
|
348
291
|
accessToken,
|
|
349
292
|
apiEndpoint: MapboxApiBasedTool_js_1.MapboxApiBasedTool.mapboxApiEndpoint,
|
|
@@ -351,21 +294,21 @@ async function tryRenderInlineUiHtml(data, accessToken, httpRequest) {
|
|
|
351
294
|
});
|
|
352
295
|
if (!publicToken)
|
|
353
296
|
return undefined;
|
|
354
|
-
const summaryParts = [];
|
|
355
|
-
if (typeof route?.distance === 'number') {
|
|
356
|
-
summaryParts.push(`${(route.distance / 1609.34).toFixed(1)} mi`);
|
|
357
|
-
}
|
|
358
|
-
if (typeof route?.duration === 'number') {
|
|
359
|
-
summaryParts.push(`${Math.round(route.duration / 60)} min`);
|
|
360
|
-
}
|
|
361
|
-
const summary = summaryParts.length
|
|
362
|
-
? `Route: ${summaryParts.join(', ')}`
|
|
363
|
-
: 'Route';
|
|
364
297
|
return (0, directionsAppHtml_js_1.renderDirectionsAppHtml)({
|
|
365
298
|
publicToken,
|
|
299
|
+
apiEndpoint: MapboxApiBasedTool_js_1.MapboxApiBasedTool.mapboxApiEndpoint,
|
|
366
300
|
initialData: {
|
|
367
|
-
|
|
368
|
-
|
|
301
|
+
params: {
|
|
302
|
+
coordinates: input.coordinates,
|
|
303
|
+
routing_profile: input.routing_profile,
|
|
304
|
+
alternatives: input.alternatives,
|
|
305
|
+
exclude: input.exclude,
|
|
306
|
+
depart_at: input.depart_at,
|
|
307
|
+
arrive_by: input.arrive_by,
|
|
308
|
+
max_height: input.max_height,
|
|
309
|
+
max_width: input.max_width,
|
|
310
|
+
max_weight: input.max_weight
|
|
311
|
+
}
|
|
369
312
|
}
|
|
370
313
|
});
|
|
371
314
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectionsTool.js","sourceRoot":"","sources":["../../../../src/tools/directions-tool/DirectionsTool.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAElC,
|
|
1
|
+
{"version":3,"file":"DirectionsTool.js","sourceRoot":"","sources":["../../../../src/tools/directions-tool/DirectionsTool.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAElC,6CAAsD;AAEtD,2CAAkD;AAClD,oEAA8D;AAE9D,iEAA2D;AAC3D,iFAA2E;AAC3E,qFAAyE;AACzE,uFAG2C;AAE3C,yFAAmF;AACnF,yDAA+D;AAC/D,8DAA4D;AAC5D,2EAA4E;AAC5E,uFAAuF;AAEvF,2DAA2D;AAE3D,MAAa,cAAe,SAAQ,0CAGnC;IACC,IAAI,GAAG,iBAAiB,CAAC;IACzB,WAAW,GACT,yFAAyF;QACzF,6FAA6F;QAC7F,2FAA2F;QAC3F,uFAAuF;QACvF,wFAAwF;QACxF,uCAAuC,CAAC;IAC1C,WAAW,GAAG;QACZ,KAAK,EAAE,iBAAiB;QACxB,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;KACpB,CAAC;IACO,IAAI,GAAG;QACd,EAAE,EAAE;YACF,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B;QACjD,WAAW;KACZ,CAAC,CAAC;IACH,IAAI,CAAC,WAAW;QAAE,OAAO,SAAS,CAAC;IAEnC,OAAO,IAAA,8CAAuB,EAAC;QAC7B,WAAW;QACX,WAAW,EAAE,0CAAkB,CAAC,iBAAiB;QACjD,WAAW,EAAE;YACX,MAAM,EAAE;gBACN,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,eAAe,EAAE,KAAK,CAAC,eAAe;gBACtC,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,UAAU,EAAE,KAAK,CAAC,UAAU;aAC7B;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface DirectionsRequestInput {
|
|
2
|
+
coordinates: {
|
|
3
|
+
longitude: number;
|
|
4
|
+
latitude: number;
|
|
5
|
+
}[];
|
|
6
|
+
routing_profile: string;
|
|
7
|
+
geometries: 'none' | 'geojson';
|
|
8
|
+
alternatives: boolean;
|
|
9
|
+
exclude?: string;
|
|
10
|
+
depart_at?: string;
|
|
11
|
+
arrive_by?: string;
|
|
12
|
+
max_height?: number;
|
|
13
|
+
max_width?: number;
|
|
14
|
+
max_weight?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Build the Mapbox Directions v5 request URL for a given input. Shared by
|
|
18
|
+
* DirectionsTool.execute() (server-side) and hand-mirrored by the
|
|
19
|
+
* self-fetching map preview iframe (directionsAppHtml.ts) — the parity test
|
|
20
|
+
* in test/tools/directions-tool/directionsUrlParity.test.ts keeps the two
|
|
21
|
+
* implementations in sync.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildDirectionsRequestUrl(params: {
|
|
24
|
+
input: DirectionsRequestInput;
|
|
25
|
+
accessToken: string;
|
|
26
|
+
apiEndpoint: string;
|
|
27
|
+
geometriesOverride?: 'none' | 'geojson';
|
|
28
|
+
}): string;
|
|
29
|
+
//# sourceMappingURL=buildDirectionsRequestUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildDirectionsRequestUrl.d.ts","sourceRoot":"","sources":["../../../../src/tools/directions-tool/buildDirectionsRequestUrl.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvD,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAUD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE;IAChD,KAAK,EAAE,sBAAsB,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC,GAAG,MAAM,CA+CT"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Mapbox, Inc.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.buildDirectionsRequestUrl = buildDirectionsRequestUrl;
|
|
6
|
+
const dateUtils_js_1 = require("../../utils/dateUtils.js");
|
|
7
|
+
function encodeExclude(value) {
|
|
8
|
+
return value
|
|
9
|
+
.replace(/,/g, '%2C')
|
|
10
|
+
.replace(/\(/g, '%28')
|
|
11
|
+
.replace(/\)/g, '%29')
|
|
12
|
+
.replace(/ /g, '%20');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Build the Mapbox Directions v5 request URL for a given input. Shared by
|
|
16
|
+
* DirectionsTool.execute() (server-side) and hand-mirrored by the
|
|
17
|
+
* self-fetching map preview iframe (directionsAppHtml.ts) — the parity test
|
|
18
|
+
* in test/tools/directions-tool/directionsUrlParity.test.ts keeps the two
|
|
19
|
+
* implementations in sync.
|
|
20
|
+
*/
|
|
21
|
+
function buildDirectionsRequestUrl(params) {
|
|
22
|
+
const { input, accessToken, apiEndpoint, geometriesOverride } = params;
|
|
23
|
+
const geometries = geometriesOverride ?? input.geometries;
|
|
24
|
+
const joined = input.coordinates
|
|
25
|
+
.map(({ longitude, latitude }) => `${longitude},${latitude}`)
|
|
26
|
+
.join(';');
|
|
27
|
+
const encodedCoords = encodeURIComponent(joined);
|
|
28
|
+
const queryParams = new URLSearchParams();
|
|
29
|
+
queryParams.append('access_token', accessToken);
|
|
30
|
+
if (geometries !== 'none') {
|
|
31
|
+
queryParams.append('geometries', geometries);
|
|
32
|
+
}
|
|
33
|
+
queryParams.append('alternatives', input.alternatives.toString());
|
|
34
|
+
if (input.routing_profile === 'mapbox/driving-traffic') {
|
|
35
|
+
queryParams.append('annotations', 'distance,congestion,speed');
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
queryParams.append('annotations', 'distance,speed');
|
|
39
|
+
}
|
|
40
|
+
queryParams.append('overview', 'full');
|
|
41
|
+
if (input.depart_at) {
|
|
42
|
+
queryParams.append('depart_at', (0, dateUtils_js_1.formatIsoDateTime)(input.depart_at));
|
|
43
|
+
}
|
|
44
|
+
else if (input.arrive_by) {
|
|
45
|
+
queryParams.append('arrive_by', (0, dateUtils_js_1.formatIsoDateTime)(input.arrive_by));
|
|
46
|
+
}
|
|
47
|
+
if (input.max_height !== undefined) {
|
|
48
|
+
queryParams.append('max_height', input.max_height.toString());
|
|
49
|
+
}
|
|
50
|
+
if (input.max_width !== undefined) {
|
|
51
|
+
queryParams.append('max_width', input.max_width.toString());
|
|
52
|
+
}
|
|
53
|
+
if (input.max_weight !== undefined) {
|
|
54
|
+
queryParams.append('max_weight', input.max_weight.toString());
|
|
55
|
+
}
|
|
56
|
+
queryParams.append('steps', 'true');
|
|
57
|
+
let queryString = queryParams.toString();
|
|
58
|
+
if (input.exclude) {
|
|
59
|
+
queryString += `&exclude=${encodeExclude(input.exclude)}`;
|
|
60
|
+
}
|
|
61
|
+
return `${apiEndpoint}directions/v5/${input.routing_profile}/${encodedCoords}?${queryString}`;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=buildDirectionsRequestUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildDirectionsRequestUrl.js","sourceRoot":"","sources":["../../../../src/tools/directions-tool/buildDirectionsRequestUrl.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;AAgClC,8DAoDC;AAlFD,2DAA6D;AAe7D,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,yBAAyB,CAAC,MAKzC;IACC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAAC;IACvE,MAAM,UAAU,GAAG,kBAAkB,IAAI,KAAK,CAAC,UAAU,CAAC;IAE1D,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW;S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AAE,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAClC,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACnC,WAAW,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;IAEzC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,WAAW,IAAI,YAAY,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;IAC5D,CAAC;IAED,OAAO,GAAG,WAAW,iBAAiB,KAAK,CAAC,eAAe,IAAI,aAAa,IAAI,WAAW,EAAE,CAAC;AAChG,CAAC"}
|
|
@@ -9,8 +9,9 @@ import type { HttpRequest } from '../../utils/types.js';
|
|
|
9
9
|
* event and renders the route from `structuredContent.routes[0]`.
|
|
10
10
|
*
|
|
11
11
|
* The legacy MCP-UI pathway (inline `rawHtml` on the tool result) uses the
|
|
12
|
-
* same HTML template via `renderDirectionsAppHtml` with
|
|
13
|
-
* tool-execute time
|
|
12
|
+
* same HTML template via `renderDirectionsAppHtml` with the call's input
|
|
13
|
+
* params baked in at tool-execute time; the iframe self-fetches the route
|
|
14
|
+
* from the Directions API using those params.
|
|
14
15
|
*/
|
|
15
16
|
export declare class DirectionsAppUIResource extends BaseResource {
|
|
16
17
|
readonly name = "Directions App UI";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectionsAppUIResource.d.ts","sourceRoot":"","sources":["../../../../src/resources/ui-apps/DirectionsAppUIResource.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACd,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIxD
|
|
1
|
+
{"version":3,"file":"DirectionsAppUIResource.d.ts","sourceRoot":"","sources":["../../../../src/resources/ui-apps/DirectionsAppUIResource.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACd,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIxD;;;;;;;;;;GAUG;AACH,qBAAa,uBAAwB,SAAQ,YAAY;IACvD,QAAQ,CAAC,IAAI,uBAAuB;IACpC,QAAQ,CAAC,GAAG,2CAA2C;IACvD,QAAQ,CAAC,WAAW,2FACsE;IAC1F,QAAQ,CAAC,QAAQ,+BAAsB;IAEvC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;gBAE/B,MAAM,EAAE;QAClB,WAAW,EAAE,WAAW,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;KAC5B;IAQK,IAAI,CACR,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,mBAAmB,CAAC,aAAa,EAAE,kBAAkB,CAAC,GAC7D,OAAO,CAAC,kBAAkB,CAAC;CAwC/B"}
|
|
@@ -11,8 +11,9 @@ import { renderDirectionsAppHtml } from './directionsAppHtml.js';
|
|
|
11
11
|
* event and renders the route from `structuredContent.routes[0]`.
|
|
12
12
|
*
|
|
13
13
|
* The legacy MCP-UI pathway (inline `rawHtml` on the tool result) uses the
|
|
14
|
-
* same HTML template via `renderDirectionsAppHtml` with
|
|
15
|
-
* tool-execute time
|
|
14
|
+
* same HTML template via `renderDirectionsAppHtml` with the call's input
|
|
15
|
+
* params baked in at tool-execute time; the iframe self-fetches the route
|
|
16
|
+
* from the Directions API using those params.
|
|
16
17
|
*/
|
|
17
18
|
export class DirectionsAppUIResource extends BaseResource {
|
|
18
19
|
name = 'Directions App UI';
|
|
@@ -38,7 +39,8 @@ export class DirectionsAppUIResource extends BaseResource {
|
|
|
38
39
|
httpRequest: this.httpRequest
|
|
39
40
|
});
|
|
40
41
|
const html = renderDirectionsAppHtml({
|
|
41
|
-
publicToken: publicToken ?? ''
|
|
42
|
+
publicToken: publicToken ?? '',
|
|
43
|
+
apiEndpoint: this.apiEndpoint()
|
|
42
44
|
});
|
|
43
45
|
return {
|
|
44
46
|
contents: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectionsAppUIResource.js","sourceRoot":"","sources":["../../../../src/resources/ui-apps/DirectionsAppUIResource.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAQlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE
|
|
1
|
+
{"version":3,"file":"DirectionsAppUIResource.js","sourceRoot":"","sources":["../../../../src/resources/ui-apps/DirectionsAppUIResource.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAQlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,C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Ac,EAAE;oCACd,sBAAsB;oCACtB,2BAA2B;iCAC5B;gCACD,eAAe,EAAE,CAAC,wBAAwB,CAAC;gCAC3C,aAAa,EAAE,CAAC,OAAO,CAAC;6BACzB;4BACD,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE;yBAC5C;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -11,22 +11,34 @@
|
|
|
11
11
|
*
|
|
12
12
|
* 2. **Legacy MCP-UI spec** — `directions_tool` inlines a `rawHtml`
|
|
13
13
|
* UIResource into its content array (gated by `isMcpUiEnabled()`). The
|
|
14
|
-
* HTML is generated at tool-execute time with the
|
|
15
|
-
* baked in as an `initialData` script block
|
|
16
|
-
*
|
|
14
|
+
* HTML is generated at tool-execute time with the call's input params
|
|
15
|
+
* baked in as an `initialData` script block; the iframe uses those params
|
|
16
|
+
* to self-fetch the route from the Directions API, so it never depends on
|
|
17
|
+
* the host delivering the tool result.
|
|
17
18
|
*
|
|
18
19
|
* One source of truth for the rendering logic; two slim entry conditions.
|
|
19
20
|
*/
|
|
20
21
|
export declare const MAPBOX_GL_VERSION = "3.12.0";
|
|
22
|
+
export interface DirectionsAppInitialParams {
|
|
23
|
+
coordinates: {
|
|
24
|
+
longitude: number;
|
|
25
|
+
latitude: number;
|
|
26
|
+
}[];
|
|
27
|
+
routing_profile?: string;
|
|
28
|
+
alternatives?: boolean;
|
|
29
|
+
exclude?: string;
|
|
30
|
+
depart_at?: string;
|
|
31
|
+
arrive_by?: string;
|
|
32
|
+
max_height?: number;
|
|
33
|
+
max_width?: number;
|
|
34
|
+
max_weight?: number;
|
|
35
|
+
}
|
|
21
36
|
export interface DirectionsAppInitialData {
|
|
22
|
-
|
|
23
|
-
type: string;
|
|
24
|
-
coordinates: [number, number][];
|
|
25
|
-
};
|
|
26
|
-
summary?: string;
|
|
37
|
+
params: DirectionsAppInitialParams;
|
|
27
38
|
}
|
|
28
39
|
export declare function renderDirectionsAppHtml(params: {
|
|
29
40
|
publicToken: string;
|
|
41
|
+
apiEndpoint: string;
|
|
30
42
|
glVersion?: string;
|
|
31
43
|
initialData?: DirectionsAppInitialData;
|
|
32
44
|
}): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directionsAppHtml.d.ts","sourceRoot":"","sources":["../../../../src/resources/ui-apps/directionsAppHtml.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"directionsAppHtml.d.ts","sourceRoot":"","sources":["../../../../src/resources/ui-apps/directionsAppHtml.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,0BAA0B,CAAC;CACpC;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,wBAAwB,CAAC;CACxC,GAAG,MAAM,CAmmBT"}
|