@mapbox/mcp-server 0.15.1 → 0.16.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/dist/commonjs/resources/place-photo/PlacePhotoResource.d.ts +57 -0
- package/dist/commonjs/resources/place-photo/PlacePhotoResource.d.ts.map +1 -0
- package/dist/commonjs/resources/place-photo/PlacePhotoResource.js +202 -0
- package/dist/commonjs/resources/place-photo/PlacePhotoResource.js.map +1 -0
- package/dist/commonjs/resources/resourceRegistry.d.ts +3 -1
- package/dist/commonjs/resources/resourceRegistry.d.ts.map +1 -1
- package/dist/commonjs/resources/resourceRegistry.js +5 -0
- package/dist/commonjs/resources/resourceRegistry.js.map +1 -1
- package/dist/commonjs/resources/tool-response/ToolResponseResource.d.ts +20 -0
- package/dist/commonjs/resources/tool-response/ToolResponseResource.d.ts.map +1 -0
- package/dist/commonjs/resources/tool-response/ToolResponseResource.js +83 -0
- package/dist/commonjs/resources/tool-response/ToolResponseResource.js.map +1 -0
- package/dist/commonjs/resources/ui-apps/mapAppHtml.d.ts.map +1 -1
- package/dist/commonjs/resources/ui-apps/mapAppHtml.js +484 -11
- package/dist/commonjs/resources/ui-apps/mapAppHtml.js.map +1 -1
- package/dist/commonjs/tools/category-list-tool/CategoryListTool.d.ts.map +1 -1
- package/dist/commonjs/tools/category-list-tool/CategoryListTool.input.schema.js +1 -1
- package/dist/commonjs/tools/category-list-tool/CategoryListTool.input.schema.js.map +1 -1
- package/dist/commonjs/tools/category-list-tool/CategoryListTool.js +1 -1
- package/dist/commonjs/tools/category-list-tool/CategoryListTool.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.js +3 -3
- package/dist/commonjs/tools/directions-tool/DirectionsTool.input.schema.js.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.js +17 -17
- package/dist/commonjs/tools/directions-tool/DirectionsTool.js.map +1 -1
- package/dist/commonjs/tools/ground-location-tool/GroundLocationTool.d.ts.map +1 -1
- package/dist/commonjs/tools/ground-location-tool/GroundLocationTool.js +1 -1
- package/dist/commonjs/tools/ground-location-tool/GroundLocationTool.js.map +1 -1
- package/dist/commonjs/tools/isochrone-tool/IsochroneTool.d.ts.map +1 -1
- package/dist/commonjs/tools/isochrone-tool/IsochroneTool.js +6 -13
- package/dist/commonjs/tools/isochrone-tool/IsochroneTool.js.map +1 -1
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.d.ts.map +1 -1
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.input.schema.d.ts +4 -0
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.input.schema.d.ts.map +1 -1
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.input.schema.js +18 -2
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.input.schema.js.map +1 -1
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.js +9 -5
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.js.map +1 -1
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.output.schema.d.ts +4 -0
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.output.schema.d.ts.map +1 -1
- package/dist/commonjs/utils/directionsRef.d.ts +27 -0
- package/dist/commonjs/utils/directionsRef.d.ts.map +1 -0
- package/dist/commonjs/utils/directionsRef.js +52 -0
- package/dist/commonjs/utils/directionsRef.js.map +1 -0
- package/dist/commonjs/utils/index.d.ts +6 -0
- package/dist/commonjs/utils/index.d.ts.map +1 -1
- package/dist/commonjs/utils/index.js +14 -1
- package/dist/commonjs/utils/index.js.map +1 -1
- package/dist/commonjs/utils/mapAppPayload.d.ts +21 -0
- package/dist/commonjs/utils/mapAppPayload.d.ts.map +1 -1
- package/dist/commonjs/utils/mapAppPayload.js +5 -1
- package/dist/commonjs/utils/mapAppPayload.js.map +1 -1
- package/dist/commonjs/utils/responseRef.d.ts +33 -0
- package/dist/commonjs/utils/responseRef.d.ts.map +1 -0
- package/dist/commonjs/utils/responseRef.js +73 -0
- package/dist/commonjs/utils/responseRef.js.map +1 -0
- package/dist/commonjs/utils/serverInstructions.d.ts +2 -2
- package/dist/commonjs/utils/serverInstructions.js +2 -2
- package/dist/commonjs/utils/storeMapPayload.js +1 -1
- package/dist/commonjs/utils/storeMapPayload.js.map +1 -1
- package/dist/commonjs/utils/urlSafety.d.ts +6 -0
- package/dist/commonjs/utils/urlSafety.d.ts.map +1 -1
- package/dist/commonjs/utils/urlSafety.js +15 -4
- package/dist/commonjs/utils/urlSafety.js.map +1 -1
- package/dist/commonjs/version.json +3 -3
- package/dist/esm/resources/place-photo/PlacePhotoResource.d.ts +57 -0
- package/dist/esm/resources/place-photo/PlacePhotoResource.d.ts.map +1 -0
- package/dist/esm/resources/place-photo/PlacePhotoResource.js +198 -0
- package/dist/esm/resources/place-photo/PlacePhotoResource.js.map +1 -0
- package/dist/esm/resources/resourceRegistry.d.ts +3 -1
- package/dist/esm/resources/resourceRegistry.d.ts.map +1 -1
- package/dist/esm/resources/resourceRegistry.js +5 -0
- package/dist/esm/resources/resourceRegistry.js.map +1 -1
- package/dist/esm/resources/tool-response/ToolResponseResource.d.ts +20 -0
- package/dist/esm/resources/tool-response/ToolResponseResource.d.ts.map +1 -0
- package/dist/esm/resources/tool-response/ToolResponseResource.js +79 -0
- package/dist/esm/resources/tool-response/ToolResponseResource.js.map +1 -0
- package/dist/esm/resources/ui-apps/mapAppHtml.d.ts.map +1 -1
- package/dist/esm/resources/ui-apps/mapAppHtml.js +484 -11
- package/dist/esm/resources/ui-apps/mapAppHtml.js.map +1 -1
- package/dist/esm/tools/category-list-tool/CategoryListTool.d.ts.map +1 -1
- package/dist/esm/tools/category-list-tool/CategoryListTool.input.schema.js +1 -1
- package/dist/esm/tools/category-list-tool/CategoryListTool.input.schema.js.map +1 -1
- package/dist/esm/tools/category-list-tool/CategoryListTool.js +1 -1
- package/dist/esm/tools/category-list-tool/CategoryListTool.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.js +3 -3
- package/dist/esm/tools/directions-tool/DirectionsTool.input.schema.js.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.js +17 -17
- package/dist/esm/tools/directions-tool/DirectionsTool.js.map +1 -1
- package/dist/esm/tools/ground-location-tool/GroundLocationTool.d.ts.map +1 -1
- package/dist/esm/tools/ground-location-tool/GroundLocationTool.js +1 -1
- package/dist/esm/tools/ground-location-tool/GroundLocationTool.js.map +1 -1
- package/dist/esm/tools/isochrone-tool/IsochroneTool.d.ts.map +1 -1
- package/dist/esm/tools/isochrone-tool/IsochroneTool.js +6 -13
- package/dist/esm/tools/isochrone-tool/IsochroneTool.js.map +1 -1
- package/dist/esm/tools/render-map-tool/RenderMapTool.d.ts.map +1 -1
- package/dist/esm/tools/render-map-tool/RenderMapTool.input.schema.d.ts +4 -0
- package/dist/esm/tools/render-map-tool/RenderMapTool.input.schema.d.ts.map +1 -1
- package/dist/esm/tools/render-map-tool/RenderMapTool.input.schema.js +18 -2
- package/dist/esm/tools/render-map-tool/RenderMapTool.input.schema.js.map +1 -1
- package/dist/esm/tools/render-map-tool/RenderMapTool.js +9 -5
- package/dist/esm/tools/render-map-tool/RenderMapTool.js.map +1 -1
- package/dist/esm/tools/render-map-tool/RenderMapTool.output.schema.d.ts +4 -0
- package/dist/esm/tools/render-map-tool/RenderMapTool.output.schema.d.ts.map +1 -1
- package/dist/esm/utils/directionsRef.d.ts +27 -0
- package/dist/esm/utils/directionsRef.d.ts.map +1 -0
- package/dist/esm/utils/directionsRef.js +49 -0
- package/dist/esm/utils/directionsRef.js.map +1 -0
- package/dist/esm/utils/index.d.ts +6 -0
- package/dist/esm/utils/index.d.ts.map +1 -1
- package/dist/esm/utils/index.js +9 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/mapAppPayload.d.ts +21 -0
- package/dist/esm/utils/mapAppPayload.d.ts.map +1 -1
- package/dist/esm/utils/mapAppPayload.js +5 -1
- package/dist/esm/utils/mapAppPayload.js.map +1 -1
- package/dist/esm/utils/responseRef.d.ts +33 -0
- package/dist/esm/utils/responseRef.d.ts.map +1 -0
- package/dist/esm/utils/responseRef.js +68 -0
- package/dist/esm/utils/responseRef.js.map +1 -0
- package/dist/esm/utils/serverInstructions.d.ts +2 -2
- package/dist/esm/utils/serverInstructions.js +2 -2
- package/dist/esm/utils/storeMapPayload.js +1 -1
- package/dist/esm/utils/storeMapPayload.js.map +1 -1
- package/dist/esm/utils/urlSafety.d.ts +6 -0
- package/dist/esm/utils/urlSafety.d.ts.map +1 -1
- package/dist/esm/utils/urlSafety.js +14 -4
- package/dist/esm/utils/urlSafety.js.map +1 -1
- package/dist/esm/version.json +3 -3
- package/package.json +9 -2
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
// Copyright (c) Mapbox, Inc.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import { lookup } from 'node:dns/promises';
|
|
4
|
+
import { MapboxApiBasedResource } from '../MapboxApiBasedResource.js';
|
|
5
|
+
import { isPublicIpAddress, parseSafeExternalUrl } from '../../utils/urlSafety.js';
|
|
6
|
+
const URI_PREFIX = 'mapbox://place-photo/';
|
|
7
|
+
/**
|
|
8
|
+
* Largest photo the resource returns; bigger ones are treated as missing.
|
|
9
|
+
* Place Details photos are full-size originals: Union Square's ran 100 to
|
|
10
|
+
* 600 KB, so a smaller cap would drop most of them.
|
|
11
|
+
*/
|
|
12
|
+
export const MAX_PLACE_PHOTO_BYTES = 1024 * 1024;
|
|
13
|
+
/**
|
|
14
|
+
* The cache is shared by everyone using the server process, so it's capped
|
|
15
|
+
* by size (base64, as stored) as well as by entries.
|
|
16
|
+
*/
|
|
17
|
+
export const MAX_PLACE_PHOTO_CACHE_BYTES = 20 * 1024 * 1024;
|
|
18
|
+
const PHOTO_FETCH_TIMEOUT_MS = 5000;
|
|
19
|
+
const CACHE_TTL_MS = 30 * 60 * 1000;
|
|
20
|
+
const CACHE_MAX_ENTRIES = 200;
|
|
21
|
+
// Raster types an <img> or CSS background can show. SVG is left out: it's a
|
|
22
|
+
// document that can carry script, and thumbnails never need it.
|
|
23
|
+
const ALLOWED_TYPES = new Set([
|
|
24
|
+
'image/jpeg',
|
|
25
|
+
'image/png',
|
|
26
|
+
'image/webp',
|
|
27
|
+
'image/gif'
|
|
28
|
+
]);
|
|
29
|
+
const lookupAll = async (hostname) => (await lookup(hostname, { all: true })).map((a) => a.address);
|
|
30
|
+
/**
|
|
31
|
+
* A POI's first Place Details photo, proxied through the server for the map
|
|
32
|
+
* app's results panel.
|
|
33
|
+
*
|
|
34
|
+
* Place Details photos are hosted wherever the business's own site hosts
|
|
35
|
+
* them (Yext, Webflow and so on), so the map app's CSP can't list their
|
|
36
|
+
* hosts, and allowing any https: host would also allow scripts from
|
|
37
|
+
* anywhere. Instead the page reads this resource through the host
|
|
38
|
+
* (`resources/read`) and shows the image as a `data:` URL.
|
|
39
|
+
*
|
|
40
|
+
* The URI carries only a mapbox_id, never a URL: the server looks the place
|
|
41
|
+
* up itself and fetches the photo URL Place Details returns, so the page
|
|
42
|
+
* can't point the server at arbitrary hosts.
|
|
43
|
+
*/
|
|
44
|
+
export class PlacePhotoResource extends MapboxApiBasedResource {
|
|
45
|
+
uri = `${URI_PREFIX}{id}`;
|
|
46
|
+
name = 'Mapbox Place Photo';
|
|
47
|
+
description = "The first photo of a POI from Place Details, as an image, for the map app's results panel. " +
|
|
48
|
+
'Read with mapbox://place-photo/{mapbox_id}.';
|
|
49
|
+
mimeType = 'image/jpeg';
|
|
50
|
+
cache = new Map();
|
|
51
|
+
cacheBytes = 0;
|
|
52
|
+
lookupHost;
|
|
53
|
+
constructor(params) {
|
|
54
|
+
super(params);
|
|
55
|
+
this.lookupHost = params.lookupHost ?? lookupAll;
|
|
56
|
+
}
|
|
57
|
+
async execute(uri, accessToken) {
|
|
58
|
+
const id = decodeURIComponent(uri.slice(URI_PREFIX.length));
|
|
59
|
+
if (!isPlacesApiId(id)) {
|
|
60
|
+
throw new Error('Not a Places API mapbox_id');
|
|
61
|
+
}
|
|
62
|
+
const photo = await this.getPhoto(id, accessToken);
|
|
63
|
+
if (!photo) {
|
|
64
|
+
return {
|
|
65
|
+
contents: [{ uri, mimeType: 'text/plain', text: 'No photo available' }]
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
contents: [{ uri, mimeType: photo.mimeType, blob: photo.base64 }]
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
async getPhoto(id, accessToken) {
|
|
73
|
+
const now = Date.now();
|
|
74
|
+
const cached = this.cache.get(id);
|
|
75
|
+
if (cached && cached.expires > now)
|
|
76
|
+
return cached.photo;
|
|
77
|
+
const photo = await this.fetchPhoto(id, accessToken);
|
|
78
|
+
// Places are public data, so one cache serves every caller. Misses are
|
|
79
|
+
// cached too, so a place without a photo isn't looked up on every render.
|
|
80
|
+
this.evict(id);
|
|
81
|
+
const size = photo?.base64.length ?? 0;
|
|
82
|
+
while (this.cache.size > 0 &&
|
|
83
|
+
(this.cache.size >= CACHE_MAX_ENTRIES ||
|
|
84
|
+
this.cacheBytes + size > MAX_PLACE_PHOTO_CACHE_BYTES)) {
|
|
85
|
+
this.evict(this.cache.keys().next().value);
|
|
86
|
+
}
|
|
87
|
+
this.cache.set(id, { expires: now + CACHE_TTL_MS, photo });
|
|
88
|
+
this.cacheBytes += size;
|
|
89
|
+
return photo;
|
|
90
|
+
}
|
|
91
|
+
evict(id) {
|
|
92
|
+
const entry = this.cache.get(id);
|
|
93
|
+
if (!entry)
|
|
94
|
+
return;
|
|
95
|
+
this.cacheBytes -= entry.photo?.base64.length ?? 0;
|
|
96
|
+
this.cache.delete(id);
|
|
97
|
+
}
|
|
98
|
+
async fetchPhoto(id, accessToken) {
|
|
99
|
+
const detailsUrl = new URL(`${MapboxApiBasedResource.mapboxApiEndpoint}places/v1/details/retrieve/${encodeURIComponent(id)}`);
|
|
100
|
+
detailsUrl.searchParams.append('access_token', accessToken);
|
|
101
|
+
const details = await this.httpRequest(detailsUrl.toString());
|
|
102
|
+
if (!details.ok)
|
|
103
|
+
return null;
|
|
104
|
+
const data = (await details.json());
|
|
105
|
+
const photoUrl = data.photos?.find((p) => typeof p?.url === 'string')
|
|
106
|
+
?.url;
|
|
107
|
+
if (!photoUrl || !(await this.isPublicPhotoUrl(photoUrl)))
|
|
108
|
+
return null;
|
|
109
|
+
let response;
|
|
110
|
+
try {
|
|
111
|
+
response = await this.httpRequest(photoUrl, {
|
|
112
|
+
// A redirect could lead anywhere, including hosts isPublicHttpsUrl
|
|
113
|
+
// would have rejected, so treat it as no photo.
|
|
114
|
+
redirect: 'manual',
|
|
115
|
+
signal: AbortSignal.timeout(PHOTO_FETCH_TIMEOUT_MS)
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
if (response.status !== 200)
|
|
122
|
+
return null;
|
|
123
|
+
const mimeType = (response.headers?.get('content-type') ?? '')
|
|
124
|
+
.split(';')[0]
|
|
125
|
+
.trim()
|
|
126
|
+
.toLowerCase();
|
|
127
|
+
if (!ALLOWED_TYPES.has(mimeType))
|
|
128
|
+
return null;
|
|
129
|
+
const declared = Number(response.headers?.get('content-length'));
|
|
130
|
+
if (declared > MAX_PLACE_PHOTO_BYTES)
|
|
131
|
+
return null;
|
|
132
|
+
const bytes = await readCapped(response, MAX_PLACE_PHOTO_BYTES);
|
|
133
|
+
if (!bytes || bytes.length === 0)
|
|
134
|
+
return null;
|
|
135
|
+
return { mimeType, base64: bytes.toString('base64') };
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* https on the default port, a public DNS name (not an IP literal or a
|
|
139
|
+
* local name), and every address it resolves to public, so a bad photo
|
|
140
|
+
* URL in the data can't make the server request something on its own
|
|
141
|
+
* network. The fetch resolves the name again, so a host that changes its
|
|
142
|
+
* answer in between can still get through; the request can't be read
|
|
143
|
+
* back either way (no redirects, image types only).
|
|
144
|
+
*/
|
|
145
|
+
async isPublicPhotoUrl(value) {
|
|
146
|
+
const url = parseSafeExternalUrl(value);
|
|
147
|
+
if (!url || url.username || url.password)
|
|
148
|
+
return false;
|
|
149
|
+
if (url.port && url.port !== '443')
|
|
150
|
+
return false;
|
|
151
|
+
const host = url.hostname;
|
|
152
|
+
if (host.startsWith('[') || isIpv4Literal(host))
|
|
153
|
+
return false;
|
|
154
|
+
try {
|
|
155
|
+
const addresses = await this.lookupHost(host);
|
|
156
|
+
return addresses.length > 0 && addresses.every(isPublicIpAddress);
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function isIpv4Literal(host) {
|
|
164
|
+
return /^[\d.]+$/.test(host);
|
|
165
|
+
}
|
|
166
|
+
/** Reads a body, giving up (null) as soon as it passes `limit` bytes. */
|
|
167
|
+
async function readCapped(response, limit) {
|
|
168
|
+
const reader = response.body?.getReader();
|
|
169
|
+
if (!reader) {
|
|
170
|
+
const whole = Buffer.from(await response.arrayBuffer());
|
|
171
|
+
return whole.length > limit ? null : whole;
|
|
172
|
+
}
|
|
173
|
+
const chunks = [];
|
|
174
|
+
let total = 0;
|
|
175
|
+
for (;;) {
|
|
176
|
+
const { done, value } = await reader.read();
|
|
177
|
+
if (done)
|
|
178
|
+
break;
|
|
179
|
+
total += value.byteLength;
|
|
180
|
+
if (total > limit) {
|
|
181
|
+
await reader.cancel().catch(() => { });
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
chunks.push(value);
|
|
185
|
+
}
|
|
186
|
+
return Buffer.concat(chunks);
|
|
187
|
+
}
|
|
188
|
+
const PLACES_ID = /^urn:mbxpoi:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
189
|
+
/**
|
|
190
|
+
* Native Places ids decode to "urn:mbxpoi:<uuid>". Others, including
|
|
191
|
+
* OSM-sourced ids and "urn:mbxpoi:mapbox-n<id>", 422 the API.
|
|
192
|
+
*/
|
|
193
|
+
function isPlacesApiId(id) {
|
|
194
|
+
if (!/^[A-Za-z0-9+/_=-]{8,200}$/.test(id))
|
|
195
|
+
return false;
|
|
196
|
+
return PLACES_ID.test(Buffer.from(id, 'base64').toString('utf8'));
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=PlacePhotoResource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlacePhotoResource.js","sourceRoot":"","sources":["../../../../src/resources/place-photo/PlacePhotoResource.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAElC,MAAM,UAAU,GAAG,uBAAuB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5D,MAAM,sBAAsB,GAAG,IAAI,CAAC;AACpC,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACpC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B,4EAA4E;AAC5E,gEAAgE;AAChE,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,WAAW;CACZ,CAAC,CAAC;AAUH,MAAM,SAAS,GAAe,KAAK,EAAE,QAAQ,EAAE,EAAE,CAC/C,CAAC,MAAM,MAAM,CAAC,QAAQ,EAAE,EAAE,GA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U;IAC/B,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,EAAE,CAAC;QAAE,OAAO,KAAK,CAAC;IACxD,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -2,9 +2,11 @@ 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 { ToolResponseResource } from './tool-response/ToolResponseResource.js';
|
|
5
6
|
import { MapAppUIResource } from './ui-apps/MapAppUIResource.js';
|
|
6
7
|
import { VersionResource } from './version/VersionResource.js';
|
|
7
|
-
|
|
8
|
+
import { PlacePhotoResource } from './place-photo/PlacePhotoResource.js';
|
|
9
|
+
export declare const ALL_RESOURCES: readonly [CategoryListResource, TemporaryDataResource, ComputeResource, InlinePayloadResource, ToolResponseResource, MapAppUIResource, PlacePhotoResource, VersionResource];
|
|
8
10
|
export type ResourceInstance = (typeof ALL_RESOURCES)[number];
|
|
9
11
|
export declare function getAllResources(): readonly ResourceInstance[];
|
|
10
12
|
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,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;
|
|
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,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAIzE,eAAO,MAAM,aAAa,6KAYhB,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"}
|
|
@@ -5,8 +5,10 @@ import { CategoryListResource } from './category-list/CategoryListResource.js';
|
|
|
5
5
|
import { TemporaryDataResource } from './temporary/TemporaryDataResource.js';
|
|
6
6
|
import { ComputeResource } from './compute/ComputeResource.js';
|
|
7
7
|
import { InlinePayloadResource } from './inline-payload/InlinePayloadResource.js';
|
|
8
|
+
import { ToolResponseResource } from './tool-response/ToolResponseResource.js';
|
|
8
9
|
import { MapAppUIResource } from './ui-apps/MapAppUIResource.js';
|
|
9
10
|
import { VersionResource } from './version/VersionResource.js';
|
|
11
|
+
import { PlacePhotoResource } from './place-photo/PlacePhotoResource.js';
|
|
10
12
|
import { httpRequest } from '../utils/httpPipeline.js';
|
|
11
13
|
// Central registry of all resources
|
|
12
14
|
export const ALL_RESOURCES = [
|
|
@@ -15,8 +17,11 @@ export const ALL_RESOURCES = [
|
|
|
15
17
|
new TemporaryDataResource(),
|
|
16
18
|
new ComputeResource(),
|
|
17
19
|
new InlinePayloadResource(),
|
|
20
|
+
new ToolResponseResource({ httpRequest }),
|
|
18
21
|
// Single shared map renderer, targeted exclusively by render_map_tool.
|
|
19
22
|
new MapAppUIResource({ httpRequest }),
|
|
23
|
+
// Photos for the map app's results panel, which its CSP can't load directly.
|
|
24
|
+
new PlacePhotoResource({ httpRequest }),
|
|
20
25
|
new VersionResource()
|
|
21
26
|
];
|
|
22
27
|
export function getAllResources() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceRegistry.js","sourceRoot":"","sources":["../../../src/resources/resourceRegistry.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAElC,kCAAkC;AAClC,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;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,oCAAoC;AACpC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,oCAAoC;IACpC,IAAI,oBAAoB,CAAC,EAAE,WAAW,EAAE,CAAC;IACzC,IAAI,qBAAqB,EAAE;IAC3B,IAAI,eAAe,EAAE;IACrB,IAAI,qBAAqB,EAAE;IAC3B,uEAAuE;IACvE,IAAI,gBA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,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;QAC3C,OAAO,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReadResourceResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { MapboxApiBasedResource } from '../MapboxApiBasedResource.js';
|
|
3
|
+
import type { HttpRequest } from '../../utils/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Full `directions_tool` / `isochrone_tool` responses that were too large
|
|
6
|
+
* to return inline. The `mapbox://response/{tool}?data=...` ref carries the
|
|
7
|
+
* call's inputs (see responseRef.ts), and reading it runs the same request
|
|
8
|
+
* again with the reader's token, so any server process can answer it.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ToolResponseResource extends MapboxApiBasedResource {
|
|
11
|
+
readonly name = "Full Tool Response";
|
|
12
|
+
readonly uri = "mapbox://response/{spec}";
|
|
13
|
+
readonly description = "The full response of a directions_tool or isochrone_tool call that was too large to return inline, fetched again from its ref.";
|
|
14
|
+
readonly mimeType = "application/json";
|
|
15
|
+
constructor(params: {
|
|
16
|
+
httpRequest: HttpRequest;
|
|
17
|
+
});
|
|
18
|
+
protected execute(uri: string, accessToken: string): Promise<ReadResourceResult>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ToolResponseResource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolResponseResource.d.ts","sourceRoot":"","sources":["../../../../src/resources/tool-response/ToolResponseResource.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AASxD;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,sBAAsB;IAC9D,QAAQ,CAAC,IAAI,wBAAwB;IACrC,QAAQ,CAAC,GAAG,8BAA8B;IAC1C,QAAQ,CAAC,WAAW,oIAC+G;IACnI,QAAQ,CAAC,QAAQ,sBAAsB;gBAE3B,MAAM,EAAE;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE;cAIhC,OAAO,CACrB,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC;CAgE/B"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Copyright (c) Mapbox, Inc.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import { MapboxApiBasedResource } from '../MapboxApiBasedResource.js';
|
|
4
|
+
import { resolveResponseRef } from '../../utils/responseRef.js';
|
|
5
|
+
import { DirectionsInputSchema } from '../../tools/directions-tool/DirectionsTool.input.schema.js';
|
|
6
|
+
import { buildDirectionsRequestUrl } from '../../tools/directions-tool/buildDirectionsRequestUrl.js';
|
|
7
|
+
import { cleanResponseData } from '../../tools/directions-tool/cleanResponseData.js';
|
|
8
|
+
import { IsochroneInputSchema } from '../../tools/isochrone-tool/IsochroneTool.input.schema.js';
|
|
9
|
+
import { buildIsochroneRequestUrl } from '../../tools/isochrone-tool/buildIsochroneRequestUrl.js';
|
|
10
|
+
/**
|
|
11
|
+
* Full `directions_tool` / `isochrone_tool` responses that were too large
|
|
12
|
+
* to return inline. The `mapbox://response/{tool}?data=...` ref carries the
|
|
13
|
+
* call's inputs (see responseRef.ts), and reading it runs the same request
|
|
14
|
+
* again with the reader's token, so any server process can answer it.
|
|
15
|
+
*/
|
|
16
|
+
export class ToolResponseResource extends MapboxApiBasedResource {
|
|
17
|
+
name = 'Full Tool Response';
|
|
18
|
+
uri = 'mapbox://response/{spec}';
|
|
19
|
+
description = 'The full response of a directions_tool or isochrone_tool call that was too large to return inline, fetched again from its ref.';
|
|
20
|
+
mimeType = 'application/json';
|
|
21
|
+
constructor(params) {
|
|
22
|
+
super(params);
|
|
23
|
+
}
|
|
24
|
+
async execute(uri, accessToken) {
|
|
25
|
+
const spec = resolveResponseRef(uri);
|
|
26
|
+
const apiEndpoint = MapboxApiBasedResource.mapboxApiEndpoint;
|
|
27
|
+
let url = null;
|
|
28
|
+
let directionsInput = null;
|
|
29
|
+
if (spec?.tool === 'directions') {
|
|
30
|
+
const parsed = DirectionsInputSchema.safeParse(spec.input);
|
|
31
|
+
if (parsed.success) {
|
|
32
|
+
directionsInput = parsed.data;
|
|
33
|
+
url = buildDirectionsRequestUrl({
|
|
34
|
+
input: parsed.data,
|
|
35
|
+
accessToken,
|
|
36
|
+
apiEndpoint
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else if (spec?.tool === 'isochrone') {
|
|
41
|
+
const parsed = IsochroneInputSchema.safeParse(spec.input);
|
|
42
|
+
if (parsed.success &&
|
|
43
|
+
(parsed.data.contours_minutes || parsed.data.contours_meters)) {
|
|
44
|
+
url = buildIsochroneRequestUrl({
|
|
45
|
+
input: parsed.data,
|
|
46
|
+
accessToken,
|
|
47
|
+
apiEndpoint
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!url) {
|
|
52
|
+
return text(uri, 'Response ref was malformed or unsupported.');
|
|
53
|
+
}
|
|
54
|
+
const response = await this.httpRequest(url);
|
|
55
|
+
if (!response.ok) {
|
|
56
|
+
return text(uri, `Fetching the full response failed: ${response.status} ${response.statusText}`);
|
|
57
|
+
}
|
|
58
|
+
let data = await response.json();
|
|
59
|
+
if (directionsInput) {
|
|
60
|
+
// The same cast DirectionsTool makes on its own response.
|
|
61
|
+
let cleaned = cleanResponseData(directionsInput, data);
|
|
62
|
+
// Same route the user picked when the original call was made.
|
|
63
|
+
const index = spec?.selectedRouteIndex;
|
|
64
|
+
if (index !== undefined && cleaned.routes?.[index]) {
|
|
65
|
+
cleaned = { ...cleaned, routes: [cleaned.routes[index]] };
|
|
66
|
+
}
|
|
67
|
+
data = cleaned;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
contents: [
|
|
71
|
+
{ uri, mimeType: this.mimeType, text: JSON.stringify(data, null, 2) }
|
|
72
|
+
]
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function text(uri, message) {
|
|
77
|
+
return { contents: [{ uri, mimeType: 'text/plain', text: message }] };
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=ToolResponseResource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolResponseResource.js","sourceRoot":"","sources":["../../../../src/resources/tool-response/ToolResponseResource.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAGlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4DAA4D,CAAC;AACnG,OAAO,EAAE,yBAAyB,EAAE,MAAM,0DAA0D,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AAErF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0DAA0D,CAAC;AAChG,OAAO,EAAE,wBAAwB,EAAE,MAAM,wDAAwD,CAAC;AAElG;;;;;GAKG;AACH,MAAM,OAAO,oBAAqB,SAAQ,sBAAsB;IACrD,IAAI,GAAG,oBAAoB,CAAC;IAC5B,GAAG,GAAG,0BAA0B,CAAC;IACjC,WAAW,GAClB,gIAAgI,CAAC;IAC1H,QAAQ,GAAG,kBAAkB,CAAC;IAEvC,YAAY,MAAoC;QAC9C,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAES,KAAK,CAAC,OAAO,CACrB,GAAW,EACX,WAAmB;QAEnB,MAAM,IAAI,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;QACrC,MAAM,WAAW,GAAG,sBAAsB,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AAC;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,CAomET"}
|