Mapbox开发者
STDIO提供Mapbox开发者API访问的MCP服务器
提供Mapbox开发者API访问的MCP服务器
A Model Context Protocol (MCP) server that provides AI assistants with direct access to Mapbox developer APIs. This server enables AI models to interact with Mapbox services, helping developers build Mapbox applications more efficiently.
https://github.com/user-attachments/assets/8b1b8ef2-9fba-4951-bc9a-beaed4f6aff6
Get started by integrating with your preferred AI development environment:
This MCP server can be packaged as a DXT (Desktop Extension) file for easy distribution and installation. DXT is a standardized format for distributing local MCP servers, similar to browser extensions.
To create a DXT package:
# Install the DXT CLI tool npm install -g @anthropic-ai/dxt # Build the server first npm run build # Create the DXT package npx @anthropic-ai/dxt pack
This will generate mcp-devkit-server.dxt using the configuration in manifest.json.
The DXT package includes:
dist/esm/index.js)For quick access, you can use our hosted MCP endpoint:
Endpoint: https://mcp-devkit.mapbox.com/mcp
For detailed setup instructions for different clients and API usage, see the Hosted MCP Server Guide. Note: This guide references the standard MCP endpoint - you'll need to update the endpoint URL to use the devkit endpoint above.
A Mapbox access token is required to use this MCP server.
For more information about Mapbox access tokens, see the Mapbox documentation on access tokens.
⚠️ IMPORTANT: Token Privileges Required
The MAPBOX_ACCESS_TOKEN environment variable is required. Each tool requires specific token scopes/privileges to function properly. For example:
styles:read scopestyles:write scopetokens:read and tokens:write scopesget_latest_mapbox_docs_tool - Access the latest official Mapbox documentation directly from the source. This tool fetches comprehensive, up-to-date information about all Mapbox APIs, SDKs, and developer resources from docs.mapbox.com/llms.txt.
Example prompts:
📖 See more examples and interactive demo →
get_reference_tool - Access static Mapbox reference documentation and schemas. This tool provides essential reference information that helps AI assistants understand Mapbox concepts and build correct styles and tokens.
Note: This tool exists as a workaround for Claude Desktop's current limitation with MCP resources. Claude Desktop can see resources (via
resources/list) but doesn't automatically callresources/readto fetch their content. This tool provides the same reference data through the tool interface, which Claude Desktop does support. Other MCP clients that fully support the resources protocol can access this data directly as MCP Resources (see Resources section below).
Available References:
resource://mapbox-style-layers - Mapbox GL JS style specification reference guide covering all layer types (fill, line, symbol, circle, fill-extrusion) and their propertiesresource://mapbox-streets-v8-fields - Complete field definitions for all Mapbox Streets v8 source layers, including enumerated values for each field (useful for building filters)resource://mapbox-token-scopes - Comprehensive token scope reference explaining what each scope allows and which scopes are needed for different operationsresource://mapbox-layer-type-mapping - Mapping of Mapbox Streets v8 source layers to compatible GL JS layer types, with common usage patternsExample prompts:
Complete set of tools for managing Mapbox styles via the Styles API:
Style Builder Tool - Create and modify Mapbox styles programmatically through conversational prompts
📖 See the Style Builder documentation for detailed usage and examples →
ListStylesTool - List all styles for a Mapbox account
limit (optional - max number of styles), start (optional - pagination token)CreateStyleTool - Create a new Mapbox style
name, style (Mapbox style specification)RetrieveStyleTool - Retrieve a specific style by ID
styleIdUpdateStyleTool - Update an existing style
styleId, name (optional), style (optional)DeleteStyleTool - Delete a style by ID
styleIdPreviewStyleTool - Generate preview URL for a Mapbox style using an existing public token
styleId, title (optional), zoomwheel (optional), zoom (optional), center (optional), bearing (optional), pitch (optional)styles:read scope.⚠️ Required Token Scopes:
All style tools require a valid Mapbox access token with specific scopes. Using a token without the correct scope will result in authentication errors.
styles:list scopestyles:write scopestyles:download scopestyles:write scopestyles:write scopetokens:read scope (to list tokens) and at least one public token with styles:read scopeNote: The username is automatically extracted from the JWT token payload.
Example prompts:
Create a new Mapbox access token with specified scopes and optional URL restrictions.
Parameters:
note (string, required): Description of the tokenscopes (array of strings, required): Array of scopes/permissions for the token. Must be valid Mapbox scopes (see below)allowedUrls (array of strings, optional): URLs where the token can be used (max 100)expires (string, optional): Expiration time in ISO 8601 format (maximum 1 hour in the future)Available Scopes:
Available scopes for public tokens:
styles:tiles - Read styles as raster tilesstyles:read - Read stylesfonts:read - Read fontsdatasets:read - Read datasetsvision:read - Read Vision APIExample:
{ "note": "Development token for my app", "scopes": ["styles:read", "fonts:read"], "allowedUrls": ["https://myapp.com"] }
Example prompts:
List Mapbox access tokens for the authenticated user with optional filtering and pagination.
Parameters:
default (boolean, optional): Filter to show only the default public tokenlimit (number, optional): Maximum number of tokens to return per page (1-100)sortby (string, optional): Sort tokens by "created" or "modified" timestampstart (string, optional): The token ID after which to start the listing (when provided, auto-pagination is disabled)usage (string, optional): Filter by token type: "pk" (public)Pagination behavior:
start parameter is provided, the tool automatically fetches all pages of resultsstart parameter is provided, only the requested page is returned (for manual pagination control)Example:
{ "limit": 10, "sortby": "created", "usage": "pk" }
Example prompts:
Generate a geojson.io URL to visualize GeoJSON data. This tool:
Example usage:
{ "geojson": { "type": "Point", "coordinates": [-122.4194, 37.7749] } }
Returns: A single URL string that can be opened in a browser to view the GeoJSON data.
Note: This is a beta feature currently optimized for small to medium-sized GeoJSON files. Large GeoJSON files may result in very long URLs and slower performance. We plan to optimize this in future versions by implementing alternative approaches for handling large datasets.
Example prompts:
Convert coordinates between different coordinate reference systems (CRS), specifically between WGS84 (EPSG:4326) and Web Mercator (EPSG:3857).
Parameters:
coordinates (array, required): Array of coordinate pairs to convert. Each coordinate pair should be [longitude, latitude] for WGS84 or [x, y] for Web MercatorfromCRS (string, required): Source coordinate reference system. Supported values: "EPSG:4326" (WGS84), "EPSG:3857" (Web Mercator)toCRS (string, required): Target coordinate reference system. Supported values: "EPSG:4326" (WGS84), "EPSG:3857" (Web Mercator)Returns:
An array of converted coordinate pairs in the target CRS format.
Example:
{ "coordinates": [ [-122.4194, 37.7749], [-74.006, 40.7128] ], "fromCRS": "EPSG:4326", "toCRS": "EPSG:3857" }
Example prompts:
Calculates the bounding box of given GeoJSON content, returning coordinates as [minX, minY, maxX, maxY].
Parameters:
geojson (string or object, required): GeoJSON content to calculate bounding box for. Can be provided as:
Supported GeoJSON types:
Returns:
An array of four numbers representing the bounding box: [minX, minY, maxX, maxY]
minX: Western-most longitudeminY: Southern-most latitudemaxX: Eastern-most longitudemaxY: Northern-most latitudeExample:
{ "geojson": { "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-73.9857, 40.7484] }, "properties": {} }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-74.006, 40.7128] }, "properties": {} } ] } }
Example prompts:
This server exposes static reference documentation as MCP Resources. While these are primarily accessed through the get_reference_tool, MCP clients that fully support the resources protocol can access them directly.
Available Resources:
Mapbox Style Specification Guide (resource://mapbox-style-layers)
Mapbox Streets v8 Fields Reference (resource://mapbox-streets-v8-fields)
landuse layer has class field with values like park, cemetery, hospital, etc.Mapbox Token Scopes Reference (resource://mapbox-token-scopes)
Mapbox Layer Type Mapping (resource://mapbox-layer-type-mapping)
Accessing Resources:
get_reference_tool to access these referencesNote: Resources provide static reference data that doesn't change frequently, while tools provide dynamic, user-specific data (like listing your styles or tokens) and perform actions (like creating styles or tokens).
The project includes snapshot tests to ensure tool integrity and prevent accidental additions or removals of tools. These tests automatically discover all tools and create a snapshot of their metadata.
What the snapshot test covers:
snake_case_tool naming convention)When to update snapshots:
Adding a new tool: After creating a new tool, run the test with snapshot update flag:
npm test -- test/tools/tool-naming-convention.test.ts --updateSnapshot
Removing a tool: After removing a tool, update the snapshot:
npm test -- src/tools/tool-naming-convention.test.ts --updateSnapshot
Modifying tool metadata: If you change a tool's name or description, update the snapshot:
npm test -- src/tools/tool-naming-convention.test.ts --updateSnapshot
Running snapshot tests:
# Run all tests (snapshot will fail if tools have changed) npm test # Update snapshots after intentional changes npm test -- --updateSnapshot
Important: Only update snapshots when you have intentionally added, removed, or modified tools. Unexpected snapshot failures indicate accidental changes to the tool structure.
# Build npm run build # Inspect npx @modelcontextprotocol/inspector node dist/esm/index.js
# Build the Docker image docker build -t mapbox-mcp-devkit . # Run and inspect the server npx @modelcontextprotocol/inspector docker run -i --rm --env MAPBOX_ACCESS_TOKEN="YOUR_TOKEN" mapbox-mcp-devkit
npx plop create-tool # 1. Choose tool type: # - Mapbox tool (makes API calls to Mapbox services) # - Local tool (local processing, no API calls) # 2. Provide tool name without suffix using PascalCase (e.g. Search)
Generated file structure:
The plop generator creates three files for each new tool:
src/tools/your-tool-name-tool/
├── YourToolNameTool.schema.ts    # Input schema definition and types
├── YourToolNameTool.ts           # Main tool implementation
└── YourToolNameTool.test.ts      # Unit tests
After creating a new tool:
Update the input schema in YourToolNameTool.schema.ts:
Update the tool description in YourToolNameTool.ts:
Implement the tool logic in the execute method
Update test cases with actual test data in YourToolNameTool.test.ts
Update the snapshot test to include the new tool:
npm test -- src/tools/tool-naming-convention.test.ts --updateSnapshot
Run all tests to ensure everything works:
npm test
Schema separation benefits:
Set VERBOSE_ERRORS=true to get detailed error messages from the MCP server. This is useful for debugging issues when integrating with MCP clients.
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.
Issue: Tools fail with authentication errors
Solution: Check that your MAPBOX_ACCESS_TOKEN has the required scopes for the tool you're using. See the token scopes section above.
Issue: Large GeoJSON files cause slow performance
Solution: The GeoJSON preview tool may be slow with very large files. Consider simplifying geometries or using smaller datasets for preview purposes.
We welcome contributions to the Mapbox Development MCP Server! Please review our standards and guidelines before contributing: