mapbox-mcp-runtime-patterns
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.
What this skill does
# 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
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.