@mapbox/mcp-server 0.0.2-dev.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 (90) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +149 -0
  3. package/dist/cjs/package.json +3 -0
  4. package/dist/esm/package.json +3 -0
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +37 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/tools/MapboxApiBasedTool.d.ts +75 -0
  10. package/dist/tools/MapboxApiBasedTool.d.ts.map +1 -0
  11. package/dist/tools/MapboxApiBasedTool.js +78 -0
  12. package/dist/tools/MapboxApiBasedTool.js.map +1 -0
  13. package/dist/tools/category-search-tool/CategorySearchTool.d.ts +39 -0
  14. package/dist/tools/category-search-tool/CategorySearchTool.d.ts.map +1 -0
  15. package/dist/tools/category-search-tool/CategorySearchTool.js +638 -0
  16. package/dist/tools/category-search-tool/CategorySearchTool.js.map +1 -0
  17. package/dist/tools/category-search-tool/CategorySearchTool.test.d.ts +2 -0
  18. package/dist/tools/category-search-tool/CategorySearchTool.test.d.ts.map +1 -0
  19. package/dist/tools/category-search-tool/CategorySearchTool.test.js +289 -0
  20. package/dist/tools/category-search-tool/CategorySearchTool.test.js.map +1 -0
  21. package/dist/tools/directions-tool/DirectionsTool.d.ts +53 -0
  22. package/dist/tools/directions-tool/DirectionsTool.d.ts.map +1 -0
  23. package/dist/tools/directions-tool/DirectionsTool.js +405 -0
  24. package/dist/tools/directions-tool/DirectionsTool.js.map +1 -0
  25. package/dist/tools/directions-tool/DirectionsTool.test.d.ts +2 -0
  26. package/dist/tools/directions-tool/DirectionsTool.test.d.ts.map +1 -0
  27. package/dist/tools/directions-tool/DirectionsTool.test.js +867 -0
  28. package/dist/tools/directions-tool/DirectionsTool.test.js.map +1 -0
  29. package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.d.ts +51 -0
  30. package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.d.ts.map +1 -0
  31. package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.js +182 -0
  32. package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.js.map +1 -0
  33. package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.d.ts +2 -0
  34. package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.d.ts.map +1 -0
  35. package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.js +335 -0
  36. package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.js.map +1 -0
  37. package/dist/tools/isochrone-tool/IsochroneTool.d.ts +44 -0
  38. package/dist/tools/isochrone-tool/IsochroneTool.d.ts.map +1 -0
  39. package/dist/tools/isochrone-tool/IsochroneTool.js +108 -0
  40. package/dist/tools/isochrone-tool/IsochroneTool.js.map +1 -0
  41. package/dist/tools/isochrone-tool/IsochroneTool.test.d.ts +2 -0
  42. package/dist/tools/isochrone-tool/IsochroneTool.test.d.ts.map +1 -0
  43. package/dist/tools/isochrone-tool/IsochroneTool.test.js +110 -0
  44. package/dist/tools/isochrone-tool/IsochroneTool.test.js.map +1 -0
  45. package/dist/tools/matrix-tool/MatrixTool.d.ts +35 -0
  46. package/dist/tools/matrix-tool/MatrixTool.d.ts.map +1 -0
  47. package/dist/tools/matrix-tool/MatrixTool.js +195 -0
  48. package/dist/tools/matrix-tool/MatrixTool.js.map +1 -0
  49. package/dist/tools/matrix-tool/MatrixTool.test.d.ts +2 -0
  50. package/dist/tools/matrix-tool/MatrixTool.test.d.ts.map +1 -0
  51. package/dist/tools/matrix-tool/MatrixTool.test.js +803 -0
  52. package/dist/tools/matrix-tool/MatrixTool.test.js.map +1 -0
  53. package/dist/tools/poi-search-tool/PoiSearchTool.d.ts +54 -0
  54. package/dist/tools/poi-search-tool/PoiSearchTool.d.ts.map +1 -0
  55. package/dist/tools/poi-search-tool/PoiSearchTool.js +193 -0
  56. package/dist/tools/poi-search-tool/PoiSearchTool.js.map +1 -0
  57. package/dist/tools/poi-search-tool/PoiSearchTool.test.d.ts +2 -0
  58. package/dist/tools/poi-search-tool/PoiSearchTool.test.d.ts.map +1 -0
  59. package/dist/tools/poi-search-tool/PoiSearchTool.test.js +338 -0
  60. package/dist/tools/poi-search-tool/PoiSearchTool.test.js.map +1 -0
  61. package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts +42 -0
  62. package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts.map +1 -0
  63. package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.js +131 -0
  64. package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.js.map +1 -0
  65. package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.d.ts +2 -0
  66. package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.d.ts.map +1 -0
  67. package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.js +340 -0
  68. package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.js.map +1 -0
  69. package/dist/tools/static-map-image-tool/StaticMapImageTool.d.ts +148 -0
  70. package/dist/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -0
  71. package/dist/tools/static-map-image-tool/StaticMapImageTool.js +406 -0
  72. package/dist/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -0
  73. package/dist/tools/static-map-image-tool/StaticMapImageTool.test.d.ts +2 -0
  74. package/dist/tools/static-map-image-tool/StaticMapImageTool.test.d.ts.map +1 -0
  75. package/dist/tools/static-map-image-tool/StaticMapImageTool.test.js +440 -0
  76. package/dist/tools/static-map-image-tool/StaticMapImageTool.test.js.map +1 -0
  77. package/dist/utils/requestUtils.d.ts +6 -0
  78. package/dist/utils/requestUtils.d.ts.map +1 -0
  79. package/dist/utils/requestUtils.js +29 -0
  80. package/dist/utils/requestUtils.js.map +1 -0
  81. package/dist/utils/requestUtils.test-helpers.d.ts +3 -0
  82. package/dist/utils/requestUtils.test-helpers.d.ts.map +1 -0
  83. package/dist/utils/requestUtils.test-helpers.js +28 -0
  84. package/dist/utils/requestUtils.test-helpers.js.map +1 -0
  85. package/dist/utils/versionUtils.d.ts +9 -0
  86. package/dist/utils/versionUtils.d.ts.map +1 -0
  87. package/dist/utils/versionUtils.js +25 -0
  88. package/dist/utils/versionUtils.js.map +1 -0
  89. package/dist/version.json +6 -0
  90. package/package.json +76 -0
package/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ ### License
2
+
3
+ Mapbox MCP Server
4
+
5
+ Copyright © 2025 Mapbox, Inc. All rights reserved.
6
+
7
+ The software and files in this repository (collectively, “Software”) are licensed under the Mapbox TOS for use only with the relevant Mapbox product(s) listed at www.mapbox.com/pricing. This license allows developers with a current active Mapbox account to use and modify the authorized portions of the Software as needed for use only with the relevant Mapbox product(s) through their Mapbox account in accordance with the Mapbox TOS. This license terminates automatically if a developer no longer has a Mapbox account in good standing or breaches the Mapbox TOS. For the license terms, please see the Mapbox TOS at https://www.mapbox.com/legal/tos/ which incorporates the Mapbox Product Terms at www.mapbox.com/legal/service-terms. If this Software is a SDK, modifications that change or interfere with marked portions of the code related to billing, accounting, or data collection are not authorized and the SDK sends limited de-identified location and usage data which is used in accordance with the Mapbox TOS. [Updated 2023-01]
package/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # Mapbox MCP Server
2
+
3
+ Node.js server implementing Model Context Protocol (MCP) for Mapbox APIs.
4
+
5
+ **A Mapbox access token is required to use this MCP server.**
6
+
7
+ To get a Mapbox access token:
8
+
9
+ 1. Sign up for a free Mapbox account at [mapbox.com/signup](https://www.mapbox.com/signup/)
10
+ 2. Navigate to your [Account page](https://account.mapbox.com/)
11
+ 3. Create a new token or use the default public token
12
+
13
+ For more information about Mapbox access tokens, see the [Mapbox documentation on access tokens](https://docs.mapbox.com/help/dive-deeper/access-tokens/).
14
+
15
+ ## Integration Guides
16
+
17
+ For detailed setup instructions for different integrations, refer to the following guides:
18
+
19
+ - [Claude Desktop Setup](./docs/claude-desktop-setup.md) - Instructions for configuring Claude Desktop to work with this MCP server
20
+ - [VS Code Setup](./docs/vscode-setup.md) - Setting up a development environment in Visual Studio Code
21
+ - [SmolaGents Integration](./docs/using-mcp-with-smolagents/README.md) - Example showing how to connect SmolaGents AI agents to Mapbox's tools
22
+
23
+ ## Tools
24
+
25
+ ### Mapbox API tools
26
+
27
+ #### Matrix tool
28
+
29
+ Calculates travel times and distances between multiple points using [Mapbox Matrix API](https://www.mapbox.com/matrix-api). Features include:
30
+
31
+ - Efficient one-to-many, many-to-one or many-to-many routing calculations
32
+ - Support for different travel profiles (driving-traffic, driving, walking, cycling)
33
+ - Departure time specification for traffic-aware calculations
34
+ - Route summarization with distance and duration metrics
35
+ - Control approach (curb/unrestricted) and range of allowed departure bearings
36
+
37
+ #### Static image tool
38
+
39
+ Generates static map images using the [Mapbox static image API](https://docs.mapbox.com/api/maps/static-images/). Features include:
40
+
41
+ - Custom map styles (streets, outdoors, satellite, etc.)
42
+ - Adjustable image dimensions and zoom levels
43
+ - Support for multiple markers with custom colors and labels
44
+ - Overlay options including polylines and polygons
45
+ - Auto-fitting to specified coordinates
46
+
47
+ #### POI search tool
48
+
49
+ Finds specific points of interest or brand locations by name using the [Mapbox Search Box forward search API](https://docs.mapbox.com/api/search/search-box/#search-request). Features include:
50
+
51
+ - Search for specific points of interest by proper name or unique brand (e.g., "Amalie Arena", "Starbucks")
52
+ - Find all nearby branches of a brand (e.g., "Macy's stores near me")
53
+ - Geographic proximity biasing for more relevant results
54
+ - Support for multiple languages and countries
55
+
56
+ #### Category search tool
57
+
58
+ Performs a category search using the [Mapbox Search Box category search API](https://docs.mapbox.com/api/search/search-box/#category-search). Features include:
59
+
60
+ - Search for points of interest by category (restaurants, hotels, gas stations, etc.)
61
+ - Filtering by geographic proximity
62
+ - Customizable result limits
63
+ - Rich metadata for each result
64
+ - Support for multiple languages
65
+
66
+ #### Forward geocoding tool
67
+
68
+ Performs forward geocoding using the [Mapbox geocoding V6 API](https://docs.mapbox.com/api/search/geocoding/#forward-geocoding-with-search-text-input). Features include:
69
+
70
+ - Convert addresses or place names to geographic coordinates
71
+ - Fuzzy matching for partial or misspelled inputs
72
+ - Results filtering by country, region, or bounding box
73
+ - Customizable result limits
74
+ - Multiple language support
75
+
76
+ #### Reverse geocoding tool
77
+
78
+ Performs reverse geocoding using the [Mapbox geocoding V6 API](https://docs.mapbox.com/api/search/geocoding/#reverse-geocoding). Features include:
79
+
80
+ - Convert geographic coordinates to human-readable addresses
81
+ - Customizable levels of detail (street, neighborhood, city, etc.)
82
+ - Results filtering by type (address, poi, neighborhood, etc.)
83
+ - Support for multiple languages
84
+ - Rich location context information
85
+
86
+ #### Directions tool
87
+
88
+ Fetches routing directions using the [Mapbox Directions API](https://docs.mapbox.com/api/navigation/directions/). Features include:
89
+
90
+ - Support for different routing profiles: driving (with live traffic or typical), walking, and cycling
91
+ - Route from multiple waypoints (2-25 coordinate pairs)
92
+ - Alternative routes option
93
+ - Route annotations (distance, duration, speed, congestion)
94
+ - Scheduling options:
95
+ - Future departure time (`depart_at`) for driving and driving-traffic profiles
96
+ - Desired arrival time (`arrive_by`) for driving profile only
97
+ - Profile-specific optimizations:
98
+ - Walking: customizable walking speed and bias for/against walkways
99
+ - Driving: vehicle dimension constraints (height, width, weight)
100
+ - Exclusion options for routing:
101
+ - Common exclusions: ferry routes, cash-only tolls
102
+ - Driving-specific exclusions: tolls, motorways, unpaved roads, tunnels, country borders, state borders
103
+ - Custom point exclusions (up to 50 geographic points to avoid)
104
+ - Multiple geometry output formats (GeoJSON, polyline)
105
+
106
+ #### Isochrone tool
107
+
108
+ Computes areas that are reachable within a specified amount of times from a location using [Mapbox Isochrone API](https://docs.mapbox.com/api/navigation/isochrone/). Features include:
109
+
110
+ - Support for different travel profiles (driving, walking, cycling)
111
+ - Customizable travel times or distances
112
+ - Multiple contour generation (e.g., 15, 30, 45 minute ranges)
113
+ - Optional departure or arrival time specification
114
+ - Color customization for visualization
115
+
116
+ # Development
117
+
118
+ ## Inspecting server
119
+
120
+ ### Using Node.js
121
+
122
+ ```sh
123
+ # Build
124
+ npm run build
125
+
126
+ # Inspect
127
+ npx @modelcontextprotocol/inspector node dist/index.js
128
+ ```
129
+
130
+ ### Using Docker
131
+
132
+ ```sh
133
+ # Build the Docker image
134
+ docker build -t mapbox-mcp-server .
135
+
136
+ # Run and inspect the server
137
+ npx @modelcontextprotocol/inspector docker run -i --rm --env MAPBOX_ACCESS_TOKEN="YOUR_TOKEN" mapbox-mcp-server
138
+ ```
139
+
140
+ ## Create new tool
141
+
142
+ ```sh
143
+ npx plop create-tool
144
+ # provide tool name without suffix (e.g. Search)
145
+ ```
146
+
147
+ ---
148
+
149
+ [License](LICENSE.md)
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { CategorySearchTool } from './tools/category-search-tool/CategorySearchTool.js';
4
+ import { DirectionsTool } from './tools/directions-tool/DirectionsTool.js';
5
+ import { ForwardGeocodeTool } from './tools/forward-geocode-tool/ForwardGeocodeTool.js';
6
+ import { IsochroneTool } from './tools/isochrone-tool/IsochroneTool.js';
7
+ import { MatrixTool } from './tools/matrix-tool/MatrixTool.js';
8
+ import { PoiSearchTool } from './tools/poi-search-tool/PoiSearchTool.js';
9
+ import { ReverseGeocodeTool } from './tools/reverse-geocode-tool/ReverseGeocodeTool.js';
10
+ import { StaticMapImageTool } from './tools/static-map-image-tool/StaticMapImageTool.js';
11
+ import { patchGlobalFetch } from './utils/requestUtils.js';
12
+ import { getVersionInfo } from './utils/versionUtils.js';
13
+ // INSERT NEW TOOL IMPORT HERE
14
+ let serverVersionInfo = getVersionInfo();
15
+ patchGlobalFetch(serverVersionInfo);
16
+ // Create an MCP server
17
+ const server = new McpServer({
18
+ name: serverVersionInfo.name,
19
+ version: serverVersionInfo.version
20
+ }, {
21
+ capabilities: {
22
+ logging: {}
23
+ }
24
+ });
25
+ // INSERT NEW TOOL REGISTRATION HERE
26
+ new MatrixTool().installTo(server);
27
+ new ReverseGeocodeTool().installTo(server);
28
+ new ForwardGeocodeTool().installTo(server);
29
+ new IsochroneTool().installTo(server);
30
+ new PoiSearchTool().installTo(server);
31
+ new CategorySearchTool().installTo(server);
32
+ new StaticMapImageTool().installTo(server);
33
+ new DirectionsTool().installTo(server);
34
+ // Start receiving messages on stdin and sending messages on stdout
35
+ const transport = new StdioServerTransport();
36
+ await server.connect(transport);
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACV,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,8BAA8B;AAE9B,IAAI,iBAAiB,GAAG,cAAc,EAAE,CAAC;AACzC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;AAEpC,uBAAuB;AACvB,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;IACE,IAAI,EAAE,iBAAiB,CAAC,IAAI;IAC5B,OAAO,EAAE,iBAAiB,CAAC,OAAO;CACnC,EACD;IACE,YAAY,EAAE;QACZ,OAAO,EAAE,EAAE;KACZ;CACF,CACF,CAAC;AAEF,oCAAoC;AACpC,IAAI,UAAU,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACnC,IAAI,kBAAkB,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC3C,IAAI,kBAAkB,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC3C,IAAI,aAAa,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACtC,IAAI,aAAa,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACtC,IAAI,kBAAkB,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC3C,IAAI,kBAAkB,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC3C,IAAI,cAAc,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAEvC,mEAAmE;AACnE,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,75 @@
1
+ import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp';
2
+ import { z, ZodTypeAny } from 'zod';
3
+ export declare const OutputSchema: z.ZodObject<{
4
+ content: z.ZodArray<z.ZodUnion<[z.ZodObject<{
5
+ type: z.ZodLiteral<"text">;
6
+ text: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ type: "text";
9
+ text: string;
10
+ }, {
11
+ type: "text";
12
+ text: string;
13
+ }>, z.ZodObject<{
14
+ type: z.ZodLiteral<"image">;
15
+ data: z.ZodString;
16
+ mimeType: z.ZodString;
17
+ }, "strip", z.ZodTypeAny, {
18
+ type: "image";
19
+ data: string;
20
+ mimeType: string;
21
+ }, {
22
+ type: "image";
23
+ data: string;
24
+ mimeType: string;
25
+ }>]>, "many">;
26
+ is_error: z.ZodDefault<z.ZodBoolean>;
27
+ }, "strip", z.ZodTypeAny, {
28
+ content: ({
29
+ type: "text";
30
+ text: string;
31
+ } | {
32
+ type: "image";
33
+ data: string;
34
+ mimeType: string;
35
+ })[];
36
+ is_error: boolean;
37
+ }, {
38
+ content: ({
39
+ type: "text";
40
+ text: string;
41
+ } | {
42
+ type: "image";
43
+ data: string;
44
+ mimeType: string;
45
+ })[];
46
+ is_error?: boolean | undefined;
47
+ }>;
48
+ export declare abstract class MapboxApiBasedTool<InputSchema extends ZodTypeAny> {
49
+ abstract readonly name: string;
50
+ abstract readonly description: string;
51
+ readonly inputSchema: InputSchema;
52
+ protected server: McpServer | null;
53
+ static readonly MAPBOX_ACCESS_TOKEN: string | undefined;
54
+ static readonly MAPBOX_API_ENDPOINT: string;
55
+ constructor(params: {
56
+ inputSchema: InputSchema;
57
+ });
58
+ /**
59
+ * Validates and runs the tool logic.
60
+ */
61
+ run(rawInput: unknown): Promise<z.infer<typeof OutputSchema>>;
62
+ /**
63
+ * Tool logic to be implemented by subclasses.
64
+ */
65
+ protected abstract execute(_input: z.infer<InputSchema>): Promise<any>;
66
+ /**
67
+ * Installs the tool to the given MCP server.
68
+ */
69
+ installTo(server: McpServer): RegisteredTool;
70
+ /**
71
+ * Helper method to send logging messages
72
+ */
73
+ protected log(level: 'debug' | 'info' | 'warning' | 'error', data: any): void;
74
+ }
75
+ //# sourceMappingURL=MapboxApiBasedTool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapboxApiBasedTool.d.ts","sourceRoot":"","sources":["../../src/tools/MapboxApiBasedTool.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,cAAc,EACf,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEpC,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAevB,CAAC;AAEH,8BAAsB,kBAAkB,CAAC,WAAW,SAAS,UAAU;IACrE,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAEtC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAQ;IAE1C,MAAM,CAAC,QAAQ,CAAC,mBAAmB,qBAAmC;IACtE,MAAM,CAAC,QAAQ,CAAC,mBAAmB,SAC4B;gBAEnD,MAAM,EAAE;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE;IAIhD;;OAEG;IACG,GAAG,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;IA2CnE;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAEtE;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,cAAc;IAU5C;;OAEG;IACH,SAAS,CAAC,GAAG,CACX,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,EAC7C,IAAI,EAAE,GAAG,GACR,IAAI;CAKR"}
@@ -0,0 +1,78 @@
1
+ import { z } from 'zod';
2
+ export const OutputSchema = z.object({
3
+ content: z.array(z.union([
4
+ z.object({
5
+ type: z.literal('text'),
6
+ text: z.string()
7
+ }),
8
+ z.object({
9
+ type: z.literal('image'),
10
+ data: z.string(),
11
+ mimeType: z.string()
12
+ })
13
+ ])),
14
+ is_error: z.boolean().default(false)
15
+ });
16
+ export class MapboxApiBasedTool {
17
+ inputSchema;
18
+ server = null;
19
+ static MAPBOX_ACCESS_TOKEN = process.env.MAPBOX_ACCESS_TOKEN;
20
+ static MAPBOX_API_ENDPOINT = process.env.MAPBOX_API_ENDPOINT || 'https://api.mapbox.com/';
21
+ constructor(params) {
22
+ this.inputSchema = params.inputSchema;
23
+ }
24
+ /**
25
+ * Validates and runs the tool logic.
26
+ */
27
+ async run(rawInput) {
28
+ try {
29
+ if (!MapboxApiBasedTool.MAPBOX_ACCESS_TOKEN) {
30
+ throw new Error('MAPBOX_ACCESS_TOKEN is not set');
31
+ }
32
+ const input = this.inputSchema.parse(rawInput);
33
+ const result = await this.execute(input);
34
+ // Check if result is already a content object (image or text)
35
+ if (result &&
36
+ typeof result === 'object' &&
37
+ (result.type === 'image' || result.type === 'text')) {
38
+ return {
39
+ content: [result],
40
+ is_error: false
41
+ };
42
+ }
43
+ // Otherwise return as text
44
+ return {
45
+ content: [{ type: 'text', text: JSON.stringify(result) }],
46
+ is_error: false
47
+ };
48
+ }
49
+ catch (error) {
50
+ this.log('error', `${this.name}: Error during execution: ${error instanceof Error ? error.message : String(error)}`);
51
+ return {
52
+ content: [
53
+ {
54
+ type: 'text',
55
+ text: 'Internal error has occurred.'
56
+ }
57
+ ],
58
+ is_error: true
59
+ };
60
+ }
61
+ }
62
+ /**
63
+ * Installs the tool to the given MCP server.
64
+ */
65
+ installTo(server) {
66
+ this.server = server;
67
+ return server.tool(this.name, this.description, this.inputSchema.shape, this.run.bind(this));
68
+ }
69
+ /**
70
+ * Helper method to send logging messages
71
+ */
72
+ log(level, data) {
73
+ if (this.server) {
74
+ this.server.server.sendLoggingMessage({ level, data });
75
+ }
76
+ }
77
+ }
78
+ //# sourceMappingURL=MapboxApiBasedTool.js.map
@@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OAEG;IACO,GAAG,CACX,KAA6C,EAC7C,IAAS;QAET,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ import { MapboxApiBasedTool } from '../MapboxApiBasedTool.js';
3
+ declare const CategorySearchInputSchema: z.ZodObject<{
4
+ category: z.ZodString;
5
+ language: z.ZodOptional<z.ZodString>;
6
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
7
+ proximity: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodEffects<z.ZodString, [number, number] | "ip", string>]>>;
8
+ bbox: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
9
+ country: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
10
+ poi_category_exclusions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ category: string;
13
+ limit: number;
14
+ country?: string[] | undefined;
15
+ language?: string | undefined;
16
+ proximity?: [number, number] | "ip" | undefined;
17
+ bbox?: [number, number, number, number] | undefined;
18
+ poi_category_exclusions?: string[] | undefined;
19
+ }, {
20
+ category: string;
21
+ country?: string[] | undefined;
22
+ language?: string | undefined;
23
+ limit?: number | undefined;
24
+ proximity?: string | [number, number] | undefined;
25
+ bbox?: [number, number, number, number] | undefined;
26
+ poi_category_exclusions?: string[] | undefined;
27
+ }>;
28
+ export declare class CategorySearchTool extends MapboxApiBasedTool<typeof CategorySearchInputSchema> {
29
+ name: string;
30
+ description: string;
31
+ constructor();
32
+ private formatGeoJsonToText;
33
+ protected execute(input: z.infer<typeof CategorySearchInputSchema>): Promise<{
34
+ type: 'text';
35
+ text: string;
36
+ }>;
37
+ }
38
+ export {};
39
+ //# sourceMappingURL=CategorySearchTool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CategorySearchTool.d.ts","sourceRoot":"","sources":["../../../src/tools/category-search-tool/CategorySearchTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAwe9D,QAAA,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;EAsE7B,CAAC;AAEH,qBAAa,kBAAmB,SAAQ,kBAAkB,CACxD,OAAO,yBAAyB,CACjC;IACC,IAAI,SAAwB;IAC5B,WAAW,SACwU;;IAMnV,OAAO,CAAC,mBAAmB;cAsDX,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;CAgE3C"}