@mapbox/mcp-server 0.17.0-dev → 0.17.0-dev.2
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/BaseResource.d.ts +7 -0
- package/dist/commonjs/resources/BaseResource.d.ts.map +1 -1
- package/dist/commonjs/resources/BaseResource.js +13 -2
- package/dist/commonjs/resources/BaseResource.js.map +1 -1
- package/dist/commonjs/resources/category-list/CategoryListResource.d.ts +7 -2
- package/dist/commonjs/resources/category-list/CategoryListResource.d.ts.map +1 -1
- package/dist/commonjs/resources/category-list/CategoryListResource.js +14 -4
- package/dist/commonjs/resources/category-list/CategoryListResource.js.map +1 -1
- package/dist/commonjs/resources/place-photo/PlacePhotoResource.d.ts +1 -1
- package/dist/commonjs/resources/place-photo/PlacePhotoResource.js +2 -2
- package/dist/commonjs/resources/place-photo/PlacePhotoResource.js.map +1 -1
- package/dist/commonjs/resources/resourceRegistry.d.ts +2 -1
- package/dist/commonjs/resources/resourceRegistry.d.ts.map +1 -1
- package/dist/commonjs/resources/resourceRegistry.js +10 -5
- package/dist/commonjs/resources/resourceRegistry.js.map +1 -1
- package/dist/commonjs/resources/tool-response/ToolResponseResource.d.ts +6 -5
- package/dist/commonjs/resources/tool-response/ToolResponseResource.d.ts.map +1 -1
- package/dist/commonjs/resources/tool-response/ToolResponseResource.js +29 -5
- package/dist/commonjs/resources/tool-response/ToolResponseResource.js.map +1 -1
- package/dist/commonjs/resources/ui-apps/StaticMapViewerUIResource.d.ts +28 -0
- package/dist/commonjs/resources/ui-apps/StaticMapViewerUIResource.d.ts.map +1 -0
- package/dist/commonjs/resources/ui-apps/StaticMapViewerUIResource.js +64 -0
- package/dist/commonjs/resources/ui-apps/StaticMapViewerUIResource.js.map +1 -0
- package/dist/commonjs/resources/ui-apps/mapAppHtml.d.ts.map +1 -1
- package/dist/commonjs/resources/ui-apps/mapAppHtml.js +936 -223
- package/dist/commonjs/resources/ui-apps/mapAppHtml.js.map +1 -1
- package/dist/commonjs/resources/ui-apps/staticMapViewerHtml.d.ts +17 -0
- package/dist/commonjs/resources/ui-apps/staticMapViewerHtml.d.ts.map +1 -0
- package/dist/commonjs/resources/ui-apps/staticMapViewerHtml.js +180 -0
- package/dist/commonjs/resources/ui-apps/staticMapViewerHtml.js.map +1 -0
- 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 +1 -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 +10 -6
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.input.schema.js.map +1 -1
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.js +26 -12
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.js.map +1 -1
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.output.schema.d.ts +1 -0
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.output.schema.d.ts.map +1 -1
- package/dist/commonjs/tools/resource-reader-tool/ResourceReaderTool.d.ts.map +1 -1
- package/dist/commonjs/tools/resource-reader-tool/ResourceReaderTool.js +43 -9
- package/dist/commonjs/tools/resource-reader-tool/ResourceReaderTool.js.map +1 -1
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.d.ts +8 -1
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.js +113 -90
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
- package/dist/commonjs/tools/static-map-image-tool/buildStaticMapRequestUrl.d.ts +23 -0
- package/dist/commonjs/tools/static-map-image-tool/buildStaticMapRequestUrl.d.ts.map +1 -0
- package/dist/commonjs/tools/static-map-image-tool/buildStaticMapRequestUrl.js +84 -0
- package/dist/commonjs/tools/static-map-image-tool/buildStaticMapRequestUrl.js.map +1 -0
- package/dist/commonjs/utils/mapAppPayload.d.ts +15 -6
- package/dist/commonjs/utils/mapAppPayload.d.ts.map +1 -1
- package/dist/commonjs/utils/mapAppPayload.js +2 -1
- package/dist/commonjs/utils/mapAppPayload.js.map +1 -1
- package/dist/commonjs/utils/mapboxPublicToken.d.ts +5 -1
- package/dist/commonjs/utils/mapboxPublicToken.d.ts.map +1 -1
- package/dist/commonjs/utils/mapboxPublicToken.js +6 -1
- package/dist/commonjs/utils/mapboxPublicToken.js.map +1 -1
- package/dist/commonjs/utils/responseRef.d.ts +1 -1
- package/dist/commonjs/utils/responseRef.d.ts.map +1 -1
- package/dist/commonjs/utils/responseRef.js +1 -1
- package/dist/commonjs/utils/responseRef.js.map +1 -1
- package/dist/commonjs/version.json +3 -3
- package/dist/esm/resources/BaseResource.d.ts +7 -0
- package/dist/esm/resources/BaseResource.d.ts.map +1 -1
- package/dist/esm/resources/BaseResource.js +13 -2
- package/dist/esm/resources/BaseResource.js.map +1 -1
- package/dist/esm/resources/category-list/CategoryListResource.d.ts +7 -2
- package/dist/esm/resources/category-list/CategoryListResource.d.ts.map +1 -1
- package/dist/esm/resources/category-list/CategoryListResource.js +14 -4
- package/dist/esm/resources/category-list/CategoryListResource.js.map +1 -1
- package/dist/esm/resources/place-photo/PlacePhotoResource.d.ts +1 -1
- package/dist/esm/resources/place-photo/PlacePhotoResource.js +2 -2
- package/dist/esm/resources/place-photo/PlacePhotoResource.js.map +1 -1
- package/dist/esm/resources/resourceRegistry.d.ts +2 -1
- package/dist/esm/resources/resourceRegistry.d.ts.map +1 -1
- package/dist/esm/resources/resourceRegistry.js +10 -5
- package/dist/esm/resources/resourceRegistry.js.map +1 -1
- package/dist/esm/resources/tool-response/ToolResponseResource.d.ts +6 -5
- package/dist/esm/resources/tool-response/ToolResponseResource.d.ts.map +1 -1
- package/dist/esm/resources/tool-response/ToolResponseResource.js +29 -5
- package/dist/esm/resources/tool-response/ToolResponseResource.js.map +1 -1
- package/dist/esm/resources/ui-apps/StaticMapViewerUIResource.d.ts +28 -0
- package/dist/esm/resources/ui-apps/StaticMapViewerUIResource.d.ts.map +1 -0
- package/dist/esm/resources/ui-apps/StaticMapViewerUIResource.js +59 -0
- package/dist/esm/resources/ui-apps/StaticMapViewerUIResource.js.map +1 -0
- package/dist/esm/resources/ui-apps/mapAppHtml.d.ts.map +1 -1
- package/dist/esm/resources/ui-apps/mapAppHtml.js +936 -223
- package/dist/esm/resources/ui-apps/mapAppHtml.js.map +1 -1
- package/dist/esm/resources/ui-apps/staticMapViewerHtml.d.ts +17 -0
- package/dist/esm/resources/ui-apps/staticMapViewerHtml.d.ts.map +1 -0
- package/dist/esm/resources/ui-apps/staticMapViewerHtml.js +177 -0
- package/dist/esm/resources/ui-apps/staticMapViewerHtml.js.map +1 -0
- 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 +1 -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 +10 -6
- package/dist/esm/tools/render-map-tool/RenderMapTool.input.schema.js.map +1 -1
- package/dist/esm/tools/render-map-tool/RenderMapTool.js +26 -12
- package/dist/esm/tools/render-map-tool/RenderMapTool.js.map +1 -1
- package/dist/esm/tools/render-map-tool/RenderMapTool.output.schema.d.ts +1 -0
- package/dist/esm/tools/render-map-tool/RenderMapTool.output.schema.d.ts.map +1 -1
- package/dist/esm/tools/resource-reader-tool/ResourceReaderTool.d.ts.map +1 -1
- package/dist/esm/tools/resource-reader-tool/ResourceReaderTool.js +43 -9
- package/dist/esm/tools/resource-reader-tool/ResourceReaderTool.js.map +1 -1
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.d.ts +8 -1
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.js +114 -91
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
- package/dist/esm/tools/static-map-image-tool/buildStaticMapRequestUrl.d.ts +23 -0
- package/dist/esm/tools/static-map-image-tool/buildStaticMapRequestUrl.d.ts.map +1 -0
- package/dist/esm/tools/static-map-image-tool/buildStaticMapRequestUrl.js +78 -0
- package/dist/esm/tools/static-map-image-tool/buildStaticMapRequestUrl.js.map +1 -0
- package/dist/esm/utils/mapAppPayload.d.ts +15 -6
- package/dist/esm/utils/mapAppPayload.d.ts.map +1 -1
- package/dist/esm/utils/mapAppPayload.js +2 -1
- package/dist/esm/utils/mapAppPayload.js.map +1 -1
- package/dist/esm/utils/mapboxPublicToken.d.ts +5 -1
- package/dist/esm/utils/mapboxPublicToken.d.ts.map +1 -1
- package/dist/esm/utils/mapboxPublicToken.js +6 -1
- package/dist/esm/utils/mapboxPublicToken.js.map +1 -1
- package/dist/esm/utils/responseRef.d.ts +1 -1
- package/dist/esm/utils/responseRef.d.ts.map +1 -1
- package/dist/esm/utils/responseRef.js +1 -1
- package/dist/esm/utils/responseRef.js.map +1 -1
- package/dist/esm/version.json +3 -3
- package/package.json +1 -1
|
@@ -7,6 +7,12 @@ export declare abstract class BaseResource {
|
|
|
7
7
|
abstract readonly name: string;
|
|
8
8
|
abstract readonly description?: string;
|
|
9
9
|
abstract readonly mimeType?: string;
|
|
10
|
+
/**
|
|
11
|
+
* A URI template this resource also answers, next to its fixed `uri`
|
|
12
|
+
* (e.g. mapbox://categories/{language}). resources/read matches a fixed
|
|
13
|
+
* URI exactly, so variants of it need a template to be readable.
|
|
14
|
+
*/
|
|
15
|
+
readonly uriTemplate?: string;
|
|
10
16
|
/**
|
|
11
17
|
* The most recently installed server. Used as a fallback when `read()` is
|
|
12
18
|
* called directly rather than through a handler registered by `installTo()`.
|
|
@@ -30,6 +36,7 @@ export declare abstract class BaseResource {
|
|
|
30
36
|
* Installs the resource to the given MCP server.
|
|
31
37
|
*/
|
|
32
38
|
installTo(server: McpServer): void;
|
|
39
|
+
private registerTemplate;
|
|
33
40
|
/**
|
|
34
41
|
* Resource read logic to be implemented by subclasses.
|
|
35
42
|
* @param uri The resource URI as a string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseResource.d.ts","sourceRoot":"","sources":["../../../src/resources/BaseResource.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,aAAa,EACd,MAAM,8BAA8B,CAAC;AAEtC;;GAEG;AACH,8BAAsB,YAAY;IAChC,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseResource.d.ts","sourceRoot":"","sources":["../../../src/resources/BaseResource.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,aAAa,EACd,MAAM,8BAA8B,CAAC;AAEtC;;GAEG;AACH,8BAAsB,YAAY;IAChC,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAQ;IAE1C;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAsC;IAEvE;;;;OAIG;IACH,SAAS,KAAK,YAAY,IAAI,SAAS,GAAG,IAAI,CAE7C;IAED;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAkClC,OAAO,CAAC,gBAAgB;IAmBxB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,CACX,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,aAAa,GACpB,OAAO,CAAC,kBAAkB,CAAC;IAE9B;;OAEG;IACH,SAAS,CAAC,GAAG,CACX,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,EAC7C,IAAI,EAAE,OAAO,GACZ,IAAI;CAMR"}
|
|
@@ -9,6 +9,12 @@ const server_1 = require("@modelcontextprotocol/server");
|
|
|
9
9
|
* Base class for all MCP resources
|
|
10
10
|
*/
|
|
11
11
|
class BaseResource {
|
|
12
|
+
/**
|
|
13
|
+
* A URI template this resource also answers, next to its fixed `uri`
|
|
14
|
+
* (e.g. mapbox://categories/{language}). resources/read matches a fixed
|
|
15
|
+
* URI exactly, so variants of it need a template to be readable.
|
|
16
|
+
*/
|
|
17
|
+
uriTemplate;
|
|
12
18
|
/**
|
|
13
19
|
* The most recently installed server. Used as a fallback when `read()` is
|
|
14
20
|
* called directly rather than through a handler registered by `installTo()`.
|
|
@@ -43,12 +49,17 @@ class BaseResource {
|
|
|
43
49
|
if (this.uri.includes('{')) {
|
|
44
50
|
// URI contains template variables — register as a ResourceTemplate so the
|
|
45
51
|
// SDK performs proper URI template matching (e.g. mapbox://temp/{id}).
|
|
46
|
-
|
|
47
|
-
server.registerResource(this.name, template, metadata, (uri, _variables, ctx) => this.invocationServer.run(server, () => this.read(uri.toString(), ctx)));
|
|
52
|
+
this.registerTemplate(server, this.name, this.uri, metadata);
|
|
48
53
|
}
|
|
49
54
|
else {
|
|
50
55
|
server.registerResource(this.name, this.uri, metadata, (uri, ctx) => this.invocationServer.run(server, () => this.read(uri.toString(), ctx)));
|
|
51
56
|
}
|
|
57
|
+
if (this.uriTemplate) {
|
|
58
|
+
this.registerTemplate(server, `${this.name} (${this.uriTemplate})`, this.uriTemplate, metadata);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
registerTemplate(server, name, uriTemplate, metadata) {
|
|
62
|
+
server.registerResource(name, new server_1.ResourceTemplate(uriTemplate, { list: undefined }), metadata, (uri, _variables, ctx) => this.invocationServer.run(server, () => this.read(uri.toString(), ctx)));
|
|
52
63
|
}
|
|
53
64
|
/**
|
|
54
65
|
* Helper method to send logging messages
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseResource.js","sourceRoot":"","sources":["../../../src/resources/BaseResource.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAElC,uDAAqD;AACrD,yDAAgE;AAOhE;;GAEG;AACH,MAAsB,YAAY;
|
|
1
|
+
{"version":3,"file":"BaseResource.js","sourceRoot":"","sources":["../../../src/resources/BaseResource.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAElC,uDAAqD;AACrD,yDAAgE;AAOhE;;GAEG;AACH,MAAsB,YAAY;IAKhC;;;;OAIG;IACM,WAAW,CAAU;IAE9B;;;;;OAKG;IACO,MAAM,GAAqB,IAAI,CAAC;IAE1C;;;;OAIG;IACc,gBAAgB,GAAG,IAAI,oCAAiB,EAAa,CAAC;IAEvE;;;;OAIG;IACH,IAAc,YAAY;QACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,MAAiB;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,MAAM,QAAQ,GAAG;YACf,KAAK,EAAE,IAAI,CAAC,IAAI;YAChB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;QAEF,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ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ACjC,IAAI,MAAM,EAAE,MAAM,EAAE,CAAC;YACnB,KAAK,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;CACF;AAlHD,oCAkHC"}
|
|
@@ -10,8 +10,9 @@ import type { ReadResourceResult } from '@modelcontextprotocol/server';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class CategoryListResource extends MapboxApiBasedResource {
|
|
12
12
|
readonly uri = "mapbox://categories";
|
|
13
|
+
readonly uriTemplate = "mapbox://categories/{language}";
|
|
13
14
|
readonly name = "Mapbox Categories";
|
|
14
|
-
readonly description = "List of all available Mapbox Search API categories. Categories can be used for filtering search results. Supports localization via language parameter in URI (e.g., mapbox://categories/ja for Japanese).";
|
|
15
|
+
readonly description = "List of all available Mapbox Search API categories. Categories can be used for filtering search results. Supports localization via language parameter in URI (e.g., mapbox://categories/ja for Japanese). A language code the API does not support gets the default (English) list.";
|
|
15
16
|
readonly mimeType = "application/json";
|
|
16
17
|
constructor(params: {
|
|
17
18
|
httpRequest: HttpRequest;
|
|
@@ -20,7 +21,11 @@ export declare class CategoryListResource extends MapboxApiBasedResource {
|
|
|
20
21
|
/**
|
|
21
22
|
* Extract language code from URI
|
|
22
23
|
* @param uri Resource URI (e.g., mapbox://categories/ja)
|
|
23
|
-
* @returns Language code or undefined
|
|
24
|
+
* @returns Language code, or undefined for the default list
|
|
25
|
+
* @throws for anything after `mapbox://categories/` that isn't a language
|
|
26
|
+
* code (e.g. `%20ja` or `ja?x=1`), rather than quietly returning English.
|
|
27
|
+
* A well-formed code the API doesn't support (e.g. `xx`) still goes
|
|
28
|
+
* through: the API answers with its English list.
|
|
24
29
|
*/
|
|
25
30
|
private extractLanguageFromUri;
|
|
26
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoryListResource.d.ts","sourceRoot":"","sources":["../../../../src/resources/category-list/CategoryListResource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAiBvE;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,sBAAsB;IAC9D,QAAQ,CAAC,GAAG,yBAAyB;IACrC,QAAQ,CAAC,IAAI,uBAAuB;IACpC,QAAQ,CAAC,WAAW
|
|
1
|
+
{"version":3,"file":"CategoryListResource.d.ts","sourceRoot":"","sources":["../../../../src/resources/category-list/CategoryListResource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAiBvE;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,sBAAsB;IAC9D,QAAQ,CAAC,GAAG,yBAAyB;IACrC,QAAQ,CAAC,WAAW,oCAAoC;IACxD,QAAQ,CAAC,IAAI,uBAAuB;IACpC,QAAQ,CAAC,WAAW,yRACoQ;IACxR,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;IAmD9B;;;;;;;;OAQG;IACH,OAAO,CAAC,sBAAsB;CAY/B"}
|
|
@@ -14,8 +14,9 @@ const MapboxApiBasedResource_js_1 = require("../MapboxApiBasedResource.js");
|
|
|
14
14
|
*/
|
|
15
15
|
class CategoryListResource extends MapboxApiBasedResource_js_1.MapboxApiBasedResource {
|
|
16
16
|
uri = 'mapbox://categories';
|
|
17
|
+
uriTemplate = 'mapbox://categories/{language}';
|
|
17
18
|
name = 'Mapbox Categories';
|
|
18
|
-
description = 'List of all available Mapbox Search API categories. Categories can be used for filtering search results. Supports localization via language parameter in URI (e.g., mapbox://categories/ja for Japanese).';
|
|
19
|
+
description = 'List of all available Mapbox Search API categories. Categories can be used for filtering search results. Supports localization via language parameter in URI (e.g., mapbox://categories/ja for Japanese). A language code the API does not support gets the default (English) list.';
|
|
19
20
|
mimeType = 'application/json';
|
|
20
21
|
constructor(params) {
|
|
21
22
|
super(params);
|
|
@@ -60,11 +61,20 @@ class CategoryListResource extends MapboxApiBasedResource_js_1.MapboxApiBasedRes
|
|
|
60
61
|
/**
|
|
61
62
|
* Extract language code from URI
|
|
62
63
|
* @param uri Resource URI (e.g., mapbox://categories/ja)
|
|
63
|
-
* @returns Language code or undefined
|
|
64
|
+
* @returns Language code, or undefined for the default list
|
|
65
|
+
* @throws for anything after `mapbox://categories/` that isn't a language
|
|
66
|
+
* code (e.g. `%20ja` or `ja?x=1`), rather than quietly returning English.
|
|
67
|
+
* A well-formed code the API doesn't support (e.g. `xx`) still goes
|
|
68
|
+
* through: the API answers with its English list.
|
|
64
69
|
*/
|
|
65
70
|
extractLanguageFromUri(uri) {
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
if (uri === this.uri)
|
|
72
|
+
return undefined;
|
|
73
|
+
const match = uri.match(/^mapbox:\/\/categories\/([a-z]{2}(?:-[a-z]{2,4})?)$/i);
|
|
74
|
+
if (!match) {
|
|
75
|
+
throw new Error(`Resource not found: ${uri}. Use mapbox://categories for the default list, or mapbox://categories/{language} with a language code such as "ja".`);
|
|
76
|
+
}
|
|
77
|
+
return match[1];
|
|
68
78
|
}
|
|
69
79
|
}
|
|
70
80
|
exports.CategoryListResource = CategoryListResource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoryListResource.js","sourceRoot":"","sources":["../../../../src/resources/category-list/CategoryListResource.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAElC,4EAAsE;AAiBtE,oFAAoF;AAEpF;;;;;;GAMG;AACH,MAAa,oBAAqB,SAAQ,kDAAsB;IACrD,GAAG,GAAG,qBAAqB,CAAC;IAC5B,IAAI,GAAG,mBAAmB,CAAC;IAC3B,WAAW,GAClB,
|
|
1
|
+
{"version":3,"file":"CategoryListResource.js","sourceRoot":"","sources":["../../../../src/resources/category-list/CategoryListResource.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAElC,4EAAsE;AAiBtE,oFAAoF;AAEpF;;;;;;GAMG;AACH,MAAa,oBAAqB,SAAQ,kDAAsB;IACrD,GAAG,GAAG,qBAAqB,CAAC;IAC5B,WAAW,GAAG,gCAAgC,CAAC;IAC/C,IAAI,GAAG,mBAAmB,CAAC;IAC3B,WAAW,GAClB,qRAAqR,CAAC;IAC/Q,QAAQ,GAAG,kBAAkB,CAAC;IAEvC,YAAY,MAAoC;QAC9C,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAES,KAAK,CAAC,OAAO,CACrB,GAAW,EACX,WAAmB;QAEnB,qCAAqC;QACrC,wDAAwD;QACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;QAElD,MAAM,MAAM,GAAG,IAAI,GAAG,CACpB,0DAA0D,CAC3D,CAAC;QAEF,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QAErD,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAChD,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE;YACzD,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,YAAY,EAAE,sBAAsB,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,KAAK,EAAE;a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
|
|
18
18
|
* A POI's first Place Details photo, proxied through the server for the map
|
|
19
|
-
* app's results
|
|
19
|
+
* app's results carousel.
|
|
20
20
|
*
|
|
21
21
|
* Place Details photos are hosted wherever the business's own site hosts
|
|
22
22
|
* them (Yext, Webflow and so on), so the map app's CSP can't list their
|
|
@@ -32,7 +32,7 @@ const ALLOWED_TYPES = new Set([
|
|
|
32
32
|
const lookupAll = async (hostname) => (await (0, promises_1.lookup)(hostname, { all: true })).map((a) => a.address);
|
|
33
33
|
/**
|
|
34
34
|
* A POI's first Place Details photo, proxied through the server for the map
|
|
35
|
-
* app's results
|
|
35
|
+
* app's results carousel.
|
|
36
36
|
*
|
|
37
37
|
* Place Details photos are hosted wherever the business's own site hosts
|
|
38
38
|
* them (Yext, Webflow and so on), so the map app's CSP can't list their
|
|
@@ -47,7 +47,7 @@ const lookupAll = async (hostname) => (await (0, promises_1.lookup)(hostname, {
|
|
|
47
47
|
class PlacePhotoResource extends MapboxApiBasedResource_js_1.MapboxApiBasedResource {
|
|
48
48
|
uri = `${URI_PREFIX}{id}`;
|
|
49
49
|
name = 'Mapbox Place Photo';
|
|
50
|
-
description = "The first photo of a POI from Place Details, as an image, for the map app's results
|
|
50
|
+
description = "The first photo of a POI from Place Details, as an image, for the map app's results carousel. " +
|
|
51
51
|
'Read with mapbox://place-photo/{mapbox_id}.';
|
|
52
52
|
mimeType = 'image/jpeg';
|
|
53
53
|
cache = new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlacePhotoResource.js","sourceRoot":"","sources":["../../../../src/resources/place-photo/PlacePhotoResource.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAElC,gDAA2C;AAE3C,4EAAsE;AAEtE,2DAGkC;AAElC,MAAM,UAAU,GAAG,uBAAuB,CAAC;AAE3C;;;;GAIG;AACU,QAAA,qBAAqB,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjD;;;GAGG;AACU,QAAA,2BAA2B,GAAG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tC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,SAAS,GACb,4EAA4E,CAAC;AAE/E;;;GAGG;AACH,SAAS,aAAa,CAAC,EAAU;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"}
|
|
@@ -4,9 +4,10 @@ import { ComputeResource } from './compute/ComputeResource.js';
|
|
|
4
4
|
import { InlinePayloadResource } from './inline-payload/InlinePayloadResource.js';
|
|
5
5
|
import { ToolResponseResource } from './tool-response/ToolResponseResource.js';
|
|
6
6
|
import { MapAppUIResource } from './ui-apps/MapAppUIResource.js';
|
|
7
|
+
import { StaticMapViewerUIResource } from './ui-apps/StaticMapViewerUIResource.js';
|
|
7
8
|
import { VersionResource } from './version/VersionResource.js';
|
|
8
9
|
import { PlacePhotoResource } from './place-photo/PlacePhotoResource.js';
|
|
9
|
-
export declare const ALL_RESOURCES: readonly [CategoryListResource, TemporaryDataResource, ComputeResource, InlinePayloadResource, ToolResponseResource, MapAppUIResource, PlacePhotoResource, VersionResource];
|
|
10
|
+
export declare const ALL_RESOURCES: readonly [CategoryListResource, TemporaryDataResource, ComputeResource, InlinePayloadResource, ToolResponseResource, MapAppUIResource, StaticMapViewerUIResource, PlacePhotoResource, VersionResource];
|
|
10
11
|
export type ResourceInstance = (typeof ALL_RESOURCES)[number];
|
|
11
12
|
export declare function getAllResources(): readonly ResourceInstance[];
|
|
12
13
|
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,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,
|
|
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,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAIzE,eAAO,MAAM,aAAa,wMAchB,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,CAoB1E"}
|
|
@@ -12,6 +12,7 @@ const ComputeResource_js_1 = require("./compute/ComputeResource.js");
|
|
|
12
12
|
const InlinePayloadResource_js_1 = require("./inline-payload/InlinePayloadResource.js");
|
|
13
13
|
const ToolResponseResource_js_1 = require("./tool-response/ToolResponseResource.js");
|
|
14
14
|
const MapAppUIResource_js_1 = require("./ui-apps/MapAppUIResource.js");
|
|
15
|
+
const StaticMapViewerUIResource_js_1 = require("./ui-apps/StaticMapViewerUIResource.js");
|
|
15
16
|
const VersionResource_js_1 = require("./version/VersionResource.js");
|
|
16
17
|
const PlacePhotoResource_js_1 = require("./place-photo/PlacePhotoResource.js");
|
|
17
18
|
const httpPipeline_js_1 = require("../utils/httpPipeline.js");
|
|
@@ -25,7 +26,9 @@ exports.ALL_RESOURCES = [
|
|
|
25
26
|
new ToolResponseResource_js_1.ToolResponseResource({ httpRequest: httpPipeline_js_1.httpRequest }),
|
|
26
27
|
// Single shared map renderer, targeted exclusively by render_map_tool.
|
|
27
28
|
new MapAppUIResource_js_1.MapAppUIResource({ httpRequest: httpPipeline_js_1.httpRequest }),
|
|
28
|
-
//
|
|
29
|
+
// Full-width viewer for static_map_image_tool's image.
|
|
30
|
+
new StaticMapViewerUIResource_js_1.StaticMapViewerUIResource(),
|
|
31
|
+
// Photos for the map app's results carousel, which its CSP can't load directly.
|
|
29
32
|
new PlacePhotoResource_js_1.PlacePhotoResource({ httpRequest: httpPipeline_js_1.httpRequest }),
|
|
30
33
|
new VersionResource_js_1.VersionResource()
|
|
31
34
|
];
|
|
@@ -37,16 +40,18 @@ function getResourceByUri(uri) {
|
|
|
37
40
|
const exactMatch = exports.ALL_RESOURCES.find((resource) => resource.uri === uri);
|
|
38
41
|
if (exactMatch)
|
|
39
42
|
return exactMatch;
|
|
40
|
-
// Find pattern match (e.g., mapbox://categories/ja matches mapbox://categories
|
|
43
|
+
// Find pattern match (e.g., mapbox://categories/ja matches mapbox://categories,
|
|
44
|
+
// mapbox://temp/abc matches the template mapbox://temp/{id}). The prefix is
|
|
45
|
+
// everything before the first `{` or `*`.
|
|
41
46
|
// Plain string prefix check — avoids building a RegExp from data at runtime,
|
|
42
47
|
// which would let an unbounded, user-supplied `uri` be tested against a
|
|
43
48
|
// dynamically constructed pattern (untrusted-input-into-RegExp is a ReDoS
|
|
44
49
|
// smell even though today's static resource URIs are innocuous).
|
|
45
50
|
return exports.ALL_RESOURCES.find((resource) => {
|
|
46
|
-
const
|
|
47
|
-
const basePrefix =
|
|
51
|
+
const variableIndex = resource.uri.search(/[{*]/);
|
|
52
|
+
const basePrefix = variableIndex === -1
|
|
48
53
|
? resource.uri
|
|
49
|
-
: resource.uri.slice(0,
|
|
54
|
+
: resource.uri.slice(0, variableIndex);
|
|
50
55
|
return uri.startsWith(basePrefix);
|
|
51
56
|
});
|
|
52
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceRegistry.js","sourceRoot":"","sources":["../../../src/resources/resourceRegistry.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;
|
|
1
|
+
{"version":3,"file":"resourceRegistry.js","sourceRoot":"","sources":["../../../src/resources/resourceRegistry.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAiClC,0CAEC;AAED,4CAoBC;AAvDD,kCAAkC;AAClC,qFAA+E;AAC/E,mFAA6E;AAC7E,qEAA+D;AAC/D,wFAAkF;AAClF,qFAA+E;AAC/E,uEAAiE;AACjE,yFAAmF;AACnF,qEAA+D;AAC/D,+EAAyE;AACzE,8DAAuD;AAEvD,oCAAoC;AACvB,QAAA,aAAa,GAAG;IAC3B,oCAAoC;IACpC,IAAI,8CAAoB,CAAC,EAAE,WAAW,EAAX,6BAAW,EAAE,CAAC;IACzC,IAAI,gDAAqB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'../MapboxApiBasedResource.js';
|
|
3
3
|
import type { HttpRequest } from '../../utils/types.js';
|
|
4
4
|
/**
|
|
5
|
-
* Full `directions_tool` / `isochrone_tool` responses
|
|
6
|
-
* to return inline. The
|
|
7
|
-
* call's inputs (see
|
|
8
|
-
*
|
|
5
|
+
* Full `directions_tool` / `isochrone_tool` responses and
|
|
6
|
+
* `static_map_image_tool` images that were too large to return inline. The
|
|
7
|
+
* `mapbox://response/{tool}?data=...` ref carries the call's inputs (see
|
|
8
|
+
* responseRef.ts), and reading it runs the same request again with the
|
|
9
|
+
* reader's token, so any server process can answer it.
|
|
9
10
|
*/
|
|
10
11
|
export declare class ToolResponseResource extends MapboxApiBasedResource {
|
|
11
12
|
readonly name = "Full Tool Response";
|
|
12
13
|
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 description = "The full response of a directions_tool or isochrone_tool call, or a static_map_image_tool image, that was too large to return inline, fetched again from its ref.";
|
|
14
15
|
readonly mimeType = "application/json";
|
|
15
16
|
constructor(params: {
|
|
16
17
|
httpRequest: HttpRequest;
|
|
@@ -1 +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,8BAA8B,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ToolResponseResource.d.ts","sourceRoot":"","sources":["../../../../src/resources/tool-response/ToolResponseResource.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAcxD;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,sBAAsB;IAC9D,QAAQ,CAAC,IAAI,wBAAwB;IACrC,QAAQ,CAAC,GAAG,8BAA8B;IAC1C,QAAQ,CAAC,WAAW,uKACkJ;IACtK,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;CAyF/B"}
|
|
@@ -10,16 +10,19 @@ const buildDirectionsRequestUrl_js_1 = require("../../tools/directions-tool/buil
|
|
|
10
10
|
const cleanResponseData_js_1 = require("../../tools/directions-tool/cleanResponseData.js");
|
|
11
11
|
const IsochroneTool_input_schema_js_1 = require("../../tools/isochrone-tool/IsochroneTool.input.schema.js");
|
|
12
12
|
const buildIsochroneRequestUrl_js_1 = require("../../tools/isochrone-tool/buildIsochroneRequestUrl.js");
|
|
13
|
+
const StaticMapImageTool_input_schema_js_1 = require("../../tools/static-map-image-tool/StaticMapImageTool.input.schema.js");
|
|
14
|
+
const buildStaticMapRequestUrl_js_1 = require("../../tools/static-map-image-tool/buildStaticMapRequestUrl.js");
|
|
13
15
|
/**
|
|
14
|
-
* Full `directions_tool` / `isochrone_tool` responses
|
|
15
|
-
* to return inline. The
|
|
16
|
-
* call's inputs (see
|
|
17
|
-
*
|
|
16
|
+
* Full `directions_tool` / `isochrone_tool` responses and
|
|
17
|
+
* `static_map_image_tool` images that were too large to return inline. The
|
|
18
|
+
* `mapbox://response/{tool}?data=...` ref carries the call's inputs (see
|
|
19
|
+
* responseRef.ts), and reading it runs the same request again with the
|
|
20
|
+
* reader's token, so any server process can answer it.
|
|
18
21
|
*/
|
|
19
22
|
class ToolResponseResource extends MapboxApiBasedResource_js_1.MapboxApiBasedResource {
|
|
20
23
|
name = 'Full Tool Response';
|
|
21
24
|
uri = 'mapbox://response/{spec}';
|
|
22
|
-
description = 'The full response of a directions_tool or isochrone_tool call that was too large to return inline, fetched again from its ref.';
|
|
25
|
+
description = 'The full response of a directions_tool or isochrone_tool call, or a static_map_image_tool image, that was too large to return inline, fetched again from its ref.';
|
|
23
26
|
mimeType = 'application/json';
|
|
24
27
|
constructor(params) {
|
|
25
28
|
super(params);
|
|
@@ -27,6 +30,27 @@ class ToolResponseResource extends MapboxApiBasedResource_js_1.MapboxApiBasedRes
|
|
|
27
30
|
async execute(uri, accessToken) {
|
|
28
31
|
const spec = (0, responseRef_js_1.resolveResponseRef)(uri);
|
|
29
32
|
const apiEndpoint = MapboxApiBasedResource_js_1.MapboxApiBasedResource.mapboxApiEndpoint;
|
|
33
|
+
if (spec?.tool === 'static-map') {
|
|
34
|
+
const parsed = StaticMapImageTool_input_schema_js_1.StaticMapImageInputSchema.safeParse(spec.input);
|
|
35
|
+
if (!parsed.success) {
|
|
36
|
+
return text(uri, 'Response ref was malformed or unsupported.');
|
|
37
|
+
}
|
|
38
|
+
const { url } = (0, buildStaticMapRequestUrl_js_1.buildStaticMapRequestUrl)({
|
|
39
|
+
input: parsed.data,
|
|
40
|
+
accessToken,
|
|
41
|
+
apiEndpoint
|
|
42
|
+
});
|
|
43
|
+
const response = await this.httpRequest(url);
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
return text(uri, `Fetching the image failed: ${response.status} ${response.statusText}`);
|
|
46
|
+
}
|
|
47
|
+
const blob = Buffer.from(await response.arrayBuffer()).toString('base64');
|
|
48
|
+
return {
|
|
49
|
+
contents: [
|
|
50
|
+
{ uri, mimeType: (0, buildStaticMapRequestUrl_js_1.getStaticMapMimeType)(parsed.data.style), blob }
|
|
51
|
+
]
|
|
52
|
+
};
|
|
53
|
+
}
|
|
30
54
|
let url = null;
|
|
31
55
|
let directionsInput = null;
|
|
32
56
|
if (spec?.tool === 'directions') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolResponseResource.js","sourceRoot":"","sources":["../../../../src/resources/tool-response/ToolResponseResource.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAGlC,4EAAsE;AAEtE,+DAAgE;AAChE,+GAAmG;AACnG,2GAAqG;AACrG,2FAAqF;AAErF,4GAAgG;AAChG,wGAAkG;
|
|
1
|
+
{"version":3,"file":"ToolResponseResource.js","sourceRoot":"","sources":["../../../../src/resources/tool-response/ToolResponseResource.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAGlC,4EAAsE;AAEtE,+DAAgE;AAChE,+GAAmG;AACnG,2GAAqG;AACrG,2FAAqF;AAErF,4GAAgG;AAChG,wGAAkG;AAClG,6HAAiH;AACjH,+GAGuE;AAEvE;;;;;;GAMG;AACH,MAAa,oBAAqB,SAAQ,kDAAsB;IACrD,IAAI,GAAG,oBAAoB,CAAC;IAC5B,GAAG,GAAG,0BAA0B,CAAC;IACjC,WAAW,GAClB,mKAAmK,CAAC;IAC7J,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,IAAA,mCAAkB,EAAC,GAAG,CAAC,CAAC;QACrC,MAAM,WAAW,GAAG,kDAAsB,CAAC,iBAAiB,CAAC;QAE7D,IAAI,IAAI,EAAE,IAAI,KAAK,YAAY,EAAE,CAAC;YAChC,MAAM,MAAM,GAAG,8DAAyB,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,IAAI,CAAC,GAAG,EAAE,4CAA4C,CAAC,CAAC;YACjE,CAAC;YACD,MAAM,EAAE,GAAG,EAAE,GAAG,IAAA,sDAAwB,EAA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I,EAAE,CAAC,CAAC,EAAE;aACtE;SACF,CAAC;IACJ,CAAC;CACF;AAvGD,oDAuGC;AAED,SAAS,IAAI,CAAC,GAAW,EAAE,OAAe;IACxC,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReadResourceResult } from '@modelcontextprotocol/server';
|
|
2
|
+
import { BaseResource } from '../BaseResource.js';
|
|
3
|
+
export declare const STATIC_MAP_VIEWER_URI = "ui://mapbox/static-map/index.html";
|
|
4
|
+
/**
|
|
5
|
+
* The MCP App `static_map_image_tool` points at, which shows its image at
|
|
6
|
+
* full width (see staticMapViewerHtml.ts).
|
|
7
|
+
*
|
|
8
|
+
* The image comes from the tool result itself, so unlike the map app this
|
|
9
|
+
* page needs no token. Its CSP only allows images from the API origin, for
|
|
10
|
+
* the public-token URL it falls back to when the image went to a temporary
|
|
11
|
+
* resource.
|
|
12
|
+
*/
|
|
13
|
+
export declare class StaticMapViewerUIResource extends BaseResource {
|
|
14
|
+
readonly name = "Mapbox Static Map Viewer";
|
|
15
|
+
readonly uri = "ui://mapbox/static-map/index.html";
|
|
16
|
+
readonly description = "Shows the static_map_image_tool image at full width (MCP Apps)";
|
|
17
|
+
readonly mimeType = "text/html;profile=mcp-app";
|
|
18
|
+
private readonly apiEndpoint;
|
|
19
|
+
constructor(params?: {
|
|
20
|
+
apiEndpoint?: () => string;
|
|
21
|
+
});
|
|
22
|
+
read(): Promise<ReadResourceResult>;
|
|
23
|
+
}
|
|
24
|
+
/** Images from the API origin only; the page fetches nothing else. */
|
|
25
|
+
export declare function staticMapViewerCsp(apiEndpoint: string): {
|
|
26
|
+
resourceDomains: string[];
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=StaticMapViewerUIResource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StaticMapViewerUIResource.d.ts","sourceRoot":"","sources":["../../../../src/resources/ui-apps/StaticMapViewerUIResource.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,eAAO,MAAM,qBAAqB,sCAAsC,CAAC;AAEzE;;;;;;;;GAQG;AACH,qBAAa,yBAA0B,SAAQ,YAAY;IACzD,QAAQ,CAAC,IAAI,8BAA8B;IAC3C,QAAQ,CAAC,GAAG,uCAAyB;IACrC,QAAQ,CAAC,WAAW,oEAC+C;IACnE,QAAQ,CAAC,QAAQ,+BAAsB;IAEvC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;gBAE/B,MAAM,GAAE;QAAE,WAAW,CAAC,EAAE,MAAM,MAAM,CAAA;KAAO;IAOjD,IAAI,IAAI,OAAO,CAAC,kBAAkB,CAAC;CAiB1C;AAED,sEAAsE;AACtE,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG;IACvD,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CASA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Mapbox, Inc.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.StaticMapViewerUIResource = exports.STATIC_MAP_VIEWER_URI = void 0;
|
|
6
|
+
exports.staticMapViewerCsp = staticMapViewerCsp;
|
|
7
|
+
const server_1 = require("@modelcontextprotocol/ext-apps/server");
|
|
8
|
+
const BaseResource_js_1 = require("../BaseResource.js");
|
|
9
|
+
const staticMapViewerHtml_js_1 = require("./staticMapViewerHtml.js");
|
|
10
|
+
exports.STATIC_MAP_VIEWER_URI = 'ui://mapbox/static-map/index.html';
|
|
11
|
+
/**
|
|
12
|
+
* The MCP App `static_map_image_tool` points at, which shows its image at
|
|
13
|
+
* full width (see staticMapViewerHtml.ts).
|
|
14
|
+
*
|
|
15
|
+
* The image comes from the tool result itself, so unlike the map app this
|
|
16
|
+
* page needs no token. Its CSP only allows images from the API origin, for
|
|
17
|
+
* the public-token URL it falls back to when the image went to a temporary
|
|
18
|
+
* resource.
|
|
19
|
+
*/
|
|
20
|
+
class StaticMapViewerUIResource extends BaseResource_js_1.BaseResource {
|
|
21
|
+
name = 'Mapbox Static Map Viewer';
|
|
22
|
+
uri = exports.STATIC_MAP_VIEWER_URI;
|
|
23
|
+
description = 'Shows the static_map_image_tool image at full width (MCP Apps)';
|
|
24
|
+
mimeType = server_1.RESOURCE_MIME_TYPE;
|
|
25
|
+
apiEndpoint;
|
|
26
|
+
constructor(params = {}) {
|
|
27
|
+
super();
|
|
28
|
+
this.apiEndpoint =
|
|
29
|
+
params.apiEndpoint ??
|
|
30
|
+
(() => process.env.MAPBOX_API_ENDPOINT || 'https://api.mapbox.com/');
|
|
31
|
+
}
|
|
32
|
+
async read() {
|
|
33
|
+
return {
|
|
34
|
+
contents: [
|
|
35
|
+
{
|
|
36
|
+
uri: this.uri,
|
|
37
|
+
mimeType: server_1.RESOURCE_MIME_TYPE,
|
|
38
|
+
text: (0, staticMapViewerHtml_js_1.renderStaticMapViewerHtml)({ apiEndpoint: this.apiEndpoint() }),
|
|
39
|
+
_meta: {
|
|
40
|
+
ui: {
|
|
41
|
+
csp: staticMapViewerCsp(this.apiEndpoint()),
|
|
42
|
+
prefersBorder: false
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.StaticMapViewerUIResource = StaticMapViewerUIResource;
|
|
51
|
+
/** Images from the API origin only; the page fetches nothing else. */
|
|
52
|
+
function staticMapViewerCsp(apiEndpoint) {
|
|
53
|
+
const resourceDomains = ['https://api.mapbox.com'];
|
|
54
|
+
try {
|
|
55
|
+
const origin = new URL(apiEndpoint).origin;
|
|
56
|
+
if (!resourceDomains.includes(origin))
|
|
57
|
+
resourceDomains.push(origin);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// An endpoint that isn't a valid URL can't serve images anyway.
|
|
61
|
+
}
|
|
62
|
+
return { resourceDomains };
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=StaticMapViewerUIResource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StaticMapViewerUIResource.js","sourceRoot":"","sources":["../../../../src/resources/ui-apps/StaticMapViewerUIResource.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kCAAkC;;;AAsDlC,gDAWC;AA9DD,kEAA2E;AAC3E,wDAAkD;AAClD,qEAAqE;AAExD,QAAA,qBAAqB,GAAG,mCAAmC,CAAC;AAEzE;;;;;;;;GAQG;AACH,MAAa,yBAA0B,SAAQ,8BAAY;IAChD,IAAI,GAAG,0BAA0B,CAAC;IAClC,GAAG,GAAG,6BAAqB,CAAC;IAC5B,WAAW,GAClB,gEAAgE,CAAC;IAC1D,QAAQ,GAAG,2BAAkB,CAAC;IAEtB,WAAW,CAAe;IAE3C,YAAY,SAAyC,EAAE;QACrD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW;YACd,MAAM,CAAC,WAAW;gBAClB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,yBAAyB,CAAC,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,GAAG,EAAE,IAAI,CAAC,GAAG;oBACb,QAAQ,EAAE,2BAAkB;oBAC5B,IAAI,EAAE,IAAA,kDAAyB,EAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;oBACpE,KAAK,EAAE;wBACL,EAAE,EAAE;4BACF,GAAG,EAAE,kBAAkB,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;4BAC3C,aAAa,EAAE,KAAK;yBACrB;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;CACF;AAjCD,8DAiCC;AAED,sEAAsE;AACtE,SAAgB,kBAAkB,CAAC,WAAmB;IAGpD,MAAM,eAAe,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACnD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;QAC3C,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtE,CAAC;IAAC,MAAM,CAAC;QACP,gEAAgE;IAClE,CAAC;IACD,OAAO,EAAE,eAAe,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapAppHtml.d.ts","sourceRoot":"","sources":["../../../../src/resources/ui-apps/mapAppHtml.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE;;;;;;;;;GASG;AAMH,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,aAAa,CAAC;CAC7B,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"mapAppHtml.d.ts","sourceRoot":"","sources":["../../../../src/resources/ui-apps/mapAppHtml.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE;;;;;;;;;GASG;AAMH,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,aAAa,CAAC;CAC7B,GAAG,MAAM,CA6yFT"}
|