@mapbox/mcp-server 0.12.5 → 0.12.7-dev
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 +136 -17
- 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/utils/mapboxPublicToken.d.ts +6 -4
- package/dist/commonjs/utils/mapboxPublicToken.d.ts.map +1 -1
- package/dist/commonjs/utils/mapboxPublicToken.js +25 -13
- package/dist/commonjs/utils/mapboxPublicToken.js.map +1 -1
- 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 +136 -17
- 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/utils/mapboxPublicToken.d.ts +6 -4
- package/dist/esm/utils/mapboxPublicToken.d.ts.map +1 -1
- package/dist/esm/utils/mapboxPublicToken.js +25 -13
- package/dist/esm/utils/mapboxPublicToken.js.map +1 -1
- package/dist/esm/version.json +3 -3
- package/package.json +1 -1
|
@@ -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":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Input {
|
|
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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IAAI,aAAa,IAAI,WAAW,EAAE,CAAC;AAChG,CAAC"}
|
|
@@ -5,10 +5,12 @@ import type { HttpRequest } from './types.js';
|
|
|
5
5
|
*
|
|
6
6
|
* Resolution order:
|
|
7
7
|
* 1. If the access token is already a pk.* token, use it directly.
|
|
8
|
-
* 2. Reuse a cached pk.* token while it has >5 min TTL remaining.
|
|
9
|
-
* 3. If the access token is an sk.* token, call
|
|
8
|
+
* 2. Reuse a cached pk.* token (per-user) while it has >5 min TTL remaining.
|
|
9
|
+
* 3. If the access token is an sk.* or tk.* token, call
|
|
10
10
|
* GET /tokens/v2/{user}?default=true to fetch the user's default public
|
|
11
|
-
* token (requires `tokens:read` scope on the bearer).
|
|
11
|
+
* token (requires `tokens:read` scope on the bearer). OAuth-issued bearers
|
|
12
|
+
* are tk.* temporary tokens, so this is the path exercised in hosted
|
|
13
|
+
* (OAuth) deployments — without it, granting `tokens:read` has no effect.
|
|
12
14
|
* 4. Fall back to the MAPBOX_PUBLIC_TOKEN env var.
|
|
13
15
|
*
|
|
14
16
|
* Returns undefined if none of the above produces a pk.* token.
|
|
@@ -19,7 +21,7 @@ export declare function resolveMapboxPublicToken(params: {
|
|
|
19
21
|
httpRequest: HttpRequest;
|
|
20
22
|
}): Promise<string | undefined>;
|
|
21
23
|
/**
|
|
22
|
-
* Reset the cached public token. For tests only.
|
|
24
|
+
* Reset the cached public token(s). For tests only.
|
|
23
25
|
*/
|
|
24
26
|
export declare function __resetMapboxPublicTokenCache(): void;
|
|
25
27
|
//# sourceMappingURL=mapboxPublicToken.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapboxPublicToken.d.ts","sourceRoot":"","sources":["../../../src/utils/mapboxPublicToken.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"mapboxPublicToken.d.ts","sourceRoot":"","sources":["../../../src/utils/mapboxPublicToken.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAmB9C;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,wBAAwB,CAAC,MAAM,EAAE;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,WAAW,CAAC;CAC1B,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA2D9B;AAED;;GAEG;AACH,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD"}
|
|
@@ -6,17 +6,21 @@ exports.resolveMapboxPublicToken = resolveMapboxPublicToken;
|
|
|
6
6
|
exports.__resetMapboxPublicTokenCache = __resetMapboxPublicTokenCache;
|
|
7
7
|
const jwtUtils_js_1 = require("./jwtUtils.js");
|
|
8
8
|
const PUBLIC_TOKEN_TTL_MS = 60 * 60 * 1000; // 1h
|
|
9
|
-
|
|
9
|
+
// Keyed by username so that concurrent requests from different accounts
|
|
10
|
+
// never share each other's cached pk.* token.
|
|
11
|
+
const publicTokenCache = new Map();
|
|
10
12
|
/**
|
|
11
13
|
* Resolve a public (pk.*) Mapbox token suitable for embedding in client-side
|
|
12
14
|
* HTML (e.g. an MCP App iframe that initializes Mapbox GL JS).
|
|
13
15
|
*
|
|
14
16
|
* Resolution order:
|
|
15
17
|
* 1. If the access token is already a pk.* token, use it directly.
|
|
16
|
-
* 2. Reuse a cached pk.* token while it has >5 min TTL remaining.
|
|
17
|
-
* 3. If the access token is an sk.* token, call
|
|
18
|
+
* 2. Reuse a cached pk.* token (per-user) while it has >5 min TTL remaining.
|
|
19
|
+
* 3. If the access token is an sk.* or tk.* token, call
|
|
18
20
|
* GET /tokens/v2/{user}?default=true to fetch the user's default public
|
|
19
|
-
* token (requires `tokens:read` scope on the bearer).
|
|
21
|
+
* token (requires `tokens:read` scope on the bearer). OAuth-issued bearers
|
|
22
|
+
* are tk.* temporary tokens, so this is the path exercised in hosted
|
|
23
|
+
* (OAuth) deployments — without it, granting `tokens:read` has no effect.
|
|
20
24
|
* 4. Fall back to the MAPBOX_PUBLIC_TOKEN env var.
|
|
21
25
|
*
|
|
22
26
|
* Returns undefined if none of the above produces a pk.* token.
|
|
@@ -26,13 +30,14 @@ async function resolveMapboxPublicToken(params) {
|
|
|
26
30
|
if (accessToken.startsWith('pk.')) {
|
|
27
31
|
return accessToken;
|
|
28
32
|
}
|
|
29
|
-
|
|
30
|
-
if (cachedPublicToken && cachedPublicToken.expiresAt - now > 5 * 60 * 1000) {
|
|
31
|
-
return cachedPublicToken.token;
|
|
32
|
-
}
|
|
33
|
-
if (accessToken.startsWith('sk.')) {
|
|
33
|
+
if (accessToken.startsWith('sk.') || accessToken.startsWith('tk.')) {
|
|
34
34
|
const username = (0, jwtUtils_js_1.getUserNameFromToken)(accessToken);
|
|
35
35
|
if (username) {
|
|
36
|
+
const now = Date.now();
|
|
37
|
+
const cached = publicTokenCache.get(username);
|
|
38
|
+
if (cached && cached.expiresAt - now > 5 * 60 * 1000) {
|
|
39
|
+
return cached.token;
|
|
40
|
+
}
|
|
36
41
|
try {
|
|
37
42
|
const tokensUrl = new URL(`${apiEndpoint}tokens/v2/${username}`);
|
|
38
43
|
tokensUrl.searchParams.set('default', 'true');
|
|
@@ -45,13 +50,20 @@ async function resolveMapboxPublicToken(params) {
|
|
|
45
50
|
: (body?.tokens ?? []);
|
|
46
51
|
const defaultPk = entries.find((entry) => entry?.usage === 'pk' && typeof entry.token === 'string');
|
|
47
52
|
if (defaultPk?.token) {
|
|
48
|
-
|
|
53
|
+
publicTokenCache.set(username, {
|
|
49
54
|
token: defaultPk.token,
|
|
50
55
|
expiresAt: now + PUBLIC_TOKEN_TTL_MS
|
|
51
|
-
};
|
|
56
|
+
});
|
|
52
57
|
return defaultPk.token;
|
|
53
58
|
}
|
|
54
59
|
}
|
|
60
|
+
else if (response.status === 401 || response.status === 403) {
|
|
61
|
+
// Expected when the bearer lacks the `tokens:read` scope — not an
|
|
62
|
+
// anomaly, so don't warn-log on every such request.
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
console.warn(`resolveMapboxPublicToken: Tokens API returned unexpected HTTP ${response.status}; falling back to MAPBOX_PUBLIC_TOKEN env var`);
|
|
66
|
+
}
|
|
55
67
|
}
|
|
56
68
|
catch (err) {
|
|
57
69
|
// Network failures and JSON parse errors land here. Surface a warning
|
|
@@ -65,9 +77,9 @@ async function resolveMapboxPublicToken(params) {
|
|
|
65
77
|
return envFallback && envFallback.startsWith('pk.') ? envFallback : undefined;
|
|
66
78
|
}
|
|
67
79
|
/**
|
|
68
|
-
* Reset the cached public token. For tests only.
|
|
80
|
+
* Reset the cached public token(s). For tests only.
|
|
69
81
|
*/
|
|
70
82
|
function __resetMapboxPublicTokenCache() {
|
|
71
|
-
|
|
83
|
+
publicTokenCache.clear();
|
|
72
84
|
}
|
|
73
85
|
//# sourceMappingURL=mapboxPublicToken.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapboxPublicToken.js","sourceRoot":"","sources":["../../../src/utils/mapboxPublicToken.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;
|
|
1
|
+
{"version":3,"file":"mapboxPublicToken.js","sourceRoot":"","sources":["../../../src/utils/mapboxPublicToken.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;AAsClC,4DA+DC;AAKD,sEAEC;AA1GD,+CAAqD;AAcrD,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,KAAK;AAEjD,wEAAwE;AACxE,8CAA8C;AAC9C,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAuB,CAAC;AAExD;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,wBAAwB,CAAC,MAI9C;IACC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAEzD,IAAI,WAAW,CAAC,UAAU,CAAC,KAAK,CA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K,KAAK,IAAI,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,CACpE,CAAC;oBACF,IAAI,SAAS,EAAE,KAAK,EAAE,CAAC;wBACrB,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE;4BAC7B,KAAK,EAAE,SAAS,CAAC,KAAK;4BACtB,SAAS,EAAE,GAAG,GAAG,mBAAmB;yBACrC,CAAC,CAAC;wBACH,OAAO,SAAS,CAAC,KAAK,CAAC;oBACzB,CAAC;gBACH,CAAC;qBAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;oBAC9D,kEAAkE;oBAClE,oDAAoD;gBACtD,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,IAAI,CACV,iEAAiE,QAAQ,CAAC,MAAM,+CAA+C,CAChI,CAAC;gBACJ,CAAC;YACH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,sEAAsE;gBACtE,sEAAsE;gBACtE,iCAAiC;gBACjC,OAAO,CAAC,IAAI,CACV,kGAAkG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACrJ,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IACpD,OAAO,WAAW,IAAI,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC;AAED;;GAEG;AACH,SAAgB,6BAA6B;IAC3C,gBAAgB,CAAC,KAAK,EAAE,CAAC;AAC3B,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,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W;YACX,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;YAC/B,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,uBAAuB,CAAC;YACnC,WAAW,EAAE,WAAW,IAAI,EAAE;YAC9B,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;SAChC,CAAC,CAAC;QAEH,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,GAAG,EAAE,IAAI,CAAC,GAAG;oBACb,QAAQ,EAAE,kBAAkB;oBAC5B,IAAI,EAAE,IAAI;oBACV,KAAK,EAAE;wBACL,EAAE,EAAE;4BACF,GAAG,EAAE;gCACH,cAAc,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,CAsiBT"}
|
|
@@ -13,15 +13,16 @@
|
|
|
13
13
|
*
|
|
14
14
|
* 2. **Legacy MCP-UI spec** — `directions_tool` inlines a `rawHtml`
|
|
15
15
|
* UIResource into its content array (gated by `isMcpUiEnabled()`). The
|
|
16
|
-
* HTML is generated at tool-execute time with the
|
|
17
|
-
* baked in as an `initialData` script block
|
|
18
|
-
*
|
|
16
|
+
* HTML is generated at tool-execute time with the call's input params
|
|
17
|
+
* baked in as an `initialData` script block; the iframe uses those params
|
|
18
|
+
* to self-fetch the route from the Directions API, so it never depends on
|
|
19
|
+
* the host delivering the tool result.
|
|
19
20
|
*
|
|
20
21
|
* One source of truth for the rendering logic; two slim entry conditions.
|
|
21
22
|
*/
|
|
22
23
|
export const MAPBOX_GL_VERSION = '3.12.0';
|
|
23
24
|
export function renderDirectionsAppHtml(params) {
|
|
24
|
-
const { publicToken, initialData } = params;
|
|
25
|
+
const { publicToken, apiEndpoint, initialData } = params;
|
|
25
26
|
const glVersion = params.glVersion ?? MAPBOX_GL_VERSION;
|
|
26
27
|
const initialDataScript = initialData
|
|
27
28
|
? `<script id="initial-data" type="application/json">${escapeForScript(JSON.stringify(initialData))}</script>`
|
|
@@ -68,6 +69,7 @@ ${initialDataScript}
|
|
|
68
69
|
<script>
|
|
69
70
|
(function() {
|
|
70
71
|
var TOKEN = ${JSON.stringify(publicToken)};
|
|
72
|
+
var API_ENDPOINT = ${JSON.stringify(apiEndpoint)};
|
|
71
73
|
|
|
72
74
|
var loadingEl = document.getElementById('loading');
|
|
73
75
|
var errorEl = document.getElementById('error');
|
|
@@ -80,6 +82,117 @@ ${initialDataScript}
|
|
|
80
82
|
// Track markers across re-renders so we can remove them before drawing the
|
|
81
83
|
// next route — otherwise a second tool-result delivery stacks pins.
|
|
82
84
|
var routeMarkers = [];
|
|
85
|
+
var routeRendered = false;
|
|
86
|
+
var selfFetchStarted = false;
|
|
87
|
+
|
|
88
|
+
// -------------------------------------------------------------------------
|
|
89
|
+
// Self-fetch: build a Directions API request directly from the tool call's
|
|
90
|
+
// input parameters and fetch the route ourselves, so this map never
|
|
91
|
+
// depends on the tool response carrying geometries="geojson".
|
|
92
|
+
//
|
|
93
|
+
// Mirrors src/tools/directions-tool/buildDirectionsRequestUrl.ts — kept in
|
|
94
|
+
// sync by the parity test in
|
|
95
|
+
// test/tools/directions-tool/directionsUrlParity.test.ts. Always forces
|
|
96
|
+
// geometries=geojson regardless of what the tool call itself requested.
|
|
97
|
+
// -------------------------------------------------------------------------
|
|
98
|
+
function formatIsoDateTimeClient(dateTime) {
|
|
99
|
+
var noTzWithSeconds = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$/;
|
|
100
|
+
if (noTzWithSeconds.test(dateTime)) {
|
|
101
|
+
return dateTime.substring(0, dateTime.lastIndexOf(':'));
|
|
102
|
+
}
|
|
103
|
+
return dateTime;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function encodeExcludeClient(value) {
|
|
107
|
+
return value
|
|
108
|
+
.replace(/,/g, '%2C')
|
|
109
|
+
.replace(/\\(/g, '%28')
|
|
110
|
+
.replace(/\\)/g, '%29')
|
|
111
|
+
.replace(/ /g, '%20');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function buildDirectionsApiUrl(params, publicToken, apiEndpoint) {
|
|
115
|
+
var coords = params.coordinates
|
|
116
|
+
.map(function(c) { return c.longitude + ',' + c.latitude; })
|
|
117
|
+
.join(';');
|
|
118
|
+
var encodedCoords = encodeURIComponent(coords);
|
|
119
|
+
var profile = params.routing_profile || 'mapbox/driving-traffic';
|
|
120
|
+
|
|
121
|
+
var qp = new URLSearchParams();
|
|
122
|
+
qp.append('access_token', publicToken);
|
|
123
|
+
qp.append('geometries', 'geojson');
|
|
124
|
+
qp.append('alternatives', params.alternatives ? 'true' : 'false');
|
|
125
|
+
qp.append(
|
|
126
|
+
'annotations',
|
|
127
|
+
profile === 'mapbox/driving-traffic'
|
|
128
|
+
? 'distance,congestion,speed'
|
|
129
|
+
: 'distance,speed'
|
|
130
|
+
);
|
|
131
|
+
qp.append('overview', 'full');
|
|
132
|
+
|
|
133
|
+
if (params.depart_at) {
|
|
134
|
+
qp.append('depart_at', formatIsoDateTimeClient(params.depart_at));
|
|
135
|
+
} else if (params.arrive_by) {
|
|
136
|
+
qp.append('arrive_by', formatIsoDateTimeClient(params.arrive_by));
|
|
137
|
+
}
|
|
138
|
+
if (params.max_height !== undefined && params.max_height !== null) {
|
|
139
|
+
qp.append('max_height', String(params.max_height));
|
|
140
|
+
}
|
|
141
|
+
if (params.max_width !== undefined && params.max_width !== null) {
|
|
142
|
+
qp.append('max_width', String(params.max_width));
|
|
143
|
+
}
|
|
144
|
+
if (params.max_weight !== undefined && params.max_weight !== null) {
|
|
145
|
+
qp.append('max_weight', String(params.max_weight));
|
|
146
|
+
}
|
|
147
|
+
qp.append('steps', 'true');
|
|
148
|
+
|
|
149
|
+
var queryString = qp.toString();
|
|
150
|
+
if (params.exclude) {
|
|
151
|
+
queryString += '&exclude=' + encodeExcludeClient(params.exclude);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return apiEndpoint + 'directions/v5/' + profile + '/' + encodedCoords + '?' + queryString;
|
|
155
|
+
}
|
|
156
|
+
// Exposed so the parity test (Node vm sandbox) can call this in isolation.
|
|
157
|
+
window.__buildDirectionsApiUrl = buildDirectionsApiUrl;
|
|
158
|
+
|
|
159
|
+
function fetchRouteFromDirectionsApi(params) {
|
|
160
|
+
if (!TOKEN || !params || !params.coordinates) return;
|
|
161
|
+
selfFetchStarted = true;
|
|
162
|
+
var url = buildDirectionsApiUrl(params, TOKEN, API_ENDPOINT);
|
|
163
|
+
fetch(url)
|
|
164
|
+
.then(function(res) {
|
|
165
|
+
if (!res.ok) {
|
|
166
|
+
return res
|
|
167
|
+
.json()
|
|
168
|
+
.catch(function() { return null; })
|
|
169
|
+
.then(function(body) {
|
|
170
|
+
var msg =
|
|
171
|
+
body && body.message
|
|
172
|
+
? body.message
|
|
173
|
+
: 'Directions API error (' + res.status + ')';
|
|
174
|
+
throw new Error(msg);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return res.json();
|
|
178
|
+
})
|
|
179
|
+
.then(function(data) {
|
|
180
|
+
if (routeRendered) return;
|
|
181
|
+
var route = data && data.routes && data.routes[0];
|
|
182
|
+
var picked = route ? pickRouteGeometry(route) : null;
|
|
183
|
+
if (picked) {
|
|
184
|
+
renderRoute(picked);
|
|
185
|
+
} else {
|
|
186
|
+
showError('Directions API returned no route.');
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
.catch(function(err) {
|
|
190
|
+
if (routeRendered) return;
|
|
191
|
+
showError(
|
|
192
|
+
'Could not fetch route: ' + (err && err.message ? err.message : err)
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
83
196
|
|
|
84
197
|
// -------------------------------------------------------------------------
|
|
85
198
|
// MCP App postMessage protocol (skipped silently in MCP-UI rawHtml mode)
|
|
@@ -113,6 +226,9 @@ ${initialDataScript}
|
|
|
113
226
|
else handlers.resolve(message.result);
|
|
114
227
|
return;
|
|
115
228
|
}
|
|
229
|
+
if (message.method === 'ui/notifications/tool-input' && message.params) {
|
|
230
|
+
fetchRouteFromDirectionsApi(message.params.arguments);
|
|
231
|
+
}
|
|
116
232
|
if (message.method === 'ui/notifications/tool-result' && message.params) {
|
|
117
233
|
handleToolResult(message.params);
|
|
118
234
|
}
|
|
@@ -176,29 +292,22 @@ ${initialDataScript}
|
|
|
176
292
|
initMap();
|
|
177
293
|
|
|
178
294
|
// -------------------------------------------------------------------------
|
|
179
|
-
// Initial data path (MCP-UI rawHtml):
|
|
180
|
-
//
|
|
295
|
+
// Initial data path (MCP-UI rawHtml): the tool call's input params were
|
|
296
|
+
// baked in server-side. Self-fetch the route from the Directions API
|
|
297
|
+
// rather than relying on baked-in geometry from the tool response.
|
|
181
298
|
// -------------------------------------------------------------------------
|
|
182
299
|
function consumeInitialData() {
|
|
183
300
|
var el = document.getElementById('initial-data');
|
|
184
301
|
if (!el || !el.textContent) return;
|
|
185
302
|
try {
|
|
186
303
|
var data = JSON.parse(el.textContent);
|
|
187
|
-
if (!data || !data.
|
|
188
|
-
|
|
189
|
-
var route = pickRouteGeometry({
|
|
190
|
-
geometry: data.geometry,
|
|
191
|
-
distance: data.distance,
|
|
192
|
-
duration: data.duration
|
|
193
|
-
});
|
|
194
|
-
if (route) {
|
|
195
|
-
if (data.summary) route.summary = data.summary;
|
|
196
|
-
drawRoute(route);
|
|
197
|
-
}
|
|
304
|
+
if (!data || !data.params) return;
|
|
305
|
+
fetchRouteFromDirectionsApi(data.params);
|
|
198
306
|
} catch (_) { /* ignore */ }
|
|
199
307
|
}
|
|
200
308
|
|
|
201
309
|
function handleToolResult(result) {
|
|
310
|
+
if (routeRendered) return;
|
|
202
311
|
var route = extractRoute(result);
|
|
203
312
|
if (route) {
|
|
204
313
|
renderRoute(route);
|
|
@@ -214,6 +323,7 @@ ${initialDataScript}
|
|
|
214
323
|
loadingEl.textContent = 'Fetching full route…';
|
|
215
324
|
sendRequest('resources/read', { uri: tempUri }).then(
|
|
216
325
|
function(rr) {
|
|
326
|
+
if (routeRendered) return;
|
|
217
327
|
var fetched = readResourceJson(rr);
|
|
218
328
|
var fetchedRoute = fetched ? extractRoute({ structuredContent: fetched }) : null;
|
|
219
329
|
if (fetchedRoute) {
|
|
@@ -223,16 +333,23 @@ ${initialDataScript}
|
|
|
223
333
|
}
|
|
224
334
|
},
|
|
225
335
|
function(err) {
|
|
336
|
+
if (routeRendered) return;
|
|
226
337
|
showError('Could not read temporary resource: ' + (err && err.message ? err.message : err));
|
|
227
338
|
}
|
|
228
339
|
);
|
|
229
340
|
return;
|
|
230
341
|
}
|
|
231
342
|
|
|
343
|
+
// Self-fetch (kicked off by the earlier tool-input notification) is
|
|
344
|
+
// either still in flight or already reported its own error via its
|
|
345
|
+
// .catch() handler — either way, this isn't the right error to show.
|
|
346
|
+
if (selfFetchStarted) return;
|
|
347
|
+
|
|
232
348
|
showError('Could not find route data in tool result.');
|
|
233
349
|
}
|
|
234
350
|
|
|
235
351
|
function renderRoute(route) {
|
|
352
|
+
routeRendered = true;
|
|
236
353
|
if (route.summary) {
|
|
237
354
|
summaryEl.textContent = route.summary;
|
|
238
355
|
summaryEl.style.display = 'block';
|
|
@@ -388,6 +505,8 @@ ${initialDataScript}
|
|
|
388
505
|
return;
|
|
389
506
|
}
|
|
390
507
|
|
|
508
|
+
errorEl.style.display = 'none';
|
|
509
|
+
|
|
391
510
|
if (route.summary && summaryEl.style.display === 'none') {
|
|
392
511
|
summaryEl.textContent = route.summary;
|
|
393
512
|
summaryEl.style.display = 'block';
|