@mapbox/mcp-server 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/commonjs/index.js +38 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/resources/BaseResource.d.ts +18 -0
- package/dist/commonjs/resources/BaseResource.d.ts.map +1 -1
- package/dist/commonjs/resources/BaseResource.js +26 -4
- package/dist/commonjs/resources/BaseResource.js.map +1 -1
- package/dist/commonjs/resources/temporary/TemporaryDataResource.d.ts.map +1 -1
- package/dist/commonjs/resources/temporary/TemporaryDataResource.js +20 -10
- package/dist/commonjs/resources/temporary/TemporaryDataResource.js.map +1 -1
- package/dist/commonjs/resources/ui-apps/MapAppUIResource.d.ts.map +1 -1
- package/dist/commonjs/resources/ui-apps/MapAppUIResource.js +2 -8
- package/dist/commonjs/resources/ui-apps/MapAppUIResource.js.map +1 -1
- package/dist/commonjs/resources/ui-apps/mapAppCsp.d.ts +22 -0
- package/dist/commonjs/resources/ui-apps/mapAppCsp.d.ts.map +1 -0
- package/dist/commonjs/resources/ui-apps/mapAppCsp.js +39 -0
- package/dist/commonjs/resources/ui-apps/mapAppCsp.js.map +1 -0
- package/dist/commonjs/resources/ui-apps/mapAppHtml.d.ts.map +1 -1
- package/dist/commonjs/resources/ui-apps/mapAppHtml.js +71 -9
- package/dist/commonjs/resources/ui-apps/mapAppHtml.js.map +1 -1
- package/dist/commonjs/tools/BaseTool.d.ts +19 -0
- package/dist/commonjs/tools/BaseTool.d.ts.map +1 -1
- package/dist/commonjs/tools/BaseTool.js +25 -3
- package/dist/commonjs/tools/BaseTool.js.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.js +4 -3
- 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 +7 -4
- package/dist/commonjs/tools/ground-location-tool/GroundLocationTool.js.map +1 -1
- package/dist/commonjs/tools/ground-location-tool/GroundLocationTool.output.schema.d.ts +4 -0
- package/dist/commonjs/tools/ground-location-tool/GroundLocationTool.output.schema.d.ts.map +1 -1
- package/dist/commonjs/tools/ground-location-tool/GroundLocationTool.output.schema.js +9 -1
- package/dist/commonjs/tools/ground-location-tool/GroundLocationTool.output.schema.js.map +1 -1
- package/dist/commonjs/tools/isochrone-tool/IsochroneTool.js +1 -1
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.d.ts +11 -1
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.d.ts.map +1 -1
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.input.schema.js +3 -3
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.input.schema.js.map +1 -1
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.js +132 -141
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.js.map +1 -1
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.output.schema.d.ts +71 -10
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.output.schema.d.ts.map +1 -1
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.output.schema.js +86 -10
- package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.output.schema.js.map +1 -1
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.d.ts +2 -4
- 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 +50 -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 +51 -2
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.input.schema.js.map +1 -1
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.js +50 -18
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.js.map +1 -1
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.output.schema.d.ts +50 -0
- package/dist/commonjs/tools/render-map-tool/RenderMapTool.output.schema.d.ts.map +1 -1
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.d.ts.map +1 -1
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.input.schema.d.ts.map +1 -1
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.input.schema.js +2 -2
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.input.schema.js.map +1 -1
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.js +4 -3
- package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.js.map +1 -1
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.js +2 -2
- package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
- package/dist/commonjs/utils/index.d.ts +2 -0
- package/dist/commonjs/utils/index.d.ts.map +1 -1
- package/dist/commonjs/utils/index.js +10 -1
- package/dist/commonjs/utils/index.js.map +1 -1
- package/dist/commonjs/utils/jsonSchema2020.d.ts +26 -0
- package/dist/commonjs/utils/jsonSchema2020.d.ts.map +1 -0
- package/dist/commonjs/utils/jsonSchema2020.js +143 -0
- package/dist/commonjs/utils/jsonSchema2020.js.map +1 -0
- package/dist/commonjs/utils/jwtUtils.d.ts +48 -0
- package/dist/commonjs/utils/jwtUtils.d.ts.map +1 -1
- package/dist/commonjs/utils/jwtUtils.js +63 -0
- package/dist/commonjs/utils/jwtUtils.js.map +1 -1
- package/dist/commonjs/utils/mapAppPayload.d.ts +109 -0
- package/dist/commonjs/utils/mapAppPayload.d.ts.map +1 -1
- package/dist/commonjs/utils/mapAppPayload.js +38 -2
- package/dist/commonjs/utils/mapAppPayload.js.map +1 -1
- package/dist/commonjs/utils/selfFetchRef.d.ts.map +1 -1
- package/dist/commonjs/utils/selfFetchRef.js +31 -0
- package/dist/commonjs/utils/selfFetchRef.js.map +1 -1
- package/dist/commonjs/utils/serverInstructions.d.ts +12 -0
- package/dist/commonjs/utils/serverInstructions.d.ts.map +1 -0
- package/dist/commonjs/utils/serverInstructions.js +28 -0
- package/dist/commonjs/utils/serverInstructions.js.map +1 -0
- package/dist/commonjs/utils/storeMapPayload.d.ts +11 -11
- package/dist/commonjs/utils/storeMapPayload.d.ts.map +1 -1
- package/dist/commonjs/utils/storeMapPayload.js +14 -13
- package/dist/commonjs/utils/storeMapPayload.js.map +1 -1
- package/dist/commonjs/utils/temporaryResourceManager.d.ts +10 -4
- package/dist/commonjs/utils/temporaryResourceManager.d.ts.map +1 -1
- package/dist/commonjs/utils/temporaryResourceManager.js.map +1 -1
- package/dist/commonjs/utils/tracing.d.ts +4 -0
- package/dist/commonjs/utils/tracing.d.ts.map +1 -1
- package/dist/commonjs/utils/tracing.js +20 -0
- package/dist/commonjs/utils/tracing.js.map +1 -1
- package/dist/commonjs/version.json +3 -3
- package/dist/esm/index.js +39 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/resources/BaseResource.d.ts +18 -0
- package/dist/esm/resources/BaseResource.d.ts.map +1 -1
- package/dist/esm/resources/BaseResource.js +26 -4
- package/dist/esm/resources/BaseResource.js.map +1 -1
- package/dist/esm/resources/temporary/TemporaryDataResource.d.ts.map +1 -1
- package/dist/esm/resources/temporary/TemporaryDataResource.js +21 -11
- package/dist/esm/resources/temporary/TemporaryDataResource.js.map +1 -1
- package/dist/esm/resources/ui-apps/MapAppUIResource.d.ts.map +1 -1
- package/dist/esm/resources/ui-apps/MapAppUIResource.js +2 -8
- package/dist/esm/resources/ui-apps/MapAppUIResource.js.map +1 -1
- package/dist/esm/resources/ui-apps/mapAppCsp.d.ts +22 -0
- package/dist/esm/resources/ui-apps/mapAppCsp.d.ts.map +1 -0
- package/dist/esm/resources/ui-apps/mapAppCsp.js +36 -0
- package/dist/esm/resources/ui-apps/mapAppCsp.js.map +1 -0
- package/dist/esm/resources/ui-apps/mapAppHtml.d.ts.map +1 -1
- package/dist/esm/resources/ui-apps/mapAppHtml.js +71 -9
- package/dist/esm/resources/ui-apps/mapAppHtml.js.map +1 -1
- package/dist/esm/tools/BaseTool.d.ts +19 -0
- package/dist/esm/tools/BaseTool.d.ts.map +1 -1
- package/dist/esm/tools/BaseTool.js +25 -3
- package/dist/esm/tools/BaseTool.js.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.js +5 -4
- 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 +7 -4
- package/dist/esm/tools/ground-location-tool/GroundLocationTool.js.map +1 -1
- package/dist/esm/tools/ground-location-tool/GroundLocationTool.output.schema.d.ts +4 -0
- package/dist/esm/tools/ground-location-tool/GroundLocationTool.output.schema.d.ts.map +1 -1
- package/dist/esm/tools/ground-location-tool/GroundLocationTool.output.schema.js +9 -1
- package/dist/esm/tools/ground-location-tool/GroundLocationTool.output.schema.js.map +1 -1
- package/dist/esm/tools/isochrone-tool/IsochroneTool.js +2 -2
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.d.ts +11 -1
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.d.ts.map +1 -1
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.input.schema.js +3 -3
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.input.schema.js.map +1 -1
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.js +133 -142
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.js.map +1 -1
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.output.schema.d.ts +71 -10
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.output.schema.d.ts.map +1 -1
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.output.schema.js +85 -9
- package/dist/esm/tools/place-details-tool/PlaceDetailsTool.output.schema.js.map +1 -1
- package/dist/esm/tools/render-map-tool/RenderMapTool.d.ts +2 -4
- 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 +50 -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 +51 -2
- package/dist/esm/tools/render-map-tool/RenderMapTool.input.schema.js.map +1 -1
- package/dist/esm/tools/render-map-tool/RenderMapTool.js +51 -19
- package/dist/esm/tools/render-map-tool/RenderMapTool.js.map +1 -1
- package/dist/esm/tools/render-map-tool/RenderMapTool.output.schema.d.ts +50 -0
- package/dist/esm/tools/render-map-tool/RenderMapTool.output.schema.d.ts.map +1 -1
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.d.ts.map +1 -1
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.input.schema.d.ts.map +1 -1
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.input.schema.js +2 -2
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.input.schema.js.map +1 -1
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.js +4 -3
- package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.js.map +1 -1
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.js +3 -3
- package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
- package/dist/esm/utils/index.d.ts +2 -0
- package/dist/esm/utils/index.d.ts.map +1 -1
- package/dist/esm/utils/index.js +6 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/jsonSchema2020.d.ts +26 -0
- package/dist/esm/utils/jsonSchema2020.d.ts.map +1 -0
- package/dist/esm/utils/jsonSchema2020.js +138 -0
- package/dist/esm/utils/jsonSchema2020.js.map +1 -0
- package/dist/esm/utils/jwtUtils.d.ts +48 -0
- package/dist/esm/utils/jwtUtils.d.ts.map +1 -1
- package/dist/esm/utils/jwtUtils.js +61 -0
- package/dist/esm/utils/jwtUtils.js.map +1 -1
- package/dist/esm/utils/mapAppPayload.d.ts +109 -0
- package/dist/esm/utils/mapAppPayload.d.ts.map +1 -1
- package/dist/esm/utils/mapAppPayload.js +38 -2
- package/dist/esm/utils/mapAppPayload.js.map +1 -1
- package/dist/esm/utils/selfFetchRef.d.ts.map +1 -1
- package/dist/esm/utils/selfFetchRef.js +31 -0
- package/dist/esm/utils/selfFetchRef.js.map +1 -1
- package/dist/esm/utils/serverInstructions.d.ts +12 -0
- package/dist/esm/utils/serverInstructions.d.ts.map +1 -0
- package/dist/esm/utils/serverInstructions.js +25 -0
- package/dist/esm/utils/serverInstructions.js.map +1 -0
- package/dist/esm/utils/storeMapPayload.d.ts +11 -11
- package/dist/esm/utils/storeMapPayload.d.ts.map +1 -1
- package/dist/esm/utils/storeMapPayload.js +14 -13
- package/dist/esm/utils/storeMapPayload.js.map +1 -1
- package/dist/esm/utils/temporaryResourceManager.d.ts +10 -4
- package/dist/esm/utils/temporaryResourceManager.d.ts.map +1 -1
- package/dist/esm/utils/temporaryResourceManager.js.map +1 -1
- package/dist/esm/utils/tracing.d.ts +4 -0
- package/dist/esm/utils/tracing.d.ts.map +1 -1
- package/dist/esm/utils/tracing.js +19 -0
- package/dist/esm/utils/tracing.js.map +1 -1
- package/dist/esm/version.json +3 -3
- package/package.json +2 -2
- package/patches/{@modelcontextprotocol+sdk+1.29.0.patch → @modelcontextprotocol+sdk+1.30.0.patch} +6 -2
|
@@ -56,6 +56,11 @@ export declare const RenderMapOutputSchema: z.ZodObject<{
|
|
|
56
56
|
}, z.core.$strip>]>;
|
|
57
57
|
paint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
58
58
|
layout: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
59
|
+
slot: z.ZodOptional<z.ZodEnum<{
|
|
60
|
+
bottom: "bottom";
|
|
61
|
+
middle: "middle";
|
|
62
|
+
top: "top";
|
|
63
|
+
}>>;
|
|
59
64
|
}, z.core.$strip>>>;
|
|
60
65
|
markers: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
61
66
|
coordinates: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
@@ -91,6 +96,51 @@ export declare const RenderMapOutputSchema: z.ZodObject<{
|
|
|
91
96
|
}>;
|
|
92
97
|
params: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
93
98
|
}, z.core.$strip>>>>;
|
|
99
|
+
baseMapConfig: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
100
|
+
theme: z.ZodOptional<z.ZodEnum<{
|
|
101
|
+
default: "default";
|
|
102
|
+
custom: "custom";
|
|
103
|
+
faded: "faded";
|
|
104
|
+
monochrome: "monochrome";
|
|
105
|
+
}>>;
|
|
106
|
+
lightPreset: z.ZodOptional<z.ZodEnum<{
|
|
107
|
+
day: "day";
|
|
108
|
+
dawn: "dawn";
|
|
109
|
+
dusk: "dusk";
|
|
110
|
+
night: "night";
|
|
111
|
+
}>>;
|
|
112
|
+
colorWater: z.ZodOptional<z.ZodString>;
|
|
113
|
+
colorLand: z.ZodOptional<z.ZodString>;
|
|
114
|
+
colorGreenspace: z.ZodOptional<z.ZodString>;
|
|
115
|
+
colorMotorways: z.ZodOptional<z.ZodString>;
|
|
116
|
+
colorTrunks: z.ZodOptional<z.ZodString>;
|
|
117
|
+
colorRoads: z.ZodOptional<z.ZodString>;
|
|
118
|
+
colorBuildings: z.ZodOptional<z.ZodString>;
|
|
119
|
+
colorAdminBoundaries: z.ZodOptional<z.ZodString>;
|
|
120
|
+
colorCommercial: z.ZodOptional<z.ZodString>;
|
|
121
|
+
colorEducation: z.ZodOptional<z.ZodString>;
|
|
122
|
+
colorMedical: z.ZodOptional<z.ZodString>;
|
|
123
|
+
colorIndustrial: z.ZodOptional<z.ZodString>;
|
|
124
|
+
colorPlaceLabels: z.ZodOptional<z.ZodString>;
|
|
125
|
+
colorRoadLabels: z.ZodOptional<z.ZodString>;
|
|
126
|
+
colorPointOfInterestLabels: z.ZodOptional<z.ZodString>;
|
|
127
|
+
showPointOfInterestLabels: z.ZodOptional<z.ZodBoolean>;
|
|
128
|
+
showTransitLabels: z.ZodOptional<z.ZodBoolean>;
|
|
129
|
+
showPlaceLabels: z.ZodOptional<z.ZodBoolean>;
|
|
130
|
+
showRoadLabels: z.ZodOptional<z.ZodBoolean>;
|
|
131
|
+
showAdminBoundaries: z.ZodOptional<z.ZodBoolean>;
|
|
132
|
+
showIndoor: z.ZodOptional<z.ZodBoolean>;
|
|
133
|
+
showIndoorLabels: z.ZodOptional<z.ZodBoolean>;
|
|
134
|
+
showLandmarkIconLabels: z.ZodOptional<z.ZodBoolean>;
|
|
135
|
+
show3dObjects: z.ZodOptional<z.ZodBoolean>;
|
|
136
|
+
show3dTrees: z.ZodOptional<z.ZodBoolean>;
|
|
137
|
+
show3dFacades: z.ZodOptional<z.ZodBoolean>;
|
|
138
|
+
densityPointOfInterestLabels: z.ZodOptional<z.ZodNumber>;
|
|
139
|
+
}, z.core.$loose>>>;
|
|
140
|
+
baseStyle: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
|
|
141
|
+
standard: "standard";
|
|
142
|
+
"standard-satellite": "standard-satellite";
|
|
143
|
+
}>>>;
|
|
94
144
|
}, z.core.$strip>>;
|
|
95
145
|
}, z.core.$loose>;
|
|
96
146
|
export type RenderMapOutput = z.infer<typeof RenderMapOutputSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderMapTool.output.schema.d.ts","sourceRoot":"","sources":["../../../../src/tools/render-map-tool/RenderMapTool.output.schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"RenderMapTool.output.schema.d.ts","sourceRoot":"","sources":["../../../../src/tools/render-map-tool/RenderMapTool.output.schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiBlB,CAAC;AAEjB,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchAndGeocodeTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/search-and-geocode-tool/SearchAndGeocodeTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EACL,uBAAuB,EAExB,MAAM,yCAAyC,CAAC;AAKjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAOzE,qBAAa,oBAAqB,SAAQ,kBAAkB,CAC1D,OAAO,2BAA2B,EAClC,OAAO,uBAAuB,CAC/B;IACC,IAAI,SAA6B;IACjC,WAAW,
|
|
1
|
+
{"version":3,"file":"SearchAndGeocodeTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/search-and-geocode-tool/SearchAndGeocodeTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EACL,uBAAuB,EAExB,MAAM,yCAAyC,CAAC;AAKjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAOzE,qBAAa,oBAAqB,SAAQ,kBAAkB,CAC1D,OAAO,2BAA2B,EAClC,OAAO,uBAAuB,CAC/B;IACC,IAAI,SAA6B;IACjC,WAAW,SACsvB;IACjwB,WAAW;;;;;;MAMT;gBACU,MAAM,EAAE;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE;IAQhD,OAAO,CAAC,mBAAmB;cA6DX,OAAO,CACrB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,EAClD,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,cAAc,CAAC;IAuJ1B;;;;;;;;OAQG;IACH,OAAO,CAAC,cAAc;CA0CvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchAndGeocodeTool.input.schema.d.ts","sourceRoot":"","sources":["../../../../src/tools/search-and-geocode-tool/SearchAndGeocodeTool.input.schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"SearchAndGeocodeTool.input.schema.d.ts","sourceRoot":"","sources":["../../../../src/tools/search-and-geocode-tool/SearchAndGeocodeTool.input.schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4DtC,CAAC"}
|
|
@@ -5,8 +5,8 @@ import { bboxSchema, countrySchema } from '../../schemas/shared.js';
|
|
|
5
5
|
export const SearchAndGeocodeInputSchema = z.object({
|
|
6
6
|
q: z
|
|
7
7
|
.string()
|
|
8
|
-
.max(
|
|
9
|
-
.describe('Search query text. Limited to
|
|
8
|
+
.max(200)
|
|
9
|
+
.describe('Search query text. Limited to 200 characters (the API rejects longer queries with a 400, despite the docs stating 256). Supports natural-language phrasing combining category, place, and attributes (e.g. "quiet coffee shops with wifi near downtown Seattle"), though big-box retail brand + address queries (e.g. "Costco near <address>") are currently unreliable.'),
|
|
10
10
|
language: z
|
|
11
11
|
.string()
|
|
12
12
|
.optional()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchAndGeocodeTool.input.schema.js","sourceRoot":"","sources":["../../../../src/tools/search-and-geocode-tool/SearchAndGeocodeTool.input.schema.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAElC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAEpE,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,CAAC,EAAE,CAAC;SACD,MAAM,EAAE;SACR,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,
|
|
1
|
+
{"version":3,"file":"SearchAndGeocodeTool.input.schema.js","sourceRoot":"","sources":["../../../../src/tools/search-and-geocode-tool/SearchAndGeocodeTool.input.schema.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAElC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,aAAa,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ClB,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;SACvC,QAAQ,EAAE;SACV,QAAQ,CAAC,sCAAsC,CAAC;IACnD,MAAM,EAAE,CAAC;SACN,MAAM,CAAC;QACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;QACxC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;KACtC,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAC"}
|
|
@@ -10,7 +10,7 @@ import { buildSelfFetchRef } from '../../utils/selfFetchRef.js';
|
|
|
10
10
|
// API Documentation: https://docs.mapbox.com/api/search/search-box/#search-request
|
|
11
11
|
export class SearchAndGeocodeTool extends MapboxApiBasedTool {
|
|
12
12
|
name = 'search_and_geocode_tool';
|
|
13
|
-
description = "Search for POIs, brands, chains, geocode cities, towns, addresses. Do not use for generic place types such as 'museums', 'coffee shops', 'tacos', etc, because category_search_tool is better for that. Setting a proximity point is strongly encouraged for more local results.";
|
|
13
|
+
description = "Search for POIs, brands, chains, geocode cities, towns, addresses. Do not use for generic place types such as 'museums', 'coffee shops', 'tacos', etc, because category_search_tool is better for that. Setting a proximity point is strongly encouraged for more local results. The underlying Search Box API is rolling out natural-language query understanding (e.g. 'quiet coffee shops with wifi near downtown'), so richer free-text phrasing in `q` can work well for category + place + attribute combinations — but as of this writing, big-box retail brand searches tied to a specific address (e.g. 'Costco near <address>', 'Walmart near <address>', 'Target near <address>') are unreliable and often return unrelated results; verify those results before relying on them.";
|
|
14
14
|
annotations = {
|
|
15
15
|
title: 'Search and Geocode Tool',
|
|
16
16
|
readOnlyHint: true,
|
|
@@ -104,7 +104,8 @@ export class SearchAndGeocodeTool extends MapboxApiBasedTool {
|
|
|
104
104
|
data = rawData;
|
|
105
105
|
}
|
|
106
106
|
// Check if we have multiple results that might be ambiguous
|
|
107
|
-
|
|
107
|
+
const server = this.activeServer;
|
|
108
|
+
if (server &&
|
|
108
109
|
data.features &&
|
|
109
110
|
data.features.length >= 2 &&
|
|
110
111
|
data.features.length <= 10) {
|
|
@@ -122,7 +123,7 @@ export class SearchAndGeocodeTool extends MapboxApiBasedTool {
|
|
|
122
123
|
return { value: String(index), label };
|
|
123
124
|
});
|
|
124
125
|
// Create a JSON Schema with enum for the selection
|
|
125
|
-
const result = await
|
|
126
|
+
const result = await server.server.elicitInput({
|
|
126
127
|
mode: 'form',
|
|
127
128
|
message: `Found ${data.features.length} results for "${input.q}". Please select the correct location:`,
|
|
128
129
|
requestedSchema: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchAndGeocodeTool.js","sourceRoot":"","sources":["../../../../src/tools/search-and-geocode-tool/SearchAndGeocodeTool.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAGlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EACL,uBAAuB,EAExB,MAAM,yCAAyC,CAAC;AAMjD,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,mFAAmF;AAEnF,MAAM,OAAO,oBAAqB,SAAQ,kBAGzC;IACC,IAAI,GAAG,yBAAyB,CAAC;IACjC,WAAW,GACT,
|
|
1
|
+
{"version":3,"file":"SearchAndGeocodeTool.js","sourceRoot":"","sources":["../../../../src/tools/search-and-geocode-tool/SearchAndGeocodeTool.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCA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,KAAK,CAAC,kBAAkB;YAC5C,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,gBAAgB;SACjB,CAAC,CAAC;QACH,MAAM,EAAE,GAAG;YACT,GAAI,CAAC,IAAI,CAAC,iBAAiB,IAAI,EAAE,CAA6B;YAC9D,YAAY,EAAE,EAAE,GAAG,EAAE;SACtB,CAAC;QACF,uEAAuE;QACvE,kDAAkD;QAClD,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAChD,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM;YAC1B,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAG,CAAC,CAAC,IAAe,GAAG,UAAU,CAAC,GAAG,CAAC,EAAE;YACtD,CAAC,CAAC,CAAC,CACN,CAAC;QACF,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,EAAE,EAAE,CAAC;IACrD,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StaticMapImageTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/static-map-image-tool/StaticMapImageTool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAyBzE,qBAAa,kBAAmB,SAAQ,kBAAkB,CACxD,OAAO,yBAAyB,CACjC;IACC,IAAI,SAA2B;IAC/B,WAAW,
|
|
1
|
+
{"version":3,"file":"StaticMapImageTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/static-map-image-tool/StaticMapImageTool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAyBzE,qBAAa,kBAAmB,SAAQ,kBAAkB,CACxD,OAAO,yBAAyB,CACjC;IACC,IAAI,SAA2B;IAC/B,WAAW,SAC6Y;IACxZ,WAAW;;;;;;MAMT;gBAEU,MAAM,EAAE;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE;IAOhD,OAAO,CAAC,aAAa;cAkDL,OAAO,CACrB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,EAChD,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,cAAc,CAAC;CAsE3B"}
|
|
@@ -4,7 +4,7 @@ import { randomUUID, randomBytes } from 'node:crypto';
|
|
|
4
4
|
import { MapboxApiBasedTool } from '../MapboxApiBasedTool.js';
|
|
5
5
|
import { StaticMapImageInputSchema } from './StaticMapImageTool.input.schema.js';
|
|
6
6
|
import { temporaryResourceManager } from '../../utils/temporaryResourceManager.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getOwnerKeyFromToken } from '../../utils/jwtUtils.js';
|
|
8
8
|
// Images larger than this threshold are stored as temporary resources instead
|
|
9
9
|
// of being inlined as base64, to avoid exceeding Claude Desktop's 1MB tool
|
|
10
10
|
// result limit. base64 adds ~33% overhead, so 700KB raw ≈ 933KB encoded.
|
|
@@ -23,7 +23,7 @@ function encodeOverlayComponent(value) {
|
|
|
23
23
|
}
|
|
24
24
|
export class StaticMapImageTool extends MapboxApiBasedTool {
|
|
25
25
|
name = 'static_map_image_tool';
|
|
26
|
-
description = 'Generates a static map image from Mapbox Static Images API. Supports center coordinates, zoom level (0-22), image size (up to 1280x1280), various Mapbox styles, and overlays (markers, paths, GeoJSON). Returns PNG for vector styles, JPEG for raster-only styles.';
|
|
26
|
+
description = 'Generates a static map image from Mapbox Static Images API. Supports center coordinates, zoom level (0-22), image size (up to 1280x1280), various Mapbox styles, and overlays (markers, paths, GeoJSON). Returns PNG for vector styles, JPEG for raster-only styles. Use only when the user explicitly asks for a static image file — to show a map, use render_map_tool instead, which renders an interactive map.';
|
|
27
27
|
annotations = {
|
|
28
28
|
title: 'Static Map Image Tool',
|
|
29
29
|
readOnlyHint: true,
|
|
@@ -122,7 +122,7 @@ export class StaticMapImageTool extends MapboxApiBasedTool {
|
|
|
122
122
|
data: base64Data,
|
|
123
123
|
metadata: { toolName: this.name, size: buffer.byteLength },
|
|
124
124
|
mimeType,
|
|
125
|
-
owner:
|
|
125
|
+
owner: getOwnerKeyFromToken(accessToken)
|
|
126
126
|
});
|
|
127
127
|
content.push({
|
|
128
128
|
type: 'text',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StaticMapImageTool.js","sourceRoot":"","sources":["../../../../src/tools/static-map-image-tool/StaticMapImageTool.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAGjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,8EAA8E;AAC9E,2EAA2E;AAC3E,yEAAyE;AACzE,MAAM,sBAAsB,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,QAAQ;AAEnD,4EAA4E;AAC5E,qE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OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO;YACL,OAAO;YACP,OAAO,EAAE,KAAK;YACd,KAAK,EAAE;gBACL,QAAQ,EAAE,UAAU,EAAE;aACvB;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -34,4 +34,6 @@ export { RedactingSpanExporter } from './redactingSpanExporter.js';
|
|
|
34
34
|
export { redactToken } from './redactToken.js';
|
|
35
35
|
export { getVersionInfo } from './versionUtils.js';
|
|
36
36
|
export type { VersionInfo } from './versionUtils.js';
|
|
37
|
+
export { publishJsonSchema2020, toJsonSchema2020 } from './jsonSchema2020.js';
|
|
38
|
+
export { buildServerInstructions } from './serverInstructions.js';
|
|
37
39
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGpE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,WAAW,EACX,aAAa,EACb,KAAK,UAAU,EAChB,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAKjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGpE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,WAAW,EACX,aAAa,EACb,KAAK,UAAU,EAChB,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAKjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMrD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -40,4 +40,10 @@ export { RedactingSpanExporter } from './redactingSpanExporter.js';
|
|
|
40
40
|
export { redactToken } from './redactToken.js';
|
|
41
41
|
// Export version utilities
|
|
42
42
|
export { getVersionInfo } from './versionUtils.js';
|
|
43
|
+
// Export server setup helpers for consumers building their own McpServer
|
|
44
|
+
// (e.g. a hosted deployment) rather than running this package's entry point.
|
|
45
|
+
// Call publishJsonSchema2020(server) before installing any tool, and pass
|
|
46
|
+
// buildServerInstructions(<enabled tool names>) as the server's instructions.
|
|
47
|
+
export { publishJsonSchema2020, toJsonSchema2020 } from './jsonSchema2020.js';
|
|
48
|
+
export { buildServerInstructions } from './serverInstructions.js';
|
|
43
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,kDAAkD;AAClD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEpE,mEAAmE;AACnE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,WAAW,EACX,aAAa,EAEd,MAAM,mBAAmB,CAAC;AAK3B,8EAA8E;AAC9E,iFAAiF;AACjF,0EAA0E;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,2BAA2B;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,kDAAkD;AAClD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEpE,mEAAmE;AACnE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,WAAW,EACX,aAAa,EAEd,MAAM,mBAAmB,CAAC;AAK3B,8EAA8E;AAC9E,iFAAiF;AACjF,0EAA0E;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,2BAA2B;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,yEAAyE;AACzE,6EAA6E;AAC7E,0EAA0E;AAC1E,8EAA8E;AAC9E,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
export declare const JSON_SCHEMA_2020_12 = "https://json-schema.org/draft/2020-12/schema";
|
|
3
|
+
/**
|
|
4
|
+
* Convert a draft-07 root schema to JSON Schema 2020-12 and label it as
|
|
5
|
+
* such. A schema that already declares another dialect is returned
|
|
6
|
+
* unchanged.
|
|
7
|
+
*/
|
|
8
|
+
export declare function toJsonSchema2020(schema: unknown): unknown;
|
|
9
|
+
/**
|
|
10
|
+
* Make `tools/list` publish JSON Schema 2020-12 instead of draft-07.
|
|
11
|
+
*
|
|
12
|
+
* MCP SDK 1.x's McpServer generates every tool's inputSchema/outputSchema
|
|
13
|
+
* as draft-07 (with no option to change it), but MCP specifies 2020-12 as
|
|
14
|
+
* the default dialect, and newer clients enforce that — Claude Desktop
|
|
15
|
+
* refuses to call any tool whose outputSchema declares draft-07 ("JSON
|
|
16
|
+
* Schema declares an unsupported dialect ... The default validator
|
|
17
|
+
* supports JSON Schema 2020-12 only").
|
|
18
|
+
*
|
|
19
|
+
* McpServer installs its tools/list handler through the public
|
|
20
|
+
* setRequestHandler on first tool registration, so this wraps that method
|
|
21
|
+
* on this one server instance (not a global patch) and converts the
|
|
22
|
+
* schemas in the handler's result. Must be called before any tool is
|
|
23
|
+
* registered.
|
|
24
|
+
*/
|
|
25
|
+
export declare function publishJsonSchema2020(server: McpServer): void;
|
|
26
|
+
//# sourceMappingURL=jsonSchema2020.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonSchema2020.d.ts","sourceRoot":"","sources":["../../../src/utils/jsonSchema2020.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,eAAO,MAAM,mBAAmB,iDACgB,CAAC;AAmFjD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAQzD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA2B7D"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// Copyright (c) Mapbox, Inc.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import { ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
export const JSON_SCHEMA_2020_12 = 'https://json-schema.org/draft/2020-12/schema';
|
|
5
|
+
const JSON_SCHEMA_DRAFT_07 = 'http://json-schema.org/draft-07/schema#';
|
|
6
|
+
function isObject(value) {
|
|
7
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
// Keywords whose value is a single subschema.
|
|
10
|
+
const SUBSCHEMA_KEYWORDS = [
|
|
11
|
+
'additionalProperties',
|
|
12
|
+
'contains',
|
|
13
|
+
'propertyNames',
|
|
14
|
+
'not',
|
|
15
|
+
'if',
|
|
16
|
+
'then',
|
|
17
|
+
'else'
|
|
18
|
+
];
|
|
19
|
+
// Keywords whose value is an array of subschemas.
|
|
20
|
+
const SUBSCHEMA_ARRAY_KEYWORDS = ['anyOf', 'oneOf', 'allOf'];
|
|
21
|
+
// Keywords whose value maps names to subschemas — the names themselves are
|
|
22
|
+
// data (e.g. a property literally called "items"), never keywords.
|
|
23
|
+
const SUBSCHEMA_MAP_KEYWORDS = [
|
|
24
|
+
'properties',
|
|
25
|
+
'patternProperties',
|
|
26
|
+
'$defs',
|
|
27
|
+
'dependentSchemas'
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* Convert one draft-07 schema node (and everything under it) to its JSON
|
|
31
|
+
* Schema 2020-12 equivalent. Covers what zod's draft-07 output can contain:
|
|
32
|
+
* tuple `items: [...]` → `prefixItems` (with `additionalItems` → `items`),
|
|
33
|
+
* `definitions` → `$defs` (and `#/definitions/` refs to match). Walks only
|
|
34
|
+
* real subschema positions, so property names are never mistaken for
|
|
35
|
+
* keywords.
|
|
36
|
+
*/
|
|
37
|
+
function convertNode(node) {
|
|
38
|
+
if (!isObject(node))
|
|
39
|
+
return node;
|
|
40
|
+
const out = { ...node };
|
|
41
|
+
if ('definitions' in out) {
|
|
42
|
+
out.$defs = { ...out.$defs, ...out.definitions };
|
|
43
|
+
delete out.definitions;
|
|
44
|
+
}
|
|
45
|
+
if (typeof out.$ref === 'string' && out.$ref.startsWith('#/definitions/')) {
|
|
46
|
+
out.$ref = '#/$defs/' + out.$ref.slice('#/definitions/'.length);
|
|
47
|
+
}
|
|
48
|
+
if (Array.isArray(out.items)) {
|
|
49
|
+
out.prefixItems = out.items.map(convertNode);
|
|
50
|
+
if ('additionalItems' in out) {
|
|
51
|
+
out.items = convertNode(out.additionalItems);
|
|
52
|
+
delete out.additionalItems;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
delete out.items;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if ('items' in out) {
|
|
59
|
+
out.items = convertNode(out.items);
|
|
60
|
+
}
|
|
61
|
+
for (const key of SUBSCHEMA_KEYWORDS) {
|
|
62
|
+
if (key in out)
|
|
63
|
+
out[key] = convertNode(out[key]);
|
|
64
|
+
}
|
|
65
|
+
for (const key of SUBSCHEMA_ARRAY_KEYWORDS) {
|
|
66
|
+
if (Array.isArray(out[key])) {
|
|
67
|
+
out[key] = out[key].map(convertNode);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const key of SUBSCHEMA_MAP_KEYWORDS) {
|
|
71
|
+
if (isObject(out[key])) {
|
|
72
|
+
out[key] = Object.fromEntries(Object.entries(out[key]).map(([name, sub]) => [
|
|
73
|
+
name,
|
|
74
|
+
convertNode(sub)
|
|
75
|
+
]));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Convert a draft-07 root schema to JSON Schema 2020-12 and label it as
|
|
82
|
+
* such. A schema that already declares another dialect is returned
|
|
83
|
+
* unchanged.
|
|
84
|
+
*/
|
|
85
|
+
export function toJsonSchema2020(schema) {
|
|
86
|
+
if (!isObject(schema))
|
|
87
|
+
return schema;
|
|
88
|
+
if (schema.$schema !== undefined && schema.$schema !== JSON_SCHEMA_DRAFT_07) {
|
|
89
|
+
return schema;
|
|
90
|
+
}
|
|
91
|
+
const converted = convertNode(schema);
|
|
92
|
+
converted.$schema = JSON_SCHEMA_2020_12;
|
|
93
|
+
return converted;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Make `tools/list` publish JSON Schema 2020-12 instead of draft-07.
|
|
97
|
+
*
|
|
98
|
+
* MCP SDK 1.x's McpServer generates every tool's inputSchema/outputSchema
|
|
99
|
+
* as draft-07 (with no option to change it), but MCP specifies 2020-12 as
|
|
100
|
+
* the default dialect, and newer clients enforce that — Claude Desktop
|
|
101
|
+
* refuses to call any tool whose outputSchema declares draft-07 ("JSON
|
|
102
|
+
* Schema declares an unsupported dialect ... The default validator
|
|
103
|
+
* supports JSON Schema 2020-12 only").
|
|
104
|
+
*
|
|
105
|
+
* McpServer installs its tools/list handler through the public
|
|
106
|
+
* setRequestHandler on first tool registration, so this wraps that method
|
|
107
|
+
* on this one server instance (not a global patch) and converts the
|
|
108
|
+
* schemas in the handler's result. Must be called before any tool is
|
|
109
|
+
* registered.
|
|
110
|
+
*/
|
|
111
|
+
export function publishJsonSchema2020(server) {
|
|
112
|
+
const inner = server.server;
|
|
113
|
+
const listToolsMethod = ListToolsRequestSchema.shape.method.value;
|
|
114
|
+
const original = inner.setRequestHandler.bind(inner);
|
|
115
|
+
// setRequestHandler's generic signature can't be expressed for a wrapper
|
|
116
|
+
// without re-declaring the SDK's internal schema types.
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
+
inner.setRequestHandler = (requestSchema, handler) => {
|
|
119
|
+
if (requestSchema?.shape?.method?.value !== listToolsMethod) {
|
|
120
|
+
return original(requestSchema, handler);
|
|
121
|
+
}
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
123
|
+
return original(requestSchema, async (request, extra) => {
|
|
124
|
+
const result = await handler(request, extra);
|
|
125
|
+
return {
|
|
126
|
+
...result,
|
|
127
|
+
tools: result.tools.map((tool) => ({
|
|
128
|
+
...tool,
|
|
129
|
+
inputSchema: toJsonSchema2020(tool.inputSchema),
|
|
130
|
+
...(tool.outputSchema !== undefined && {
|
|
131
|
+
outputSchema: toJsonSchema2020(tool.outputSchema)
|
|
132
|
+
})
|
|
133
|
+
}))
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=jsonSchema2020.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonSchema2020.js","sourceRoot":"","sources":["../../../src/utils/jsonSchema2020.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAGlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,MAAM,CAAC,MAAM,mBAAmB,GAC9B,8CAA8C,CAAC;AACjD,MAAM,oBAAoB,GAAG,yCAAyC,CAAC;AAIvE,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,8CAA8C;AAC9C,MAAM,kBAAkB,GAAG;IACzB,sBAAsB;IACtB,UAAU;IACV,eAAe;IACf,KAAK;IACL,IAAI;IACJ,MAAM;IACN,MAAM;CACP,CAAC;AACF,kDAAkD;AAClD,MAAM,wBAAwB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC7D,2EAA2E;AAC3E,mEAAmE;AACnE,MAAM,sBAAsB,GAAG;IAC7B,YAAY;IACZ,mBAAmB;IACnB,OAAO;IACP,kBAAkB;CACnB,CAAC;AAEF;;;;;;;GAOG;AACH,SAAS,WAAW,CAAC,IAAa;IAChC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE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E,MAAM,QAAQ,GAAG,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAErD,yEAAyE;IACzE,wDAAwD;IACxD,8DAA8D;IAC7D,KAAa,CAAC,iBAAiB,GAAG,CAAC,aAAkB,EAAE,OAAY,EAAE,EAAE;QACtE,IAAI,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,KAAK,eAAe,EAAE,CAAC;YAC5D,OAAO,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;QACD,8DAA8D;QAC9D,OAAO,QAAQ,CAAC,aAAa,EAAE,KAAK,EAAE,OAAY,EAAE,KAAU,EAAE,EAAE;YAChE,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC7C,OAAO;gBACL,GAAG,MAAM;gBACT,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC;oBACzC,GAAG,IAAI;oBACP,WAAW,EAAE,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC;oBAC/C,GAAG,CAAC,IAAI,CAAC,YAAY,KAAK,SAAS,IAAI;wBACrC,YAAY,EAAE,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC;qBAClD,CAAC;iBACH,CAAC,CAAC;aACJ,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -4,6 +4,54 @@
|
|
|
4
4
|
* Mapbox tokens are JWTs whose payload contains the username under the `u` key.
|
|
5
5
|
* Returns undefined if the token is malformed or missing the `u` field — callers
|
|
6
6
|
* can decide whether to surface an error or fall back to another auth path.
|
|
7
|
+
*
|
|
8
|
+
* SECURITY: the returned name is an UNVERIFIED claim. This decodes the payload
|
|
9
|
+
* without checking the signature (Mapbox signs with a secret only Mapbox holds,
|
|
10
|
+
* so it cannot be checked here), which means any caller can fabricate a token
|
|
11
|
+
* asserting any username. Use this only where the value is non-authoritative —
|
|
12
|
+
* e.g. building a `/tokens/v2/{username}` request URL, where a forged name
|
|
13
|
+
* simply makes the Mapbox API reject the call. Never use it to decide whether
|
|
14
|
+
* one caller may read another caller's data; use {@link getOwnerKeyFromToken}
|
|
15
|
+
* and {@link ownerKeyMatches} for that.
|
|
7
16
|
*/
|
|
8
17
|
export declare function getUserNameFromToken(token: string): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Derive the ownership key used to scope temporary resources to the caller.
|
|
20
|
+
*
|
|
21
|
+
* This is a SHA-256 fingerprint of the raw token string — NOT the `u` claim.
|
|
22
|
+
* The distinction is the whole point: `getUserNameFromToken` reads an
|
|
23
|
+
* *unverified* claim out of a token payload that anyone can fabricate, because
|
|
24
|
+
* Mapbox signs its tokens with a secret only Mapbox holds and this server
|
|
25
|
+
* therefore cannot check the signature locally. Scoping a resource by username
|
|
26
|
+
* means anyone who learns a resource URI and a Mapbox username can mint a
|
|
27
|
+
* garbage token asserting `{"u":"<victim>"}` and read that resource.
|
|
28
|
+
*
|
|
29
|
+
* Fingerprinting the token instead makes the check depend on bytes the attacker
|
|
30
|
+
* would have to already possess. An attacker holding the victim's real token
|
|
31
|
+
* does not need this path at all — they can call the Mapbox API directly — so
|
|
32
|
+
* the bypass stops being worth anything. No signature verification and no
|
|
33
|
+
* network round-trip to an introspection endpoint are required, which keeps
|
|
34
|
+
* resource reads at the O(1) cost the temporary-resource cache exists to
|
|
35
|
+
* preserve.
|
|
36
|
+
*
|
|
37
|
+
* Tradeoff: ownership is now per-token rather than per-account. A caller that
|
|
38
|
+
* rotates to a different token mid-session can no longer read resources it
|
|
39
|
+
* created under the previous one; those reads fail closed and surface as the
|
|
40
|
+
* normal "not found or expired" response. With a 30-minute TTL this is a narrow
|
|
41
|
+
* window, and failing closed is the correct direction for an authorization
|
|
42
|
+
* check.
|
|
43
|
+
*
|
|
44
|
+
* Returns undefined for an empty/absent token so callers keep failing closed.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getOwnerKeyFromToken(token: string | undefined): string | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Compare two ownership keys from {@link getOwnerKeyFromToken}.
|
|
49
|
+
*
|
|
50
|
+
* Fails closed when either side is undefined — an unowned resource is never
|
|
51
|
+
* readable. The comparison is constant-time so the check cannot be probed
|
|
52
|
+
* byte-by-byte; SHA-256 preimage resistance already makes a leaked digest
|
|
53
|
+
* useless, but an authorization comparison on a credential-derived value has no
|
|
54
|
+
* reason not to be constant-time.
|
|
55
|
+
*/
|
|
56
|
+
export declare function ownerKeyMatches(expected: string | undefined, actual: string | undefined): boolean;
|
|
9
57
|
//# sourceMappingURL=jwtUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwtUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/jwtUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jwtUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/jwtUtils.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAWtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,GAAG,SAAS,CAGpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,OAAO,CAMT"}
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
// Copyright (c) Mapbox, Inc.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
+
import { createHash, timingSafeEqual } from 'node:crypto';
|
|
3
4
|
/**
|
|
4
5
|
* Extract the Mapbox username from a JWT access token.
|
|
5
6
|
*
|
|
6
7
|
* Mapbox tokens are JWTs whose payload contains the username under the `u` key.
|
|
7
8
|
* Returns undefined if the token is malformed or missing the `u` field — callers
|
|
8
9
|
* can decide whether to surface an error or fall back to another auth path.
|
|
10
|
+
*
|
|
11
|
+
* SECURITY: the returned name is an UNVERIFIED claim. This decodes the payload
|
|
12
|
+
* without checking the signature (Mapbox signs with a secret only Mapbox holds,
|
|
13
|
+
* so it cannot be checked here), which means any caller can fabricate a token
|
|
14
|
+
* asserting any username. Use this only where the value is non-authoritative —
|
|
15
|
+
* e.g. building a `/tokens/v2/{username}` request URL, where a forged name
|
|
16
|
+
* simply makes the Mapbox API reject the call. Never use it to decide whether
|
|
17
|
+
* one caller may read another caller's data; use {@link getOwnerKeyFromToken}
|
|
18
|
+
* and {@link ownerKeyMatches} for that.
|
|
9
19
|
*/
|
|
10
20
|
export function getUserNameFromToken(token) {
|
|
11
21
|
const parts = token.split('.');
|
|
@@ -19,4 +29,55 @@ export function getUserNameFromToken(token) {
|
|
|
19
29
|
return undefined;
|
|
20
30
|
}
|
|
21
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Derive the ownership key used to scope temporary resources to the caller.
|
|
34
|
+
*
|
|
35
|
+
* This is a SHA-256 fingerprint of the raw token string — NOT the `u` claim.
|
|
36
|
+
* The distinction is the whole point: `getUserNameFromToken` reads an
|
|
37
|
+
* *unverified* claim out of a token payload that anyone can fabricate, because
|
|
38
|
+
* Mapbox signs its tokens with a secret only Mapbox holds and this server
|
|
39
|
+
* therefore cannot check the signature locally. Scoping a resource by username
|
|
40
|
+
* means anyone who learns a resource URI and a Mapbox username can mint a
|
|
41
|
+
* garbage token asserting `{"u":"<victim>"}` and read that resource.
|
|
42
|
+
*
|
|
43
|
+
* Fingerprinting the token instead makes the check depend on bytes the attacker
|
|
44
|
+
* would have to already possess. An attacker holding the victim's real token
|
|
45
|
+
* does not need this path at all — they can call the Mapbox API directly — so
|
|
46
|
+
* the bypass stops being worth anything. No signature verification and no
|
|
47
|
+
* network round-trip to an introspection endpoint are required, which keeps
|
|
48
|
+
* resource reads at the O(1) cost the temporary-resource cache exists to
|
|
49
|
+
* preserve.
|
|
50
|
+
*
|
|
51
|
+
* Tradeoff: ownership is now per-token rather than per-account. A caller that
|
|
52
|
+
* rotates to a different token mid-session can no longer read resources it
|
|
53
|
+
* created under the previous one; those reads fail closed and surface as the
|
|
54
|
+
* normal "not found or expired" response. With a 30-minute TTL this is a narrow
|
|
55
|
+
* window, and failing closed is the correct direction for an authorization
|
|
56
|
+
* check.
|
|
57
|
+
*
|
|
58
|
+
* Returns undefined for an empty/absent token so callers keep failing closed.
|
|
59
|
+
*/
|
|
60
|
+
export function getOwnerKeyFromToken(token) {
|
|
61
|
+
if (!token)
|
|
62
|
+
return undefined;
|
|
63
|
+
return createHash('sha256').update(token, 'utf-8').digest('hex');
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Compare two ownership keys from {@link getOwnerKeyFromToken}.
|
|
67
|
+
*
|
|
68
|
+
* Fails closed when either side is undefined — an unowned resource is never
|
|
69
|
+
* readable. The comparison is constant-time so the check cannot be probed
|
|
70
|
+
* byte-by-byte; SHA-256 preimage resistance already makes a leaked digest
|
|
71
|
+
* useless, but an authorization comparison on a credential-derived value has no
|
|
72
|
+
* reason not to be constant-time.
|
|
73
|
+
*/
|
|
74
|
+
export function ownerKeyMatches(expected, actual) {
|
|
75
|
+
if (!expected || !actual)
|
|
76
|
+
return false;
|
|
77
|
+
const a = Buffer.from(expected, 'utf-8');
|
|
78
|
+
const b = Buffer.from(actual, 'utf-8');
|
|
79
|
+
if (a.length !== b.length)
|
|
80
|
+
return false;
|
|
81
|
+
return timingSafeEqual(a, b);
|
|
82
|
+
}
|
|
22
83
|
//# sourceMappingURL=jwtUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwtUtils.js","sourceRoot":"","sources":["../../../src/utils/jwtUtils.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAElC
|
|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