Skip to main content
skill CX Codex

mapbox-mcp-runtime-patterns — Claude Code skill: how to install

Guides agents on integrating Mapbox MCP Server into AI frameworks. Helps models choose between local Turf.js math and live Mapbox routing APIs.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mapbox/mapbox-agent-skills --skill mapbox-mcp-runtime-patterns -a claude-code
Open on GitHub

What mapbox-mcp-runtime-patterns does

The skill supplies production patterns for running Mapbox MCP Server inside frameworks like Pydantic AI, Mastra, and LangChain. It teaches the agent when to execute free offline geometry tools using Turf.js and when to call external Mapbox APIs.

Reference files organize guidance for caching, batching, error handling, and domain architectures like real estate or food delivery. The agent learns to pick straight-line calculations for basic proximity, saving road routing and isochrones for live transit questions.

Live tools require a valid MAPBOX_ACCESS_TOKEN, so unauthenticated agents are limited to local Turf.js calculations.

What it helps with

  • connect Mapbox MCP Server to Pydantic AI or LangChain agents
  • separate offline Turf.js calculations from billed API calls
  • calculate reachability polygons using isochrones
  • implement caching and error handling for geospatial workflows

Example prompts for the agent

  • Show me an integration pattern for Mapbox MCP Server in Pydantic AI
  • Which tool should the agent use to test if a point is inside a polygon?
  • Configure directions_tool and matrix_tool for route estimation in Mastra

How to install mapbox-mcp-runtime-patterns

1Skills CLI (Vercel)

npx skills add mapbox/mapbox-agent-skills --skill mapbox-mcp-runtime-patterns -a claude-code

2Manually: put the files in place

~/.claude/skills/mapbox-mcp-runtime-patterns/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/mapbox-mcp-runtime-patterns/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about mapbox-mcp-runtime-patterns

How to install mapbox-mcp-runtime-patterns in Claude Code?

Run npx skills add mapbox/mapbox-agent-skills --skill mapbox-mcp-runtime-patterns -a claude-code in your terminal.

What does mapbox-mcp-runtime-patterns do?

It provides runtime patterns and architecture guidance for integrating Mapbox MCP Server into agent frameworks. It instructs models on selecting the right geospatial tools for routing, search, and spatial analysis.

Does the Mapbox MCP Server require an API key?

Offline tools powered by Turf.js run locally without credentials or API charges. Live features like directions_tool and isochrone_tool require a configured MAPBOX_ACCESS_TOKEN.

Source text

SKILL.md · MIT
---
name: mapbox-mcp-runtime-patterns
description: Integration patterns for Mapbox MCP Server in AI applications and agent frameworks. Covers runtime integration with pydantic-ai, mastra, LangChain, and custom agents. Use when building AI-powered applications that need geospatial capabilities.
---

# Mapbox MCP Runtime Patterns

This skill provides patterns for integrating the Mapbox MCP Server into AI applications for production use with geospatial capabilities.

## What is Mapbox MCP Server?

The [Mapbox MCP Server](https://github.com/mapbox/mcp-server) is a Model Context Protocol (MCP) server that provides AI agents with geospatial tools:

**Offline Tools (Turf.js):**

- Distance, bearing, midpoint calculations
- Point-in-polygon tests
- Area, buffer, centroid operations
- Bounding box, geometry simplification
- No API calls, instant results

**Mapbox API Tools:**

- Directions and routing
- Reverse geocoding
- POI category search
- Isochrones (reachability)
- Travel time matrices
- Static map images
- GPS trace map matching
- Multi-stop route optimization

**Utility Tools:**

- Server version info
- POI category list

**Key benefit:** Give your AI application geospatial superpowers without manually integrating multiple APIs.

## Understanding Tool Categories

Before integrating, understand the key distinctions between tools to help your LLM choose correctly:

### Distance: "As the Crow Flies" vs "Along Roads"

**Straight-line distance** (offline, instant):

- Tools: `distance_tool`, `bearing_tool`, `midpoint_tool`
- Use for: Proximity checks, "how far away is X?", comparing distances
- Example: "Is this restaurant within 2 miles?" → `distance_tool`

**Route distance** (API, traffic-aware):

- Tools: `directions_tool`, `matrix_tool`
- Use for: Navigation, drive time, "how long to drive?"
- Example: "How long to drive there?" → `directions_tool`

### Search: Type vs Specific Place

**Category/type search**:

- Tool: `category_search_tool`
- Use for: "Find coffee shops", "restaurants nearby", browsing by type
- Example: "What hotels are near me?" → `category_search_tool`

**Specific place/address**:

- Tool: `search_and_geocode_tool`, `reverse_geocode_tool`
- Use for: Named places, street addresses, landmarks
- Example: "Find 123 Main Street" → `search_and_geocode_tool`

### Travel Time: Area vs Route

**Reachable area** (what's within reach):

- Tool: `isochrone_tool`
- Returns: GeoJSON polygon of everywhere reachable
- Example: "What can I reach in 15 minutes?" → `isochrone_tool`

**Specific route** (how to get there):

- Tool: `directions_tool`
- Returns: Turn-by-turn directions to one destination
- Example: "How do I get to the airport?" → `directions_tool`

### Cost & Performance

**Offline tools** (free, instant):

- No API calls, no token usage
- Use whenever real-time data not needed
- Examples: `distance_tool`, `point_in_polygon_tool`, `area_tool`

**API tools** (requires token, counts against usage):

- Real-time traffic, live POI data, current conditions
- Use when accuracy and freshness matter
- Examples: `directions_tool`, `category_search_tool`, `isochrone_tool`

**Best practice:** Prefer offline tools when possible, use API tools when you need real-time data or routing.

## Installation & Setup

### Option 1: Hosted Server (Recommended)

**Easiest integration** - Use Mapbox's hosted MCP server at:

```
https://mcp.mapbox.com/mcp
```

No installation required. Simply pass your Mapbox access token in the `Authorization` header.

**Benefits:**

- No server management
- Always up-to-date
- Production-ready
- Lower latency (Mapbox infrastructure)

**Authentication:**

Use token-based authentication (standard for programmatic access):

```
Authorization: Bearer your_mapbox_token
```

**Note:** The hosted server also supports OAuth, but that's primarily for interactive flows (coding assistants, not production apps).

### Option 2: Self-Hosted

For custom deployments or development:

```bash
npm install @mapbox/mcp-server
```

Or use directly via npx:

```bash
npx @mapbox/mcp-server
```

**Environment setup:**

```bash
export MAPBOX_ACCESS_TOKEN="your_token_here"
```

## Reference Files

Detailed integration patterns and production guidance are organized into reference files. Load the ones relevant to your task.

- **Pydantic AI** -- Type-safe Python agents
  Load: `references/pydantic-ai.md`

- **CrewAI** -- Multi-agent orchestration
  Load: `references/crewai.md`

- **Smolagents** -- Lightweight HuggingFace agents
  Load: `references/smolagents.md`

- **Mastra** -- Multi-agent TypeScript systems
  Load: `references/mastra.md`

- **LangChain** -- Conversational AI with tool chaining
  Load: `references/langchain.md`

- **Custom Agent** -- Zillow/TripAdvisor/DoorDash-style patterns, architecture diagrams, hybrid approach
  Load: `references/custom-agent.md`

- **Use Cases** -- Real Estate, Food Delivery, Travel Planning examples
  Load: `references/use-cases.md`

- **Production Patterns** -- Caching, batch operations, tool descriptions, error handling, security, rate limiting, testing
  Load: `references/production.md`

## Resources

- [Mapbox MCP Server](https://github.com/mapbox/mcp-server)
- [Model Context Protocol](https://modelcontextprotocol.io)
- [Pydantic AI](https://ai.pydantic.dev/)
- [Mastra](https://mastra.ai/)
- [LangChain](https://docs.langchain.com/oss/javascript/langchain/overview/)
- [Mapbox API Documentation](https://docs.mapbox.com/api/)

## When to Use This Skill

Invoke this skill when:

- Integrating Mapbox MCP Server into AI applications
- Building AI agents with geospatial capabilities
- Architecting Zillow/TripAdvisor/DoorDash-style apps with AI
- Choosing between MCP, direct APIs, or SDKs
- Optimizing geospatial operations in production
- Implementing error handling for geospatial AI features
- Testing AI applications with geospatial tools

© mapbox · MIT · mapbox/mapbox-agent-skills

Similar skills

All skills for Agent setup: memory, context, orchestration →

From the same set19

mapbox-store-locator-patterns Store locator patterns for Mapbox GL JS. Helps agents implement marker layers, synchronized lists, and Turf distance calculations without DOM overhead. CX Codex +1 1,700installs mapbox-ios-patterns Official integration patterns for Mapbox Maps SDK v11 on iOS in Swift, SwiftUI and UIKit. Useful when you need a map, markers or GeoJSON data in an app. CX Codex +1 1,500installs mapbox-mcp-devkit-patterns A skill that shows your AI assistant how to drive the Mapbox MCP DevKit Server: styles, tokens, validation and docs lookup from the chat. CX Codex +1 1,500installs mapbox-maplibre-migration Walks a project from MapLibre GL JS to Mapbox GL JS: package swap, imports, styles, token. Useful when self-hosted tiles or community support stop being enough. CX Codex +1 1,400installs mapbox-google-maps-migration A skill that walks an agent through porting a project from Google Maps Platform to Mapbox GL JS, with API equivalents and a migration order. CX Codex +1 1,400installs mapbox-android-patterns A skill with official Mapbox Maps SDK v11 integration patterns for Android: map setup, markers, user location, camera control. Useful when the agent builds a map screen. CX Codex +1 1,400installs mapbox-flutter-patterns Skill with official integration patterns for the Mapbox Maps Flutter SDK. Helps set up maps on iOS and Android, add markers, control the camera, and load GeoJSON data. CX Codex +1 787installs mapbox-navigation-patterns Tells your agent how to wire up turn-by-turn navigation, multi-stop routes and voice guidance on Mapbox. CX Codex +1 401installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor