### Example Workflow: Create Multi-Environment Setup Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-devkit-patterns/references/troubleshooting.md Illustrates setting up styles and tokens for different environments (dev, staging, prod) with specific access levels and domain restrictions. ```text You: "Set up styles and tokens for dev, staging, prod: - Dev: Full access, localhost - Staging: Read-only, staging.example.com - Prod: Minimal scopes, example.com Each environment needs its own style variant." AI: [Creates 3 styles and 3 tokens with specifications] ``` -------------------------------- ### Start Development Server Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/examples/web/performance-optimized/README.md Run this command to start the development server for the application. ```bash npm run dev ``` -------------------------------- ### Install Dependencies Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/examples/web/performance-optimized/README.md Run this command to install the necessary project dependencies. ```bash npm install ``` -------------------------------- ### Run All Python Examples Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-runtime-patterns/examples/README.md Execute all Python examples by navigating to the 'python' directory and running the main script. ```bash cd python python pydantic_ai_example.py python crewai_example.py python smolagents_example.py ``` -------------------------------- ### Example .env.example file Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-web-integration-patterns/references/token-management.md Provide an example .env file for your team to show the required environment variables and their format, without exposing actual tokens. ```bash VITE_MAPBOX_ACCESS_TOKEN=your_token_here ``` -------------------------------- ### Python Setup for Mapbox MCP Integration Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-runtime-patterns/examples/README.md Sets up the Python environment by installing dependencies and exporting necessary environment variables for Mapbox, OpenAI, and HuggingFace tokens. ```bash cd python pip install -r requirements.txt # Set environment variables export MAPBOX_ACCESS_TOKEN="your_token_here" export OPENAI_API_KEY="your_openai_key" export HF_TOKEN="your_huggingface_token" # For smolagents ``` -------------------------------- ### Run Smolagents Example Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-runtime-patterns/examples/README.md Executes the Smolagents example script, demonstrating lightweight agents with direct MCP connection or custom tools. ```bash python smolagents_example.py ``` -------------------------------- ### TypeScript Example Commands Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-runtime-patterns/examples/README.md Commands to type-check and run individual TypeScript examples. Ensure you are in the 'typescript' directory. ```bash cd typescript npm run build npm run mastra npm run langchain ``` -------------------------------- ### Run LangChain Example Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-runtime-patterns/examples/README.md Executes the LangChain example script, showcasing a conversational AI framework with tool chaining and memory management. ```bash npm run langchain ``` -------------------------------- ### Install Mapbox Plugin Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/README.md Install the Mapbox plugin from the added marketplace. This makes Mapbox skills available in your AI tool. ```bash /plugin install mapbox ``` -------------------------------- ### TypeScript Setup for Mapbox MCP Integration Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-runtime-patterns/examples/README.md Sets up the TypeScript environment by installing dependencies and exporting necessary environment variables for Mapbox and OpenAI API keys. ```bash cd typescript npm install # Set environment variables export MAPBOX_ACCESS_TOKEN="your_token_here" export OPENAI_API_KEY="your_openai_key" ``` -------------------------------- ### Install and Run MCP Server (Self-Hosted) Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-runtime-patterns/AGENTS.md Install the MCP server using npm and run it with your Mapbox access token configured in the environment. ```bash npm install @mapbox/mcp-server # Or: npx @mapbox/mcp-server export MAPBOX_ACCESS_TOKEN="your_token" ``` -------------------------------- ### Run Mastra Example Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-runtime-patterns/examples/README.md Executes the Mastra example script, demonstrating type-safe tool creation with Zod schemas and Mapbox MCP server integration. ```bash npm run mastra ``` -------------------------------- ### iOS Demo Quick Start Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/demos/README.md Commands to set up and run the iOS demo application. Ensure your Mapbox access token is added to `Info.plist`. ```bash cd ios-demo # Add your token to Sources/MapboxIOSDemo/Info.plist swift package resolve open Package.swift ``` -------------------------------- ### Example Workflow Steps Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/README.md Illustrates a typical user request and the sequence of skill and tool interactions to fulfill it. ```text User: "Create a high-performance map for my restaurant finder" 1. [mapbox-cartography skill] → Understands restaurant maps need high contrast, muted background 2. [mapbox-token-security skill] → Creates token with only styles:read scope, URL restrictions 3. [mapbox-style-patterns skill] → Applies POI Finder pattern 4. [MCP style_builder_tool] → Generates style JSON 5. [MCP create_style_tool] → Creates style in Mapbox account 6. [mapbox-web-performance-patterns skill] → Recommends clustering for > 1,000 markers 7. [MCP preview_style_tool] → Generates preview link ``` -------------------------------- ### Install Mapbox Search JS Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-web-integration-patterns/SKILL.md Installs the Mapbox Search JS library for React or other web frameworks. ```bash npm install @mapbox/search-js-react@^1.0.0 # React npm install @mapbox/search-js-web@^1.0.0 # Other frameworks ``` -------------------------------- ### Loading a Reference File Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-google-maps-migration/SKILL.md Example of how to load a reference markdown file within the skill's directory structure. ```bash Load references/shapes-geocoding.md ``` -------------------------------- ### Run CrewAI Example Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-runtime-patterns/examples/README.md Executes the CrewAI example script, showcasing multi-agent orchestration with specialized roles and task dependencies. ```bash python crewai_example.py ``` -------------------------------- ### Skill Structure Example Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/CONTRIBUTING.md Illustrates the required directory structure for a new skill, including metadata, documentation, assets, scripts, and evaluation files. ```bash skills/your-skill-name/ ├── SKILL.md # Required: Metadata + instructions (<500 lines) ├── references/ # Optional: Documentation loaded on demand │ ├── framework-a.md │ └── framework-b.md ├── assets/ # Optional: Templates, schemas, static resources │ └── project-template.md ├── scripts/ # Optional: Executable code agents can run │ └── validate.sh ├── evals/ │ └── evals.json # Required: Skill evaluation metrics (3-5 evals) └── AGENTS.md # Optional: Condensed version for Cursor/Copilot ``` -------------------------------- ### Clone and Install Mapbox Agent Skills Locally Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/README.md Clone the repository and install the skills locally for development using Claude Code or by creating a symlink. ```bash git clone https://github.com/mapbox/mapbox-agent-skills.git cd mapbox-agent-skills # Install in Claude Code npx skills add . -a claude-code # Or symlink for development mkdir -p .claude ln -s $(pwd)/skills .claude/skills ``` -------------------------------- ### Install Mapbox Search JS Core Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-search-integration/references/nodejs-search.md Install the Mapbox Search JS Core library using npm. This is the recommended approach for server-side search. ```bash npm install @mapbox/search-js-core ``` -------------------------------- ### Install Mapbox GL JS with npm Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-web-integration-patterns/SKILL.md Installs the latest v3.x version of Mapbox GL JS. Recommended for production environments. ```bash npm install mapbox-gl@^3.0.0 # Installs latest v3.x ``` -------------------------------- ### Basic Crew Initialization and Execution Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-runtime-patterns/references/crewai.md Demonstrates the fundamental setup for a CrewAI crew with agents and tasks, followed by execution. ```python crew = Crew( agents=[location_analyst, route_planner], tasks=[find_restaurants_task, plan_route_task], verbose=True ) result = crew.kickoff() print(result) ``` -------------------------------- ### Self-Host Mapbox DevKit Server Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-devkit-patterns/AGENTS.md Instructions for cloning, installing, and building the Mapbox DevKit server for self-hosting. ```bash git clone https://github.com/mapbox/mcp-devkit-server.git cd mcp-devkit-server && npm install && npm run build ``` -------------------------------- ### Install All Mapbox Agent Skills Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/README.md Use this command to install all available skills for Claude Code. For development, you can manually symlink the skills directory. ```bash npx skills add mapbox/mapbox-agent-skills ``` ```bash # Or manually symlink (for development) mkdir -p .claude ln -s ~/git/mapbox-agent-skills/skills .claude/skills ``` -------------------------------- ### Install Mapbox Agent Skills for VS Code (GitHub Copilot) Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/README.md Install the Mapbox Agent Skills for integration with VS Code and GitHub Copilot. ```bash npx skills add mapbox/mapbox-agent-skills -a vscode ``` -------------------------------- ### Install All Mapbox Agent Skills via CLI Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/README.md Install all Mapbox Agent Skills using the skills CLI. This command fetches all available skills for the Mapbox organization. ```bash npx skills add mapbox/mapbox-agent-skills ``` -------------------------------- ### Install Mapbox GL JS and Turf Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-store-locator-patterns/SKILL.md Install the necessary Mapbox GL JS and Turf.js libraries using npm. These are required for map display and spatial calculations. ```bash npm install mapbox-gl @turf/turf ``` -------------------------------- ### Install Mapbox MCP Server with npm Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-runtime-patterns/SKILL.md Use this command to install the Mapbox MCP Server package locally for custom deployments or development. ```bash npm install @mapbox/mcp-server ``` -------------------------------- ### Mapbox Access Token Setup Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-google-maps-migration/AGENTS.md Shows how to set the Mapbox access token, typically stored in environment variables for client-side use. ```javascript // Store in environment variables mapboxgl.accessToken = process.env.NEXT_PUBLIC_MAPBOX_TOKEN; ``` -------------------------------- ### Install Specific Mapbox Skill via CLI Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/README.md Install a specific Mapbox skill using the skills CLI by providing the skill name. This is useful for targeted skill management. ```bash npx skills add mapbox/mapbox-agent-skills --skill mapbox-web-performance-patterns ``` -------------------------------- ### Run Pydantic AI Example Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-runtime-patterns/examples/README.md Executes the Pydantic AI example script, which demonstrates type-safe agents with validation and Mapbox MCP server integration. ```bash python pydantic_ai_example.py ``` -------------------------------- ### Verify Mapbox DevKit Tools Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-devkit-patterns/references/setup.md A sample prompt to verify the installation of the Mapbox DevKit tools by asking the AI assistant to list available tools. ```text "List the available Mapbox DevKit tools" ``` -------------------------------- ### Install Mapbox Search JS Packages Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-web-integration-patterns/SKILL.md Install the appropriate Mapbox Search JS package for your framework. The React and Vanilla/Vue/Svelte packages include core functionality. ```bash npm install @mapbox/search-js-react # React npm install @mapbox/search-js-web # Vanilla/Vue/Svelte ``` -------------------------------- ### Manual Installation for AGENTS.md-based Tools Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/README.md Manually download the AGENTS.md file for tools like Codex and Copilot. This is for AI assistants that use AGENTS.md format. ```bash # For Codex, Copilot, and other AGENTS.md-based tools — copy to project root curl -O https://raw.githubusercontent.com/mapbox/mapbox-agent-skills/main/skills/mapbox-web-performance-patterns/AGENTS.md ``` -------------------------------- ### Clone and Build Mapbox DevKit Server Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-devkit-patterns/references/setup.md Instructions for cloning the Mapbox DevKit server repository, installing dependencies, and building the server for self-hosted deployment. ```bash git clone https://github.com/mapbox/mcp-devkit-server.git cd mcp-devkit-server npm install npm run build ``` -------------------------------- ### Least Privilege Scope Examples Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-token-security/SKILL.md Demonstrates the principle of least privilege by showing overly permissive versus minimal required scopes for Mapbox tokens. ```javascript // Overly permissive - don't do this { scopes: ['styles:read', 'styles:write', 'styles:list', 'styles:delete', 'tokens:read', 'tokens:write']; } ``` ```javascript // Only what's needed for displaying a map { scopes: ['styles:read', 'fonts:read']; } // Add 'styles:tiles' if your map uses raster tile sources { scopes: ['styles:read', 'fonts:read', 'styles:tiles']; } ``` -------------------------------- ### Add mapbox_maps_flutter Dependency Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-flutter-patterns/SKILL.md Add the mapbox_maps_flutter package to your pubspec.yaml file and run flutter pub get to install it. ```yaml dependencies: mapbox_maps_flutter: ^2.0.0 ``` -------------------------------- ### Android Demo Quick Start Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/demos/README.md Commands to set up and run the Android demo application. Ensure your Mapbox access token is added to `mapbox_access_token.xml` and sync Gradle. ```bash cd android-demo # Add your token to app/src/main/res/values/mapbox_access_token.xml # Open in Android Studio and sync Gradle ``` -------------------------------- ### Example Workflow: Build a Restaurant Finder Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-devkit-patterns/references/troubleshooting.md Demonstrates a conversational workflow for building a restaurant finder app, including style creation, token generation, data validation, and applying filters. ```text You: "I'm building a restaurant finder app. Create: 1. A light, neutral style emphasizing restaurants 2. A token for localhost with minimal scopes 3. Validate this GeoJSON with restaurant locations: [paste]" AI: [Creates style, token, validates data] You: "Add filters to show only 4+ star restaurants" AI: [Updates style with expression] You: "Generate a preview URL" AI: [Returns preview] ``` -------------------------------- ### Mapbox Expression Calculations Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-data-visualization-patterns/AGENTS.md Perform mathematical calculations within Mapbox expressions. Examples include division, multiplication, and percentage calculations using `get` to retrieve property values. ```javascript // Divide ['/', ['get', 'numerator'], ['get', 'denominator']] // Multiply ['*', ['get', 'value'], 1.5] // Percentage ['*', ['/', ['get', 'part'], ['get', 'total']], 100] ``` -------------------------------- ### Get Current Location Once with Mapbox Android Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-android-patterns/references/location-tracking.md Retrieve the user's last known location and center the camera on it. This is useful for initial map setup or one-time location-based actions. ```kotlin mapView.location.getLastLocation { location -> location?.let { val point = Point.fromLngLat(it.longitude, it.latitude) mapView.camera.easeTo( CameraOptions.Builder() .center(point) .zoom(14.0) .build() ) } } ``` -------------------------------- ### Create Mastra Agent with Mapbox Tools Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-runtime-patterns/references/mastra.md Defines and configures a Mastra agent with specific geospatial tools for searching points of interest and getting directions. Ensure Zod is installed for schema validation. ```typescript // Create Mastra agent with Mapbox tools import { Agent } from '@mastra/core/agent'; import { createTool } from '@mastra/core/tools'; import { z } from 'zod'; const mcp = new MapboxMCP(); // Create Mapbox tools const searchPOITool = createTool({ id: 'search-poi', description: 'Find places of a specific category near a location', inputSchema: z.object({ category: z.string(), location: z.array(z.number()).length(2) }), execute: async ({ category, location }) => { return await mcp.callTool('category_search_tool', { category, proximity: { longitude: location[0], latitude: location[1] } }); } }); const getDirectionsTool = createTool({ id: 'get-directions', description: 'Get driving directions with traffic', inputSchema: z.object({ origin: z.array(z.number()).length(2), destination: z.array(z.number()).length(2) }), execute: async ({ origin, destination }) => { return await mcp.callTool('directions_tool', { coordinates: [ { longitude: origin[0], latitude: origin[1] }, { longitude: destination[0], latitude: destination[1] } ], routing_profile: 'mapbox/driving-traffic' }); } }); // Create location agent const locationAgent = new Agent({ id: 'location-agent', name: 'Location Intelligence Agent', instructions: 'You help users find places and plan routes with geospatial tools.', model: 'openai/gpt-5.2', tools: { searchPOITool, getDirectionsTool } }); // Use agent const result = await locationAgent.generate([ { role: 'user', content: 'Find restaurants near Times Square NYC (-73.9857, 40.7484)' } ]); ``` -------------------------------- ### Multi-Environment Setup Prompt Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-mcp-devkit-patterns/AGENTS.md This prompt outlines the creation of multiple environments (Dev, Staging, Prod) with distinct configurations for tokens and styles, emphasizing security and optimization. ```text "Create 3 environments: Dev: - Token: all scopes, localhost only - Style: app-dev (debug labels enabled) Staging: - Token: read-only, staging.example.com - Style: app-staging (production-like) Prod: - Token: minimal scopes, example.com - Style: app-prod (optimized)" ``` -------------------------------- ### Install Mapbox Agent Skills for Cursor Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/README.md Install the Mapbox Agent Skills specifically for use with Cursor. ```bash npx skills add mapbox/mapbox-agent-skills -a cursor ``` -------------------------------- ### Install Pods After Podfile Change Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-flutter-patterns/references/platform-setup.md After modifying the Podfile, navigate to the ios directory and run 'pod install' to update dependencies. ```bash cd ios && pod install && cd .. ``` -------------------------------- ### Map Initialization: Mapbox GL JS (After) Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-maplibre-migration/references/api-compatibility.md This example demonstrates initializing a map with Mapbox GL JS. Key differences include the package import, the need for a Mapbox access token, and a Mapbox-specific style URL. ```javascript import mapboxgl from 'mapbox-gl'; import 'mapbox-gl/dist/mapbox-gl.css'; // Add your Mapbox token mapboxgl.accessToken = 'pk.your_mapbox_access_token'; const map = new mapboxgl.Map({ container: 'map', style: 'mapbox://styles/mapbox/streets-v12', center: [-122.4194, 37.7749], zoom: 12 }); map.on('load', () => { new mapboxgl.Marker() .setLngLat([-122.4194, 37.7749]) .setPopup(new mapboxgl.Popup().setText('San Francisco')) .addTo(map); }); ``` -------------------------------- ### Initialize Map with CDN (No Bundler) Source: https://github.com/mapbox/mapbox-agent-skills/blob/main/skills/mapbox-web-integration-patterns/references/vanilla.md This pattern is suitable for quick prototyping or simple projects where a bundler is not used. It includes Mapbox GL JS CSS and JS via CDN links in the HTML. For production, it's recommended to use npm and a bundler for better version control and optimization. ```html
${result.place_formatted || ''}