Skip to content

Conversation

@jussi-sa
Copy link
Contributor

@jussi-sa jussi-sa commented Sep 12, 2025

Description

This PR introduces a StyleBuilderTool that enables LLMs to generate complex Mapbox styles through natural language prompts. It replaces the deprecated style-helper-tool with a more comprehensive solution that supports Mapbox GL expressions, advanced filtering, and all Streets v8 layer properties.

Key Features Added

🎨 New StyleBuilderTool

  • Full expression support: Zoom-based interpolation, data-driven styling, and custom Mapbox GL expressions
  • Comprehensive filtering: Complete Streets v8 property-based filtering for all source layers
  • All layer types supported: water, roads, buildings, boundaries, transit, POIs, landcover, etc.
  • Multiple actions: show, hide, color, highlight with configurable opacity and width
  • Dark/light mode support: Automatic style adjustments for different themes

📚 New Resource System

  • BaseResource class: Foundation for MCP resources
  • MapboxStyleLayersResource: Comprehensive documentation of all Mapbox layer types, properties, and filters
  • Resource registry: Automatic resource registration and discovery

🗺️ Enhanced Type Definitions

  • Complete Mapbox Style types: Full TypeScript definitions for Mapbox GL Style Spec v8
  • Streets v8 field definitions: All filterable properties for each source layer (road, admin, poi_label, transit_stop_label, etc.)
  • Expression types: Comprehensive typing for all Mapbox expression functions

Breaking Changes

  • ❌ Removed deprecated style-helper-tool in favor of StyleBuilderTool
  • ❌ Removed unused mapboxTilesets.ts constants file

Technical Improvements

  • ✅ Replaced any types with proper union types for better type safety
  • ✅ Fixed boolean value parsing in filter expressions (now correctly uses true/false
    instead of string literals)
  • ✅ Added comprehensive test coverage (23 tests for StyleBuilderTool)
  • ✅ All tests passing (203 total)

Example Usage

The new tool enables prompts like:

  • "Create a style with only motorway bridges colored gold"
  • "Create a style with roads that get wider at higher zoom levels"
  • "Create a style with bus stops in red and subway entrances in blue"
  • "Create a style with country boundaries excluding maritime ones"

Filter Capabilities

  • Property-based: Filter by class, structure, type, admin_level, maki icons, etc.
  • Multi-value: Support for arrays like class: ['motorway', 'trunk']
  • Boolean properties: Handle oneway, toll, disputed, maritime flags
  • Transit filtering: Filter by maki icons (bus, entrance, rail-metro)

Testing


Checklist

  • Code has been tested locally
  • Unit tests have been added or updated
  • Documentation has been updated if needed

Additional Notes

@jussi-sa jussi-sa requested a review from a team as a code owner September 12, 2025 17:03
Copy link
Member

@zmofei zmofei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

* This provides all available properties for filtering
*/

export const STREETS_V8_FIELDS = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative way to get updated tileset source is through this tileset metadata api https://docs.mapbox.com/api/maps/mapbox-tiling-service/#retrieve-tilejson-metadata, e.g.
https://api.mapbox.com/v4/mapbox.mapbox-streets-v8.json?secure&access_token=<>

image

But since streets tileset is relevant stable, this approach also works

@jussi-sa jussi-sa merged commit 08c16a0 into main Sep 15, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants