Skip to content

lionkeng/mapbox-mcp-server

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mapbox MCP Server with HTTP Transport

npm version

Node.js server implementing Model Context Protocol (MCP) for Mapbox APIs.

Acknowledgment

This repository is a fork of the original mapbox/mcp-server, extending it with HTTP transport capabilities using the Fastify web framework. The original implementation provides stdio-based MCP transport, while this fork adds support for streamable HTTP transport with Server-Sent Events (SSE), making it suitable for web-based integrations and remote access scenarios.

Unlock Geospatial Intelligence for Your AI Applications

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:

  • Global geocoding to convert addresses and place names to coordinates and vice versa
  • Points of interest (POI) search across millions of businesses, landmarks, and places worldwide
  • Multi-modal routing for driving, walking, and cycling with real-time traffic
  • Travel time matrices to analyze accessibility and optimize logistics
  • Isochrone generation to visualize areas reachable within specific time or distance constraints
  • Static map images to create visual representations of locations, routes, and geographic data

Whether you're building an AI travel assistant (really? 😉), 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.

HTTP Transport Extension

This fork extends the original Mapbox MCP server with HTTP transport capabilities, providing:

  • Streamable HTTP Transport: Built on the Fastify web framework for high-performance HTTP handling
  • Server-Sent Events (SSE): Real-time streaming of responses for long-running operations
  • Authentication: JWT-based authentication for secure API access
  • Rate Limiting: Built-in rate limiting to prevent abuse (100 requests per 15 minutes per IP)
  • Health Monitoring: Health check endpoint for monitoring server status
  • CORS Support: Configurable CORS headers for browser-based clients
  • Graceful Shutdown: Proper cleanup of resources on server termination

The HTTP transport maintains full compatibility with all Mapbox geospatial tools while enabling web-based and remote client integrations.

Mapbox MCP Server Demo

Usage

A Mapbox access token is required to use this MCP server.

To get a Mapbox access token:

  1. Sign up for a free Mapbox account at mapbox.com/signup
  2. Navigate to your Account page
  3. Create a new token or use the default public token

For more information about Mapbox access tokens, see the Mapbox documentation on access tokens.

HTTP Server Usage

Environment Variables

When running the HTTP server, configure these environment variables:

Required:

  • MAPBOX_ACCESS_TOKEN: Your Mapbox API access token
  • JWT_SECRET: Secret key for JWT token generation (minimum 32 characters)

Optional:

  • PORT: HTTP server port (default: 8080)
  • HOST: Server host address (default: 0.0.0.0)
  • VERBOSE_ERRORS: Enable detailed error messages (default: false)
  • NODE_ENV: Environment mode (development/production/test)

Starting the HTTP Server

# Install dependencies
npm install

# Build the project
npm run build

# Start the HTTP server (easiest method)
MAPBOX_ACCESS_TOKEN="your_token_here" \
JWT_SECRET="your-secret-key-at-least-32-characters-long" \
npm run dev

# Alternative: Start with custom port
MAPBOX_ACCESS_TOKEN="your_token_here" \
JWT_SECRET="your-secret-key-at-least-32-characters-long" \
PORT=3000 \
node dist/index.js --http

Testing the HTTP Server

Once the server is running, you can test it using curl:

# Get authentication token
curl -X POST http://localhost:8080/auth \
  -H "Content-Type: application/json" \
  -d '{}'

# List available tools (replace YOUR_JWT_TOKEN with the token from /auth)
curl -X POST http://localhost:8080/ \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/list",
    "id": 1
  }'

# Health check
curl http://localhost:8080/health

Testing with mcp-client

This repository includes a Python-based MCP client for testing the HTTP transport:

Setup

# Navigate to the mcp-client directory
cd mcp-client

# Install dependencies with uv
uv sync

Running Tests

# Set environment variables
export MAPBOX_ACCESS_TOKEN="your_token_here"
export JWT_SECRET="your-secret-key-at-least-32-characters-long"

# Run integration tests
uv run pytest tests/integration/test_mcp_connection.py -v

# Run the interactive CLI client
uv run cli

Example Client Usage

The mcp-client provides both an interactive CLI and programmatic access:

Interactive CLI Mode

# Start interactive mode
uv run cli

# Or run a single query
uv run cli "Find coffee shops near Times Square"

Integration Guides

For detailed setup instructions for different integrations, refer to the following guides:

Example Prompts

Try these prompts with Claude Desktop or other MCP clients after setup:

Location Discovery

  • "Find coffee shops within walking distance of the Empire State Building"
  • "Show me gas stations along the route from Boston to New York"
  • "What restaurants are near Times Square?"

Navigation & Travel

  • "Get driving directions from LAX to Hollywood with current traffic"
  • "How long would it take to walk from Central Park to Times Square?"
  • "Calculate travel time from my hotel (Four Seasons) to JFK Airport by taxi during rush hour"

Visualization & Maps

  • "Create a map image showing the route from Golden Gate Bridge to Fisherman's Wharf with markers at both locations"
  • "Show me a satellite view of Manhattan with key landmarks marked"
  • "Generate a map highlighting all Starbucks locations within a mile of downtown Seattle"

Analysis & Planning

  • "Show me areas reachable within 30 minutes of downtown Portland by car"
  • "Calculate a travel time matrix between these 3 hotel locations (Marriott, Sheraton and Hilton) and the convention center in Denver"
  • "Find the optimal route visiting these 3 tourist attractions (Golden Gate, Musical Stairs and Fisherman's Wharf) in San Francisco"

Tips for Better Results

  • Be specific about locations (use full addresses or landmark names)
  • Specify your preferred travel method (driving, walking, cycling)
  • Include time constraints when relevant ("during rush hour", "at 3 PM")
  • Ask for specific output formats when needed ("as a map image", "in JSON format")

Tools

Mapbox API tools

Matrix tool

Calculates travel times and distances between multiple points using Mapbox Matrix API. Features include:

  • Efficient one-to-many, many-to-one or many-to-many routing calculations
  • Support for different travel profiles (driving-traffic, driving, walking, cycling)
  • Departure time specification for traffic-aware calculations
  • Route summarization with distance and duration metrics
  • Control approach (curb/unrestricted) and range of allowed departure bearings

Static image tool

Generates static map images using the Mapbox static image API. Features include:

  • Custom map styles (streets, outdoors, satellite, etc.)
  • Adjustable image dimensions and zoom levels
  • Support for multiple markers with custom colors and labels
  • Overlay options including polylines and polygons
  • Auto-fitting to specified coordinates

POI search tool

Finds specific points of interest or brand locations by name using the Mapbox Search Box forward search API. Features include:

  • Search for specific points of interest by proper name or unique brand (e.g., "Amalie Arena", "Starbucks")
  • Find all nearby branches of a brand (e.g., "Macy's stores near me")
  • Geographic proximity biasing for more relevant results
  • Support for multiple languages and countries

Category search tool

Performs a category search using the Mapbox Search Box category search API. Features include:

  • Search for points of interest by category (restaurants, hotels, gas stations, etc.)
  • Filtering by geographic proximity
  • Customizable result limits
  • Rich metadata for each result
  • Support for multiple languages

Forward geocoding tool

Performs forward geocoding using the Mapbox geocoding V6 API. Features include:

  • Convert addresses or place names to geographic coordinates
  • Fuzzy matching for partial or misspelled inputs
  • Results filtering by country, region, or bounding box
  • Customizable result limits
  • Multiple language support

Reverse geocoding tool

Performs reverse geocoding using the Mapbox geocoding V6 API. Features include:

  • Convert geographic coordinates to human-readable addresses
  • Customizable levels of detail (street, neighborhood, city, etc.)
  • Results filtering by type (address, poi, neighborhood, etc.)
  • Support for multiple languages
  • Rich location context information

Directions tool

Fetches routing directions using the Mapbox Directions API. Features include:

  • Support for different routing profiles: driving (with live traffic or typical), walking, and cycling
  • Route from multiple waypoints (2-25 coordinate pairs)
  • Alternative routes option
  • Route annotations (distance, duration, speed, congestion)
  • Scheduling options:
    • Future departure time (depart_at) for driving and driving-traffic profiles
    • Desired arrival time (arrive_by) for driving profile only
  • Profile-specific optimizations:
    • Driving: vehicle dimension constraints (height, width, weight)
  • Exclusion options for routing:
    • Common exclusions: ferry routes, cash-only tolls
    • Driving-specific exclusions: tolls, motorways, unpaved roads, tunnels, country borders, state borders
    • Custom point exclusions (up to 50 geographic points to avoid)
  • GeoJSON geometry output format

Isochrone tool

Computes areas that are reachable within a specified amount of times from a location using Mapbox Isochrone API. Features include:

  • Support for different travel profiles (driving, walking, cycling)
  • Customizable travel times or distances
  • Multiple contour generation (e.g., 15, 30, 45 minute ranges)
  • Optional departure or arrival time specification
  • Color customization for visualization

Development

Inspecting server

Using Node.js

# Build
npm run build

# Inspect
npx @modelcontextprotocol/inspector node dist/index.js

Using Docker

# Build the Docker image
docker build -t mapbox-mcp-server .

# Run and inspect the server
npx @modelcontextprotocol/inspector docker run -i --rm --env MAPBOX_ACCESS_TOKEN="YOUR_TOKEN" mapbox-mcp-server

Create new tool

npx plop create-tool
# provide tool name without suffix (e.g. Search)

Environment Variables

VERBOSE_ERRORS

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.

Data Usage & Privacy

What data is sent to Mapbox APIs

When you use the MCP server tools, the following data is sent directly from your environment to Mapbox APIs:

  • Geocoding tools: Address/location text, coordinates, country/region filters
  • Search tools: Search queries, location coordinates for proximity, category filters
  • Directions tool: Start/end coordinates, waypoints, routing preferences, vehicle constraints
  • Matrix tool: Multiple coordinate pairs, travel profile, departure times
  • Static map tool: Coordinates, zoom level, styling preferences, marker information
  • Isochrone tool: Origin coordinates, time/distance parameters, travel profile

Your privacy

  • Local execution: All API calls are made directly from your environment to Mapbox APIs
  • Token security: Your Mapbox API token remains on your local machine and is never transmitted to or stored by this MCP server
  • No data storage: This MCP server does not store, log, or collect any of your data or API requests
  • Direct communication: There is no intermediary server between you and Mapbox APIs

Third-party data usage

  • Mapbox's privacy policy governs data sent to their APIs: https://www.mapbox.com/legal/privacy/
  • API usage: Standard Mapbox API terms apply to all requests made through these tools
  • Data retention: Refer to Mapbox's documentation for their data retention policies

Support & Contact

For MCP Server Issues

For Mapbox API Questions

Maintenance Commitment

The original MCP server is officially maintained by Mapbox, Inc. with:

  • Regular updates for new Mapbox API features
  • Bug fixes and security updates
  • Compatibility with latest MCP protocol versions
  • Community support through GitHub issues

All licensing for this fork will adhere to the original licensing. BSD 3-Clause License

About

Mapbox Model Context Protocol (MCP) server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 82.5%
  • Python 14.0%
  • JavaScript 3.2%
  • Other 0.3%