@mapbox/mcp-server 0.0.2 → 0.1.1-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -1
- package/dist/cjs/package.json +3 -0
- package/dist/esm/package.json +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/MapboxApiBasedTool.d.ts +75 -0
- package/dist/tools/MapboxApiBasedTool.d.ts.map +1 -0
- package/dist/tools/MapboxApiBasedTool.js +78 -0
- package/dist/tools/MapboxApiBasedTool.js.map +1 -0
- package/dist/tools/category-search-tool/CategorySearchTool.d.ts +39 -0
- package/dist/tools/category-search-tool/CategorySearchTool.d.ts.map +1 -0
- package/dist/tools/category-search-tool/CategorySearchTool.js +638 -0
- package/dist/tools/category-search-tool/CategorySearchTool.js.map +1 -0
- package/dist/tools/category-search-tool/CategorySearchTool.test.d.ts +2 -0
- package/dist/tools/category-search-tool/CategorySearchTool.test.d.ts.map +1 -0
- package/dist/tools/category-search-tool/CategorySearchTool.test.js +289 -0
- package/dist/tools/category-search-tool/CategorySearchTool.test.js.map +1 -0
- package/dist/tools/directions-tool/DirectionsTool.d.ts +53 -0
- package/dist/tools/directions-tool/DirectionsTool.d.ts.map +1 -0
- package/dist/tools/directions-tool/DirectionsTool.js +405 -0
- package/dist/tools/directions-tool/DirectionsTool.js.map +1 -0
- package/dist/tools/directions-tool/DirectionsTool.test.d.ts +2 -0
- package/dist/tools/directions-tool/DirectionsTool.test.d.ts.map +1 -0
- package/dist/tools/directions-tool/DirectionsTool.test.js +867 -0
- package/dist/tools/directions-tool/DirectionsTool.test.js.map +1 -0
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.d.ts +51 -0
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.d.ts.map +1 -0
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.js +182 -0
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.js.map +1 -0
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.d.ts +2 -0
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.d.ts.map +1 -0
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.js +335 -0
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.js.map +1 -0
- package/dist/tools/isochrone-tool/IsochroneTool.d.ts +44 -0
- package/dist/tools/isochrone-tool/IsochroneTool.d.ts.map +1 -0
- package/dist/tools/isochrone-tool/IsochroneTool.js +108 -0
- package/dist/tools/isochrone-tool/IsochroneTool.js.map +1 -0
- package/dist/tools/isochrone-tool/IsochroneTool.test.d.ts +2 -0
- package/dist/tools/isochrone-tool/IsochroneTool.test.d.ts.map +1 -0
- package/dist/tools/isochrone-tool/IsochroneTool.test.js +110 -0
- package/dist/tools/isochrone-tool/IsochroneTool.test.js.map +1 -0
- package/dist/tools/matrix-tool/MatrixTool.d.ts +35 -0
- package/dist/tools/matrix-tool/MatrixTool.d.ts.map +1 -0
- package/dist/tools/matrix-tool/MatrixTool.js +195 -0
- package/dist/tools/matrix-tool/MatrixTool.js.map +1 -0
- package/dist/tools/matrix-tool/MatrixTool.test.d.ts +2 -0
- package/dist/tools/matrix-tool/MatrixTool.test.d.ts.map +1 -0
- package/dist/tools/matrix-tool/MatrixTool.test.js +803 -0
- package/dist/tools/matrix-tool/MatrixTool.test.js.map +1 -0
- package/dist/tools/poi-search-tool/PoiSearchTool.d.ts +54 -0
- package/dist/tools/poi-search-tool/PoiSearchTool.d.ts.map +1 -0
- package/dist/tools/poi-search-tool/PoiSearchTool.js +193 -0
- package/dist/tools/poi-search-tool/PoiSearchTool.js.map +1 -0
- package/dist/tools/poi-search-tool/PoiSearchTool.test.d.ts +2 -0
- package/dist/tools/poi-search-tool/PoiSearchTool.test.d.ts.map +1 -0
- package/dist/tools/poi-search-tool/PoiSearchTool.test.js +338 -0
- package/dist/tools/poi-search-tool/PoiSearchTool.test.js.map +1 -0
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts +42 -0
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts.map +1 -0
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.js +131 -0
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.js.map +1 -0
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.d.ts +2 -0
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.d.ts.map +1 -0
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.js +340 -0
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.js.map +1 -0
- package/dist/tools/static-map-image-tool/StaticMapImageTool.d.ts +148 -0
- package/dist/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -0
- package/dist/tools/static-map-image-tool/StaticMapImageTool.js +406 -0
- package/dist/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -0
- package/dist/tools/static-map-image-tool/StaticMapImageTool.test.d.ts +2 -0
- package/dist/tools/static-map-image-tool/StaticMapImageTool.test.d.ts.map +1 -0
- package/dist/tools/static-map-image-tool/StaticMapImageTool.test.js +440 -0
- package/dist/tools/static-map-image-tool/StaticMapImageTool.test.js.map +1 -0
- package/dist/utils/requestUtils.d.ts +6 -0
- package/dist/utils/requestUtils.d.ts.map +1 -0
- package/dist/utils/requestUtils.js +29 -0
- package/dist/utils/requestUtils.js.map +1 -0
- package/dist/utils/requestUtils.test-helpers.d.ts +3 -0
- package/dist/utils/requestUtils.test-helpers.d.ts.map +1 -0
- package/dist/utils/requestUtils.test-helpers.js +28 -0
- package/dist/utils/requestUtils.test-helpers.js.map +1 -0
- package/dist/utils/versionUtils.d.ts +9 -0
- package/dist/utils/versionUtils.d.ts.map +1 -0
- package/dist/utils/versionUtils.js +25 -0
- package/dist/utils/versionUtils.js.map +1 -0
- package/dist/version.json +6 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Node.js server implementing Model Context Protocol (MCP) for Mapbox APIs.
|
|
4
4
|
|
|
5
|
+
## Unlock Geospatial Intelligence for Your AI Applications
|
|
6
|
+
|
|
7
|
+
The Mapbox MCP Server transforms any AI agent or application into a geospatially-aware system by providing seamless access to Mapbox's comprehensive location intelligence platform. With this server, your AI can understand and reason about places, navigate the physical world, and access rich geospatial data including:
|
|
8
|
+
|
|
9
|
+
- **Global geocoding** to convert addresses and place names to coordinates and vice versa
|
|
10
|
+
- **Points of interest (POI) search** across millions of businesses, landmarks, and places worldwide
|
|
11
|
+
- **Multi-modal routing** for driving, walking, and cycling with real-time traffic
|
|
12
|
+
- **Travel time matrices** to analyze accessibility and optimize logistics
|
|
13
|
+
- **Isochrone generation** to visualize areas reachable within specific time or distance constraints
|
|
14
|
+
- **Static map images** to create visual representations of locations, routes, and geographic data
|
|
15
|
+
|
|
16
|
+
Whether you're building an AI travel assistant, logistics optimizer, location-based recommender, or any application that needs to understand "where", the Mapbox MCP Server provides the spatial intelligence to make it possible. You can also enable it on popular clients like Claude Desktop and VS Code. See below for details
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
# Usage
|
|
21
|
+
|
|
5
22
|
**A Mapbox access token is required to use this MCP server.**
|
|
6
23
|
|
|
7
24
|
To get a Mapbox access token:
|
|
@@ -18,7 +35,7 @@ For detailed setup instructions for different integrations, refer to the followi
|
|
|
18
35
|
|
|
19
36
|
- [Claude Desktop Setup](./docs/claude-desktop-setup.md) - Instructions for configuring Claude Desktop to work with this MCP server
|
|
20
37
|
- [VS Code Setup](./docs/vscode-setup.md) - Setting up a development environment in Visual Studio Code
|
|
21
|
-
- [
|
|
38
|
+
- [Smolagents Integration](./docs/using-mcp-with-smolagents/README.md) - Example showing how to connect Smolagents AI agents to Mapbox's tools
|
|
22
39
|
|
|
23
40
|
## Tools
|
|
24
41
|
|
|
@@ -144,6 +161,14 @@ npx plop create-tool
|
|
|
144
161
|
# provide tool name without suffix (e.g. Search)
|
|
145
162
|
```
|
|
146
163
|
|
|
164
|
+
## Environment Variables
|
|
165
|
+
|
|
166
|
+
### VERBOSE_ERRORS
|
|
167
|
+
|
|
168
|
+
Set `VERBOSE_ERRORS=true` to get detailed error messages from the MCP server. This is useful for debugging issues when integrating with MCP clients.
|
|
169
|
+
|
|
170
|
+
By default, the server returns generic error messages. With verbose errors enabled, you'll receive the actual error details, which can help diagnose API connection issues, invalid parameters, or other problems.
|
|
171
|
+
|
|
147
172
|
---
|
|
148
173
|
|
|
149
174
|
[License](LICENSE.md)
|
package/dist/index.d.ts
ADDED
|
@@ -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,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { CategorySearchTool } from './tools/category-search-tool/CategorySearchTool.js';
|
|
5
|
+
import { DirectionsTool } from './tools/directions-tool/DirectionsTool.js';
|
|
6
|
+
import { ForwardGeocodeTool } from './tools/forward-geocode-tool/ForwardGeocodeTool.js';
|
|
7
|
+
import { IsochroneTool } from './tools/isochrone-tool/IsochroneTool.js';
|
|
8
|
+
import { MatrixTool } from './tools/matrix-tool/MatrixTool.js';
|
|
9
|
+
import { PoiSearchTool } from './tools/poi-search-tool/PoiSearchTool.js';
|
|
10
|
+
import { ReverseGeocodeTool } from './tools/reverse-geocode-tool/ReverseGeocodeTool.js';
|
|
11
|
+
import { StaticMapImageTool } from './tools/static-map-image-tool/StaticMapImageTool.js';
|
|
12
|
+
import { patchGlobalFetch } from './utils/requestUtils.js';
|
|
13
|
+
import { getVersionInfo } from './utils/versionUtils.js';
|
|
14
|
+
// INSERT NEW TOOL IMPORT HERE
|
|
15
|
+
let serverVersionInfo = getVersionInfo();
|
|
16
|
+
patchGlobalFetch(serverVersionInfo);
|
|
17
|
+
// Create an MCP server
|
|
18
|
+
const server = new McpServer({
|
|
19
|
+
name: serverVersionInfo.name,
|
|
20
|
+
version: serverVersionInfo.version
|
|
21
|
+
}, {
|
|
22
|
+
capabilities: {
|
|
23
|
+
logging: {}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
// INSERT NEW TOOL REGISTRATION HERE
|
|
27
|
+
new MatrixTool().installTo(server);
|
|
28
|
+
new ReverseGeocodeTool().installTo(server);
|
|
29
|
+
new ForwardGeocodeTool().installTo(server);
|
|
30
|
+
new IsochroneTool().installTo(server);
|
|
31
|
+
new PoiSearchTool().installTo(server);
|
|
32
|
+
new CategorySearchTool().installTo(server);
|
|
33
|
+
new StaticMapImageTool().installTo(server);
|
|
34
|
+
new DirectionsTool().installTo(server);
|
|
35
|
+
// Start receiving messages on stdin and sending messages on stdout
|
|
36
|
+
const transport = new StdioServerTransport();
|
|
37
|
+
await server.connect(transport);
|
|
38
|
+
//# 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,EAA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
|
+
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapboxApiBasedTool.js","sourceRoot":"","sources":["../../src/tools/MapboxApiBasedTool.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAc,MAAM,KAAK,CAAC;AAEpC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC,KAAK,CACd,CAAC,CAAC,KAAK,CAAC;QACN,CAAC,CAAC,MAAM,CAAC;YACP,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;YACvB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;SACjB,CAAC;QACF,CAAC,CAAC,MAAM,CAAC;YACP,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;YACxB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;YAChB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;SACrB,CAAC;KACH,CAAC,CACH;IACD,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACrC,CAAC,CAAC;AAEH,MAAM,OAAgB,kBAAkB;IAI7B,WAAW,CAAc;IACxB,MAAM,GAAqB,IAAI,CAAC;IAE1C,MAAM,CAAU,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IACtE,MAAM,CAAU,mBAAmB,GACjC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,yBAAyB,CAAC;IAE/D,YAAY,MAAoC;QAC9C,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,QAAiB;QACzB,IAAI,CAAC;YACH,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,CAAC;gBAC5C,MAA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IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CACpB,CAAC;IACJ,CAAC;IAED;;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"}
|