@mapbox/mcp-server 0.2.1-dev.1 → 0.2.1-dev.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +85 -4
  2. package/dist/index.js +0 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/tools/MapboxApiBasedTool.d.ts +7 -0
  5. package/dist/tools/MapboxApiBasedTool.d.ts.map +1 -1
  6. package/dist/tools/MapboxApiBasedTool.js +24 -2
  7. package/dist/tools/MapboxApiBasedTool.js.map +1 -1
  8. package/dist/tools/MapboxApiBasedTool.test.d.ts +2 -0
  9. package/dist/tools/MapboxApiBasedTool.test.d.ts.map +1 -0
  10. package/dist/tools/MapboxApiBasedTool.test.js +143 -0
  11. package/dist/tools/MapboxApiBasedTool.test.js.map +1 -0
  12. package/dist/tools/category-search-tool/CategorySearchTool.d.ts +55 -6
  13. package/dist/tools/category-search-tool/CategorySearchTool.d.ts.map +1 -1
  14. package/dist/tools/category-search-tool/CategorySearchTool.js +47 -19
  15. package/dist/tools/category-search-tool/CategorySearchTool.js.map +1 -1
  16. package/dist/tools/category-search-tool/CategorySearchTool.test.js +90 -10
  17. package/dist/tools/category-search-tool/CategorySearchTool.test.js.map +1 -1
  18. package/dist/tools/directions-tool/DirectionsTool.d.ts +4 -14
  19. package/dist/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
  20. package/dist/tools/directions-tool/DirectionsTool.js +31 -55
  21. package/dist/tools/directions-tool/DirectionsTool.js.map +1 -1
  22. package/dist/tools/directions-tool/DirectionsTool.test.js +115 -160
  23. package/dist/tools/directions-tool/DirectionsTool.test.js.map +1 -1
  24. package/dist/tools/directions-tool/cleanResponseData.d.ts +11 -0
  25. package/dist/tools/directions-tool/cleanResponseData.d.ts.map +1 -0
  26. package/dist/tools/directions-tool/cleanResponseData.js +175 -0
  27. package/dist/tools/directions-tool/cleanResponseData.js.map +1 -0
  28. package/dist/tools/directions-tool/cleanResponseData.test.d.ts +2 -0
  29. package/dist/tools/directions-tool/cleanResponseData.test.d.ts.map +1 -0
  30. package/dist/tools/directions-tool/cleanResponseData.test.js +295 -0
  31. package/dist/tools/directions-tool/cleanResponseData.test.js.map +1 -0
  32. package/dist/tools/directions-tool/formatIsoDateTime.d.ts +8 -0
  33. package/dist/tools/directions-tool/formatIsoDateTime.d.ts.map +1 -0
  34. package/dist/tools/directions-tool/formatIsoDateTime.js +17 -0
  35. package/dist/tools/directions-tool/formatIsoDateTime.js.map +1 -0
  36. package/dist/tools/directions-tool/formatIsoDateTime.test.d.ts +2 -0
  37. package/dist/tools/directions-tool/formatIsoDateTime.test.d.ts.map +1 -0
  38. package/dist/tools/directions-tool/formatIsoDateTime.test.js +26 -0
  39. package/dist/tools/directions-tool/formatIsoDateTime.test.js.map +1 -0
  40. package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.d.ts +55 -9
  41. package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.d.ts.map +1 -1
  42. package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.js +44 -21
  43. package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.js.map +1 -1
  44. package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.js +90 -10
  45. package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.js.map +1 -1
  46. package/dist/tools/isochrone-tool/IsochroneTool.d.ts +18 -3
  47. package/dist/tools/isochrone-tool/IsochroneTool.d.ts.map +1 -1
  48. package/dist/tools/isochrone-tool/IsochroneTool.js +6 -3
  49. package/dist/tools/isochrone-tool/IsochroneTool.js.map +1 -1
  50. package/dist/tools/isochrone-tool/IsochroneTool.test.js +8 -7
  51. package/dist/tools/isochrone-tool/IsochroneTool.test.js.map +1 -1
  52. package/dist/tools/matrix-tool/MatrixTool.d.ts +18 -3
  53. package/dist/tools/matrix-tool/MatrixTool.d.ts.map +1 -1
  54. package/dist/tools/matrix-tool/MatrixTool.js +6 -6
  55. package/dist/tools/matrix-tool/MatrixTool.js.map +1 -1
  56. package/dist/tools/matrix-tool/MatrixTool.test.js +128 -115
  57. package/dist/tools/matrix-tool/MatrixTool.test.js.map +1 -1
  58. package/dist/tools/poi-search-tool/PoiSearchTool.d.ts +73 -9
  59. package/dist/tools/poi-search-tool/PoiSearchTool.d.ts.map +1 -1
  60. package/dist/tools/poi-search-tool/PoiSearchTool.js +53 -22
  61. package/dist/tools/poi-search-tool/PoiSearchTool.js.map +1 -1
  62. package/dist/tools/poi-search-tool/PoiSearchTool.test.js +90 -10
  63. package/dist/tools/poi-search-tool/PoiSearchTool.test.js.map +1 -1
  64. package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts +5 -2
  65. package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts.map +1 -1
  66. package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.js +13 -3
  67. package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.js.map +1 -1
  68. package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.js +70 -7
  69. package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.js.map +1 -1
  70. package/dist/tools/static-map-image-tool/StaticMapImageTool.d.ts +36 -6
  71. package/dist/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
  72. package/dist/tools/static-map-image-tool/StaticMapImageTool.js +12 -9
  73. package/dist/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
  74. package/dist/tools/static-map-image-tool/StaticMapImageTool.test.js +48 -47
  75. package/dist/tools/static-map-image-tool/StaticMapImageTool.test.js.map +1 -1
  76. package/dist/utils/requestUtils.d.ts.map +1 -1
  77. package/dist/utils/requestUtils.js +33 -2
  78. package/dist/utils/requestUtils.js.map +1 -1
  79. package/dist/utils/requestUtils.test-helpers.d.ts.map +1 -1
  80. package/dist/utils/requestUtils.test-helpers.js +5 -1
  81. package/dist/utils/requestUtils.test-helpers.js.map +1 -1
  82. package/dist/utils/requestUtils.test.d.ts +2 -0
  83. package/dist/utils/requestUtils.test.d.ts.map +1 -0
  84. package/dist/utils/requestUtils.test.js +115 -0
  85. package/dist/utils/requestUtils.test.js.map +1 -0
  86. package/dist/version.json +4 -4
  87. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanResponseData.test.d.ts","sourceRoot":"","sources":["../../../src/tools/directions-tool/cleanResponseData.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,295 @@
1
+ import { cleanResponseData } from './cleanResponseData.js';
2
+ describe('cleanResponseData', () => {
3
+ // Create a complete mock input that satisfies the DirectionsInputSchema
4
+ const mockInput = {
5
+ coordinates: [
6
+ [0, 0],
7
+ [1, 1]
8
+ ], // Use a proper tuple type
9
+ routing_profile: 'driving-traffic',
10
+ geometries: 'none',
11
+ alternatives: false
12
+ };
13
+ it('should remove unnecessary keys', () => {
14
+ const mockData = {
15
+ uuid: '12345',
16
+ code: 'Ok',
17
+ routes: []
18
+ };
19
+ const result = cleanResponseData(mockInput, mockData);
20
+ expect(result.uuid).toBeUndefined();
21
+ expect(result.code).toBeUndefined();
22
+ });
23
+ it('should rename waypoint location and distance properties', () => {
24
+ const mockData = {
25
+ waypoints: [
26
+ {
27
+ name: 'Test',
28
+ location: [-73.989, 40.733],
29
+ distance: 10.5
30
+ }
31
+ ],
32
+ routes: []
33
+ };
34
+ const result = cleanResponseData(mockInput, mockData);
35
+ expect(result.waypoints[0].location).toBeUndefined();
36
+ expect(result.waypoints[0].snap_location).toEqual([-73.989, 40.733]);
37
+ expect(result.waypoints[0].distance).toBeUndefined();
38
+ expect(result.waypoints[0].snap_distance).toBe(11); // Rounded from 10.5
39
+ });
40
+ it('should round duration and distance', () => {
41
+ const mockData = {
42
+ routes: [
43
+ {
44
+ duration: 1234.56,
45
+ distance: 5678.91,
46
+ legs: []
47
+ }
48
+ ]
49
+ };
50
+ const result = cleanResponseData(mockInput, mockData);
51
+ expect(result.routes[0].duration).toBe(1235);
52
+ expect(result.routes[0].distance).toBe(5679);
53
+ });
54
+ it('should delete geometry when geometries is set to none', () => {
55
+ const mockData = {
56
+ routes: [
57
+ {
58
+ geometry: 'someGeometryData',
59
+ legs: []
60
+ }
61
+ ]
62
+ };
63
+ const result = cleanResponseData(mockInput, mockData);
64
+ expect(result.routes[0].geometry).toBeUndefined();
65
+ });
66
+ it('should keep geometry when geometries is not none', () => {
67
+ const mockData = {
68
+ routes: [
69
+ {
70
+ geometry: 'someGeometryData',
71
+ legs: []
72
+ }
73
+ ]
74
+ };
75
+ // Override just the geometries property for this test
76
+ const geojsonInput = {
77
+ ...mockInput,
78
+ geometries: 'geojson'
79
+ };
80
+ const result = cleanResponseData(geojsonInput, mockData);
81
+ expect(result.routes[0].geometry).toBe('someGeometryData');
82
+ });
83
+ it('should process route data correctly', () => {
84
+ const mockData = {
85
+ routes: [
86
+ {
87
+ duration: 1200,
88
+ distance: 5000,
89
+ weight_name: 'routingWeight',
90
+ weight: 1500,
91
+ duration_typical: 1300,
92
+ weight_typical: 1600,
93
+ legs: [
94
+ {
95
+ summary: 'First leg summary',
96
+ admins: [{ iso_3166_1_alpha3: 'USA' }],
97
+ steps: []
98
+ },
99
+ {
100
+ summary: 'Second leg summary',
101
+ admins: [{ iso_3166_1_alpha3: 'CAN' }],
102
+ steps: []
103
+ }
104
+ ]
105
+ }
106
+ ]
107
+ };
108
+ const result = cleanResponseData(mockInput, mockData);
109
+ // Check if data is properly processed
110
+ expect(result.routes[0].weight_name).toBeUndefined();
111
+ expect(result.routes[0].weight).toBeUndefined();
112
+ expect(result.routes[0].leg_summaries).toEqual([
113
+ 'First leg summary',
114
+ 'Second leg summary'
115
+ ]);
116
+ expect(result.routes[0].duration_typical).toBeUndefined();
117
+ expect(result.routes[0].duration_under_typical_traffic_conditions).toBe(1300);
118
+ expect(result.routes[0].weight_typical).toBeUndefined();
119
+ expect(result.routes[0].intersecting_admins).toEqual(['USA', 'CAN']);
120
+ expect(result.routes[0].num_legs).toBe(2);
121
+ expect(result.routes[0].legs).toBeUndefined();
122
+ });
123
+ it('should handle notifications and collect unique messages', () => {
124
+ const mockData = {
125
+ routes: [
126
+ {
127
+ legs: [
128
+ {
129
+ notifications: [
130
+ { details: { message: 'Traffic ahead' } },
131
+ { details: { message: 'Road closure' } }
132
+ ],
133
+ summary: 'Leg 1'
134
+ },
135
+ {
136
+ notifications: [
137
+ { details: { message: 'Traffic ahead' } },
138
+ { details: { message: 'Construction zone' } }
139
+ ],
140
+ summary: 'Leg 2'
141
+ }
142
+ ]
143
+ }
144
+ ]
145
+ };
146
+ const result = cleanResponseData(mockInput, mockData);
147
+ expect(result.routes[0].notifications_summary).toEqual([
148
+ 'Traffic ahead',
149
+ 'Road closure',
150
+ 'Construction zone'
151
+ ]);
152
+ });
153
+ it('should process incidents information', () => {
154
+ const mockData = {
155
+ routes: [
156
+ {
157
+ legs: [
158
+ {
159
+ incidents: [
160
+ {
161
+ type: 'accident',
162
+ end_time: '2023-05-01T12:00:00Z',
163
+ long_description: 'Multiple vehicle collision',
164
+ impact: 'severe',
165
+ affected_road_names: ['Main St'],
166
+ length: 500,
167
+ extra_field: 'should not be included'
168
+ }
169
+ ],
170
+ summary: 'Leg with incident'
171
+ }
172
+ ]
173
+ }
174
+ ]
175
+ };
176
+ const result = cleanResponseData(mockInput, mockData);
177
+ expect(result.routes[0].incidents_summary).toHaveLength(1);
178
+ expect(result.routes[0].incidents_summary[0]).toEqual({
179
+ type: 'accident',
180
+ end_time: '2023-05-01T12:00:00Z',
181
+ long_description: 'Multiple vehicle collision',
182
+ impact: 'severe',
183
+ affected_road_names: ['Main St'],
184
+ length: 500
185
+ });
186
+ expect(result.routes[0].incidents_summary[0].extra_field).toBeUndefined();
187
+ });
188
+ it('should collect voice instructions when within limits', () => {
189
+ const mockData = {
190
+ routes: [
191
+ {
192
+ legs: [
193
+ {
194
+ steps: [
195
+ {
196
+ voiceInstructions: [
197
+ { announcement: 'Turn right in 100 meters' },
198
+ { announcement: 'Turn right now' }
199
+ ]
200
+ },
201
+ {
202
+ voiceInstructions: [
203
+ { announcement: 'Continue straight for 500 meters' }
204
+ ]
205
+ }
206
+ ],
207
+ summary: 'Leg with voice instructions'
208
+ }
209
+ ]
210
+ }
211
+ ]
212
+ };
213
+ const result = cleanResponseData(mockInput, mockData);
214
+ expect(result.routes[0].instructions).toEqual([
215
+ 'Turn right in 100 meters',
216
+ 'Turn right now',
217
+ 'Continue straight for 500 meters'
218
+ ]);
219
+ });
220
+ it('should not include instructions when there are too many', () => {
221
+ const mockData = {
222
+ routes: [
223
+ {
224
+ legs: [
225
+ {
226
+ steps: Array(6)
227
+ .fill(0)
228
+ .map(() => ({
229
+ voiceInstructions: [
230
+ { announcement: 'Instruction 1' },
231
+ { announcement: 'Instruction 2' }
232
+ ]
233
+ })),
234
+ summary: 'Leg with many instructions'
235
+ }
236
+ ]
237
+ }
238
+ ]
239
+ };
240
+ const result = cleanResponseData(mockInput, mockData);
241
+ // With 6 steps and 2 instructions each, we'd have 12 instructions total
242
+ // The function should exclude them since it's > 10
243
+ expect(result.routes[0].instructions).toBeUndefined();
244
+ });
245
+ it('should calculate congestion information correctly', () => {
246
+ const mockData = {
247
+ routes: [
248
+ {
249
+ legs: [
250
+ {
251
+ annotation: {
252
+ congestion: ['severe', 'heavy', 'moderate', 'low', 'unknown'],
253
+ distance: [100, 200, 300, 400, 500]
254
+ },
255
+ summary: 'Leg with congestion'
256
+ }
257
+ ]
258
+ }
259
+ ]
260
+ };
261
+ const result = cleanResponseData(mockInput, mockData);
262
+ expect(result.routes[0].congestion_information).toEqual({
263
+ length_severe: 100,
264
+ length_heavy: 200,
265
+ length_moderate: 300,
266
+ length_low: 400
267
+ });
268
+ // Note: 'unknown' congestion type is skipped
269
+ });
270
+ it('should calculate average speed correctly', () => {
271
+ const mockData = {
272
+ routes: [
273
+ {
274
+ legs: [
275
+ {
276
+ annotation: {
277
+ speed: [10, 20, 30], // m/s
278
+ distance: [100, 200, 300] // meters
279
+ },
280
+ summary: 'Leg with speed data'
281
+ }
282
+ ]
283
+ }
284
+ ]
285
+ };
286
+ const result = cleanResponseData(mockInput, mockData);
287
+ // Calculation:
288
+ // Weighted sum = 10*100 + 20*200 + 30*300 = 1000 + 4000 + 9000 = 14000
289
+ // Total distance = 100 + 200 + 300 = 600
290
+ // Average m/s = 14000/600 = 23.33
291
+ // Average km/h = 23.33 * 3.6 = 84 (rounded)
292
+ expect(result.routes[0].average_speed_kph).toBe(84);
293
+ });
294
+ });
295
+ //# sourceMappingURL=cleanResponseData.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanResponseData.test.js","sourceRoot":"","sources":["../../../src/tools/directions-tool/cleanResponseData.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,wEAAwE;IACxE,MAAM,SAAS,GAAG;QAChB,WAAW,EAAE;YACX,CAAC,CAAC,EAAE,CAAC,CAAC;YACN,CAAC,CAAC,EAAE,CAAC,CAAC;SACe,EAAE,0BAA0B;QACnD,eAAe,EAAE,iBAA0B;QAC3C,UAAU,EAAE,MAAe;QAC3B,YAAY,EAAE,KAAK;KACpB,CAAC;IAEF,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACxC,MAAM,QAAQ,GAAG;YACf,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,EAAE;SACX,CAAC;QAEF,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACtD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;QACpC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,QAAQ,GAAG;YACf,SAAS,EAAE;gBACT;oBACE,IAAI,EAAE,MAAM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G;SAChB,CAAC,CAAC;QACH,6CAA6C;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,QAAQ,GAAG;YACf,MAAM,EAAE;gBACN;oBACE,IAAI,EAAE;wBACJ;4BACE,UAAU,EAAE;gCACV,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM;gCAC3B,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,SAAS;6BACpC;4BACD,OAAO,EAAE,qBAAqB;yBAC/B;qBACF;iBACF;aACF;SACF,CAAC;QAEF,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAEtD,eAAe;QACf,uEAAuE;QACvE,yCAAyC;QACzC,kCAAkC;QAClC,4CAA4C;QAC5C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Helper function to format ISO datetime strings according to Mapbox API requirements.
3
+ * It converts the format YYYY-MM-DDThh:mm:ss (with seconds but no timezone) to
4
+ * YYYY-MM-DDThh:mm (no seconds, no timezone) by removing the seconds part.
5
+ * Other valid formats are left unchanged.
6
+ */
7
+ export declare const formatIsoDateTime: (dateTime: string) => string;
8
+ //# sourceMappingURL=formatIsoDateTime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatIsoDateTime.d.ts","sourceRoot":"","sources":["../../../src/tools/directions-tool/formatIsoDateTime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,KAAG,MAWpD,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Helper function to format ISO datetime strings according to Mapbox API requirements.
3
+ * It converts the format YYYY-MM-DDThh:mm:ss (with seconds but no timezone) to
4
+ * YYYY-MM-DDThh:mm (no seconds, no timezone) by removing the seconds part.
5
+ * Other valid formats are left unchanged.
6
+ */
7
+ export const formatIsoDateTime = (dateTime) => {
8
+ // Regex for matching YYYY-MM-DDThh:mm:ss format (with seconds but no timezone)
9
+ const dateWithSecondsNoTz = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/;
10
+ if (dateWithSecondsNoTz.test(dateTime)) {
11
+ // Extract up to the minutes part only, dropping the seconds
12
+ return dateTime.substring(0, dateTime.lastIndexOf(':'));
13
+ }
14
+ // Return unchanged if it's already in a valid format
15
+ return dateTime;
16
+ };
17
+ //# sourceMappingURL=formatIsoDateTime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatIsoDateTime.js","sourceRoot":"","sources":["../../../src/tools/directions-tool/formatIsoDateTime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAU,EAAE;IAC5D,+EAA+E;IAC/E,MAAM,mBAAmB,GAAG,uCAAuC,CAAC;IAEpE,IAAI,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACvC,4DAA4D;QAC5D,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,qDAAqD;IACrD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=formatIsoDateTime.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatIsoDateTime.test.d.ts","sourceRoot":"","sources":["../../../src/tools/directions-tool/formatIsoDateTime.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { formatIsoDateTime } from './formatIsoDateTime';
2
+ describe('formatIsoDateTime', () => {
3
+ it('converts YYYY-MM-DDThh:mm:ss to YYYY-MM-DDThh:mm by removing seconds', () => {
4
+ const input = '2025-06-05T10:30:45';
5
+ const expected = '2025-06-05T10:30';
6
+ expect(formatIsoDateTime(input)).toBe(expected);
7
+ });
8
+ it('leaves YYYY-MM-DDThh:mm:ssZ format unchanged', () => {
9
+ const input = '2025-06-05T10:30:45Z';
10
+ expect(formatIsoDateTime(input)).toBe(input);
11
+ });
12
+ it('leaves YYYY-MM-DDThh:mm:ss±hh:mm format unchanged', () => {
13
+ const input = '2025-06-05T10:30:45+02:00';
14
+ expect(formatIsoDateTime(input)).toBe(input);
15
+ });
16
+ it('leaves YYYY-MM-DDThh:mm format unchanged', () => {
17
+ const input = '2025-06-05T10:30';
18
+ expect(formatIsoDateTime(input)).toBe(input);
19
+ });
20
+ it('handles edge cases with zeros in seconds', () => {
21
+ const input = '2025-06-05T10:30:00';
22
+ const expected = '2025-06-05T10:30';
23
+ expect(formatIsoDateTime(input)).toBe(expected);
24
+ });
25
+ });
26
+ //# sourceMappingURL=formatIsoDateTime.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatIsoDateTime.test.js","sourceRoot":"","sources":["../../../src/tools/directions-tool/formatIsoDateTime.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,sEAAsE,EAAE,GAAG,EAAE;QAC9E,MAAM,KAAK,GAAG,qBAAqB,CAAC;QACpC,MAAM,QAAQ,GAAG,kBAAkB,CAAC;QAEpC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,KAAK,GAAG,sBAAsB,CAAC;QAErC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,KAAK,GAAG,2BAA2B,CAAC;QAE1C,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,KAAK,GAAG,kBAAkB,CAAC;QAEjC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,KAAK,GAAG,qBAAqB,CAAC;QACpC,MAAM,QAAQ,GAAG,kBAAkB,CAAC;QAEpC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -4,36 +4,82 @@ declare const ForwardGeocodeInputSchema: z.ZodObject<{
4
4
  q: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
5
5
  permanent: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
6
6
  autocomplete: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
7
- bbox: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
7
+ bbox: z.ZodOptional<z.ZodObject<{
8
+ minLongitude: z.ZodNumber;
9
+ minLatitude: z.ZodNumber;
10
+ maxLongitude: z.ZodNumber;
11
+ maxLatitude: z.ZodNumber;
12
+ }, "strip", z.ZodTypeAny, {
13
+ minLongitude: number;
14
+ minLatitude: number;
15
+ maxLongitude: number;
16
+ maxLatitude: number;
17
+ }, {
18
+ minLongitude: number;
19
+ minLatitude: number;
20
+ maxLongitude: number;
21
+ maxLatitude: number;
22
+ }>>;
8
23
  country: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
9
- format: z.ZodDefault<z.ZodOptional<z.ZodEnum<["geojson"]>>>;
24
+ format: z.ZodDefault<z.ZodOptional<z.ZodEnum<["json_string", "formatted_text"]>>>;
10
25
  language: z.ZodOptional<z.ZodString>;
11
26
  limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
12
- proximity: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodEffects<z.ZodString, [number, number] | "ip", string>]>>;
27
+ proximity: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
28
+ longitude: z.ZodNumber;
29
+ latitude: z.ZodNumber;
30
+ }, "strip", z.ZodTypeAny, {
31
+ longitude: number;
32
+ latitude: number;
33
+ }, {
34
+ longitude: number;
35
+ latitude: number;
36
+ }>, z.ZodEffects<z.ZodString, "ip" | {
37
+ longitude: any;
38
+ latitude: any;
39
+ }, string>]>>;
13
40
  types: z.ZodOptional<z.ZodArray<z.ZodEnum<["country", "region", "postcode", "district", "place", "locality", "neighborhood", "address"]>, "many">>;
14
41
  worldview: z.ZodDefault<z.ZodOptional<z.ZodEnum<["us", "cn", "jp", "in"]>>>;
15
42
  }, "strip", z.ZodTypeAny, {
16
43
  limit: number;
44
+ format: "json_string" | "formatted_text";
17
45
  q: string;
18
46
  permanent: boolean;
19
47
  autocomplete: boolean;
20
- format: "geojson";
21
48
  worldview: "us" | "cn" | "jp" | "in";
22
49
  country?: string[] | undefined;
23
50
  language?: string | undefined;
24
- proximity?: [number, number] | "ip" | undefined;
25
- bbox?: [number, number, number, number] | undefined;
51
+ proximity?: "ip" | {
52
+ longitude: number;
53
+ latitude: number;
54
+ } | {
55
+ longitude: any;
56
+ latitude: any;
57
+ } | undefined;
58
+ bbox?: {
59
+ minLongitude: number;
60
+ minLatitude: number;
61
+ maxLongitude: number;
62
+ maxLatitude: number;
63
+ } | undefined;
26
64
  types?: ("country" | "region" | "postcode" | "district" | "place" | "locality" | "neighborhood" | "address")[] | undefined;
27
65
  }, {
28
66
  q: string;
29
67
  country?: string[] | undefined;
30
68
  language?: string | undefined;
31
69
  limit?: number | undefined;
32
- proximity?: string | [number, number] | undefined;
33
- bbox?: [number, number, number, number] | undefined;
70
+ proximity?: string | {
71
+ longitude: number;
72
+ latitude: number;
73
+ } | undefined;
74
+ bbox?: {
75
+ minLongitude: number;
76
+ minLatitude: number;
77
+ maxLongitude: number;
78
+ maxLatitude: number;
79
+ } | undefined;
80
+ format?: "json_string" | "formatted_text" | undefined;
34
81
  permanent?: boolean | undefined;
35
82
  autocomplete?: boolean | undefined;
36
- format?: "geojson" | undefined;
37
83
  types?: ("country" | "region" | "postcode" | "district" | "place" | "locality" | "neighborhood" | "address")[] | undefined;
38
84
  worldview?: "us" | "cn" | "jp" | "in" | undefined;
39
85
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"ForwardGeocodeTool.d.ts","sourceRoot":"","sources":["../../../src/tools/forward-geocode-tool/ForwardGeocodeTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,QAAA,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8G7B,CAAC;AAEH,qBAAa,kBAAmB,SAAQ,kBAAkB,CACxD,OAAO,yBAAyB,CACjC;IACC,IAAI,SAAwB;IAC5B,WAAW,SACqY;;IAMhZ,OAAO,CAAC,mBAAmB;cA+CX,OAAO,CACrB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,GAC/C,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAiE3C"}
1
+ {"version":3,"file":"ForwardGeocodeTool.d.ts","sourceRoot":"","sources":["../../../src/tools/forward-geocode-tool/ForwardGeocodeTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,QAAA,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiI7B,CAAC;AAEH,qBAAa,kBAAmB,SAAQ,kBAAkB,CACxD,OAAO,yBAAyB,CACjC;IACC,IAAI,SAAwB;IAC5B,WAAW,SACib;;IAM5b,OAAO,CAAC,mBAAmB;cA+CX,OAAO,CACrB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,GAC/C,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAsE3C"}
@@ -18,23 +18,23 @@ const ForwardGeocodeInputSchema = z.object({
18
18
  .default(true)
19
19
  .describe('Return partial/suggested results for partial queries'),
20
20
  bbox: z
21
- .tuple([
22
- z.number().min(-180).max(180),
23
- z.number().min(-90).max(90),
24
- z.number().min(-180).max(180),
25
- z.number().min(-90).max(90)
26
- ])
21
+ .object({
22
+ minLongitude: z.number().min(-180).max(180),
23
+ minLatitude: z.number().min(-90).max(90),
24
+ maxLongitude: z.number().min(-180).max(180),
25
+ maxLatitude: z.number().min(-90).max(90)
26
+ })
27
27
  .optional()
28
- .describe('Bounding box to limit results within [minLon, minLat, maxLon, maxLat]'),
28
+ .describe('Bounding box to limit results within specified bounds'),
29
29
  country: z
30
30
  .array(z.string().length(2))
31
31
  .optional()
32
32
  .describe('Array of ISO 3166 alpha 2 country codes to limit results'),
33
33
  format: z
34
- .enum(['geojson'])
34
+ .enum(['json_string', 'formatted_text'])
35
35
  .optional()
36
- .default('geojson')
37
- .describe('Response format (currently only geojson is supported)'),
36
+ .default('formatted_text')
37
+ .describe('Output format: "json_string" returns raw GeoJSON data as a JSON string that can be parsed; "formatted_text" returns human-readable text with place names, addresses, and coordinates. Both return as text content but json_string contains parseable JSON data while formatted_text is for display.'),
38
38
  language: z
39
39
  .string()
40
40
  .optional()
@@ -48,12 +48,30 @@ const ForwardGeocodeInputSchema = z.object({
48
48
  .describe('Maximum number of results to return (1-10)'),
49
49
  proximity: z
50
50
  .union([
51
- z.tuple([z.number().min(-180).max(180), z.number().min(-90).max(90)]),
51
+ z.object({
52
+ longitude: z.number().min(-180).max(180),
53
+ latitude: z.number().min(-90).max(90)
54
+ }),
52
55
  z.string().transform((val) => {
53
56
  // Handle special case of 'ip'
54
57
  if (val === 'ip') {
55
58
  return 'ip';
56
59
  }
60
+ // Handle JSON-stringified object: "{\"longitude\": -82.458107, \"latitude\": 27.937259}"
61
+ if (val.startsWith('{') && val.endsWith('}')) {
62
+ try {
63
+ const parsed = JSON.parse(val);
64
+ if (typeof parsed === 'object' &&
65
+ parsed !== null &&
66
+ typeof parsed.longitude === 'number' &&
67
+ typeof parsed.latitude === 'number') {
68
+ return { longitude: parsed.longitude, latitude: parsed.latitude };
69
+ }
70
+ }
71
+ catch {
72
+ // Fall back to other formats
73
+ }
74
+ }
57
75
  // Handle string that looks like an array: "[-82.451668, 27.942964]"
58
76
  if (val.startsWith('[') && val.endsWith(']')) {
59
77
  const coords = val
@@ -61,15 +79,15 @@ const ForwardGeocodeInputSchema = z.object({
61
79
  .split(',')
62
80
  .map((s) => Number(s.trim()));
63
81
  if (coords.length === 2 && !isNaN(coords[0]) && !isNaN(coords[1])) {
64
- return coords;
82
+ return { longitude: coords[0], latitude: coords[1] };
65
83
  }
66
84
  }
67
85
  // Handle comma-separated string: "-82.451668,27.942964"
68
86
  const parts = val.split(',').map((s) => Number(s.trim()));
69
87
  if (parts.length === 2 && !isNaN(parts[0]) && !isNaN(parts[1])) {
70
- return parts;
88
+ return { longitude: parts[0], latitude: parts[1] };
71
89
  }
72
- throw new Error('Invalid proximity format. Expected [longitude, latitude], "longitude,latitude", or "ip"');
90
+ throw new Error('Invalid proximity format. Expected {longitude, latitude}, "longitude,latitude", or "ip"');
73
91
  })
74
92
  ])
75
93
  .optional()
@@ -95,7 +113,7 @@ const ForwardGeocodeInputSchema = z.object({
95
113
  });
96
114
  export class ForwardGeocodeTool extends MapboxApiBasedTool {
97
115
  name = 'ForwardGeocodeTool';
98
- description = 'Forward geocode addresses, cities, towns, neighborhoods, districts, postcodes, regions, and countries using Mapbox Geocoding API v6. Converts location name into geographic coordinates. Setting a proximity point helps to bias results towards a specific area for more relevant results. Do not use this tool for geocoding points of interest like businesses, landmarks, historic sites, museums, etc.';
116
+ description = 'Forward geocode addresses, cities, towns, neighborhoods, districts, postcodes, regions, and countries using Mapbox Geocoding API v6. Converts location name into geographic coordinates. Setting a proximity point helps to bias results towards a specific area for more relevant results. Do not use this tool for geocoding points of interest like businesses, landmarks, historic sites, museums, etc. Supports both JSON and text output formats.';
99
117
  constructor() {
100
118
  super({ inputSchema: ForwardGeocodeInputSchema });
101
119
  }
@@ -142,12 +160,12 @@ export class ForwardGeocodeTool extends MapboxApiBasedTool {
142
160
  // Optional parameters
143
161
  url.searchParams.append('permanent', input.permanent.toString());
144
162
  url.searchParams.append('autocomplete', input.autocomplete.toString());
145
- url.searchParams.append('format', input.format);
163
+ url.searchParams.append('format', 'geojson');
146
164
  url.searchParams.append('limit', input.limit.toString());
147
165
  url.searchParams.append('worldview', input.worldview);
148
166
  if (input.bbox) {
149
- const [minLon, minLat, maxLon, maxLat] = input.bbox;
150
- url.searchParams.append('bbox', `${minLon},${minLat},${maxLon},${maxLat}`);
167
+ const { minLongitude, minLatitude, maxLongitude, maxLatitude } = input.bbox;
168
+ url.searchParams.append('bbox', `${minLongitude},${minLatitude},${maxLongitude},${maxLatitude}`);
151
169
  }
152
170
  if (input.country && input.country.length > 0) {
153
171
  url.searchParams.append('country', input.country.join(','));
@@ -160,8 +178,8 @@ export class ForwardGeocodeTool extends MapboxApiBasedTool {
160
178
  url.searchParams.append('proximity', 'ip');
161
179
  }
162
180
  else {
163
- const [lng, lat] = input.proximity;
164
- url.searchParams.append('proximity', `${lng},${lat}`);
181
+ const { longitude, latitude } = input.proximity;
182
+ url.searchParams.append('proximity', `${longitude},${latitude}`);
165
183
  }
166
184
  }
167
185
  if (input.types && input.types.length > 0) {
@@ -176,7 +194,12 @@ export class ForwardGeocodeTool extends MapboxApiBasedTool {
176
194
  if (!data || !data.features || data.features.length === 0) {
177
195
  return { type: 'text', text: 'No results found.' };
178
196
  }
179
- return { type: 'text', text: this.formatGeoJsonToText(data) };
197
+ if (input.format === 'json_string') {
198
+ return { type: 'text', text: JSON.stringify(data, null, 2) };
199
+ }
200
+ else {
201
+ return { type: 'text', text: this.formatGeoJsonToText(data) };
202
+ }
180
203
  }
181
204
  }
182
205
  //# sourceMappingURL=ForwardGeocodeTool.js.map