Skip to content

Add live code examples tool for working snippets #72

@mattpodwysocki

Description

@mattpodwysocki

Context

Create a tool that fetches and provides working code examples from Mapbox documentation and examples repository, making it easy for AI assistants to provide copy-paste ready code.

Motivation

Code examples are one of the most valuable resources for developers. This tool helps AI assistants:

  • Provide working, tested code snippets
  • Show real-world usage patterns
  • Help users get started quickly
  • Demonstrate best practices from official examples

Proposed Implementation

Create a new tool: get_mapbox_example_tool

Input Schema:

  • topic (string, required) - Example topic: "3d-buildings", "custom-markers", "data-driven-styling", etc.
  • sdk (string, optional) - Target SDK: "mapbox-gl-js", "ios", "android", etc.
  • language (string, optional) - Programming language: "javascript", "swift", "kotlin", etc.

Output:

  • Working code example
  • Description of what it demonstrates
  • Link to live demo (if available)
  • Required dependencies
  • Setup instructions

Implementation approach:

  1. Create index of Mapbox examples from:
    • docs.mapbox.com examples
    • github.com/mapbox/mapbox-gl-js/examples
    • Other official example repositories
  2. Categorize by topic, SDK, use case
  3. Provide search/retrieval interface
  4. Include metadata for each example

Example usage:

{
  "topic": "custom-markers",
  "sdk": "mapbox-gl-js"
}

Returns:

{
  "title": "Add custom markers",
  "description": "Add custom marker images to a map",
  "code": "const map = new mapbox.Map({...});\nmap.loadImage('marker.png', (error, image) => {...});",
  "liveDemo": "https://docs.mapbox.com/mapbox-gl-js/example/custom-markers/",
  "dependencies": ["mapbox-gl"],
  "tags": ["markers", "images", "symbols"]
}

Acceptance Criteria

  • get_mapbox_example_tool implemented
  • Index of Mapbox examples created
  • Searchable by topic, SDK, language
  • Returns working code with context
  • Tests (unit and integration)
  • Updates CHANGELOG.md
  • Documentation in README.md

Example Sources

  1. https://docs.mapbox.com/mapbox-gl-js/example/
  2. https://docs.mapbox.com/ios/maps/examples/
  3. https://docs.mapbox.com/android/maps/examples/
  4. GitHub repositories (mapbox-gl-js, mapbox-gl-native, etc.)

Related

Part of enhanced documentation discovery initiative

Depends on: None (can be done in parallel)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions