Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,734 changes: 2,508 additions & 226 deletions src/constants/mapboxStreetsV8Fields.ts

Large diffs are not rendered by default.

784 changes: 0 additions & 784 deletions src/constants/mapboxStyleLayers.ts

This file was deleted.

565 changes: 290 additions & 275 deletions src/resources/mapbox-style-layers-resource/MapboxStyleLayersResource.ts

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/tools/create-style-tool/CreateStyleTool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { fetchClient } from '../../utils/fetchRequest.js';
import { filterExpandedMapboxStyles } from '../../utils/styleUtils.js';
import { MapboxApiBasedTool } from '../MapboxApiBasedTool.js';
import {
CreateStyleSchema,
Expand All @@ -18,7 +19,7 @@ export class CreateStyleTool extends MapboxApiBasedTool<
protected async execute(
input: CreateStyleInput,
accessToken?: string
): Promise<any> {
): Promise<unknown> {
const username = MapboxApiBasedTool.getUserNameFromToken(accessToken);
const url = `${MapboxApiBasedTool.mapboxApiEndpoint}styles/v1/${username}?access_token=${accessToken}`;

Expand All @@ -42,6 +43,7 @@ export class CreateStyleTool extends MapboxApiBasedTool<
}

const data = await response.json();
return data;
// Return full style but filter out expanded Mapbox styles
return filterExpandedMapboxStyles(data);
}
}
4 changes: 3 additions & 1 deletion src/tools/retrieve-style-tool/RetrieveStyleTool.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { filterExpandedMapboxStyles } from '../../utils/styleUtils.js';
import { MapboxApiBasedTool } from '../MapboxApiBasedTool.js';
import {
RetrieveStyleSchema,
Expand All @@ -17,7 +18,7 @@
protected async execute(
input: RetrieveStyleInput,
accessToken?: string
): Promise<any> {

Check warning on line 21 in src/tools/retrieve-style-tool/RetrieveStyleTool.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
const username = MapboxApiBasedTool.getUserNameFromToken(accessToken);
const url = `${MapboxApiBasedTool.mapboxApiEndpoint}styles/v1/${username}/${input.styleId}?access_token=${accessToken}`;

Expand All @@ -30,6 +31,7 @@
}

const data = await response.json();
return data;
// Always filter out expanded Mapbox styles to prevent token overflow
return filterExpandedMapboxStyles(data);
}
}
236 changes: 230 additions & 6 deletions src/tools/style-builder-tool/StyleBuilderTool.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,31 @@ const LayerConfigSchema = z.object({
.describe(
'Layer type from the resource (e.g., "water", "railways", "parks")'
),

render_type: z
.enum([
'fill',
'line',
'symbol',
'circle',
'fill-extrusion',
'heatmap',
'auto'
])
.optional()
.default('auto')
.describe(
'How to render this layer visually. Default "auto" chooses based on geometry type.\n' +
'Override to achieve specific visual effects:\n' +
'• "line" - For outlines, borders, strokes (e.g., building outlines, road borders)\n' +
'• "fill" - For solid filled areas (e.g., solid color buildings, water bodies)\n' +
'• "fill-extrusion" - For 3D extrusions (e.g., 3D buildings)\n' +
'• "symbol" - For text labels or icons\n' +
'• "circle" - For dot visualization (e.g., POI dots, data points)\n' +
'• "heatmap" - For density maps (points only)\n' +
'IMPORTANT: Use "line" for outlines even on polygon features like buildings.'
),

action: z
.enum(['show', 'hide', 'color', 'highlight'])
.describe('What to do with this layer'),
Expand All @@ -14,7 +39,10 @@ const LayerConfigSchema = z.object({
.optional()
.describe('Color value if action is "color" or "highlight"'),
opacity: z.number().min(0).max(1).optional().describe('Opacity value'),
width: z.number().optional().describe('Width for line layers'),
width: z
.number()
.optional()
.describe('Width for line layers or outline thickness'),
filter: z
.union([
z.string(),
Expand Down Expand Up @@ -81,16 +109,39 @@ const LayerConfigSchema = z.object({
z.record(z.unknown())
])
.optional()
.describe('Custom Mapbox expression for advanced styling')
.describe('Custom Mapbox expression for advanced styling'),

// Slot for Standard styles
slot: z
.enum(['bottom', 'middle', 'top'])
.optional()
.describe(
'Layer slot for Mapbox Standard styles. Controls layer stacking order. ' +
'Bottom: below most map features, Middle: between base and labels, Top: above all base map features (default)'
Copy link
Member

Choose a reason for hiding this comment

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

)
});

export const StyleBuilderToolSchema = z.object({
style_name: z.string().default('Custom Style').describe('Name for the style'),

base_style: z
.enum(['streets', 'light', 'dark', 'satellite', 'outdoors', 'blank'])
.default('streets')
.describe('Base style template to start from'),
.enum([
'standard',
'streets-v12',
'light-v11',
'dark-v11',
'satellite-v9',
'satellite-streets-v12',
'outdoors-v12',
'navigation-day-v1',
'navigation-night-v1'
])
.default('standard')
.describe(
'Base style template. ALWAYS use "standard" as the default for all new styles. ' +
'Standard style provides the best performance and modern features. ' +
'Only use Classic styles (streets/light/dark/satellite/outdoors/navigation) when explicitly requested with "create a classic style" or when working with an existing Classic style.'
),

layers: z
.array(LayerConfigSchema)
Expand All @@ -103,7 +154,180 @@ export const StyleBuilderToolSchema = z.object({
mode: z.enum(['light', 'dark']).optional().describe('Light or dark mode')
})
.optional()
.describe('Global style settings')
.describe('Global style settings'),

standard_config: z
.object({
// Boolean configuration properties
showPedestrianRoads: z
.boolean()
.optional()
.describe(
'Show/hide the base pedestrian roads and paths from the Standard style'
),
showPlaceLabels: z
.boolean()
.optional()
.describe(
'Show/hide the base place label layers from the Standard style'
),
showPointOfInterestLabels: z
.boolean()
.optional()
.describe(
'Show/hide the base POI icons and text from the Standard style'
),
showRoadLabels: z
.boolean()
.optional()
.describe(
'Show/hide the base road labels and shields from the Standard style'
),
showTransitLabels: z
.boolean()
.optional()
.describe(
'Show/hide the base transit icons and text from the Standard style'
),
show3dObjects: z
.boolean()
.optional()
.describe(
'Show/hide the base 3D objects like buildings and landmarks from the Standard style'
),
showLandmarkIcons: z
.boolean()
.optional()
.describe('Show/hide the base landmark icons from the Standard style'),
showLandmarkIconLabels: z
.boolean()
.optional()
.describe(
'Show/hide the base landmark icon labels from the Standard style'
),
showAdminBoundaries: z
.boolean()
.optional()
.describe(
'Show/hide the base administrative boundaries from the Standard style'
),
showRoadsAndTransit: z
.boolean()
.optional()
.describe(
'Show/hide the base roads and transit networks from the Standard style (Standard-Satellite)'
),

// String configuration properties
theme: z
.enum(['default', 'faded', 'monochrome', 'custom'])
.optional()
.describe('Theme for the base Standard style layers'),
'theme-data': z
.string()
.optional()
.describe('Custom color theme for the base style via Base64 LUT image'),
lightPreset: z
.enum(['dusk', 'dawn', 'day', 'night'])
.optional()
.describe('Time-of-day lighting for the base Standard style'),
font: z
.string()
.optional()
.describe('Font family for the base Standard style text'),
colorModePointOfInterestLabels: z
.string()
.optional()
.describe('Color mode for the base POI labels'),
backgroundPointOfInterestLabels: z
.string()
.optional()
.describe('Background style for the base POI labels'),

// Numeric configuration properties
densityPointOfInterestLabels: z
.number()
.min(1)
.max(5)
.optional()
.describe('Density of base POI labels (1-5, default 3)'),

// Color override properties
colorPlaceLabels: z
.string()
.optional()
.describe('Override color for the base place labels in Standard style'),
colorRoadLabels: z
.string()
.optional()
.describe('Override color for the base road labels in Standard style'),
colorGreenspace: z
.string()
.optional()
.describe(
'Override color for the base greenspace areas in Standard style'
),
colorWater: z
.string()
.optional()
.describe(
'Override color for the base water features in Standard style'
),
colorAdminBoundaries: z
.string()
.optional()
.describe(
'Override color for the base administrative boundaries in Standard style'
),
colorPointOfInterestLabels: z
.string()
.optional()
.describe('Override color for the base POI labels in Standard style'),
colorMotorways: z
.string()
.optional()
.describe(
'Override color for the base motorways/highways in Standard style'
),
colorTrunks: z
.string()
.optional()
.describe('Override color for the base trunk roads in Standard style'),
colorRoads: z
.string()
.optional()
.describe(
'Override color for the base regular roads in Standard style'
),
colorBuildingHighlight: z
.string()
.optional()
.describe(
'Override color for the base highlighted buildings in Standard style'
),
colorBuildingSelect: z
.string()
.optional()
.describe(
'Override color for the base selected buildings in Standard style'
),
colorPlaceLabelHighlight: z
.string()
.optional()
.describe(
'Override color for the base highlighted place labels in Standard style'
),
colorPlaceLabelSelect: z
.string()
.optional()
.describe(
'Override color for the base selected place labels in Standard style'
)
})
.optional()
.describe(
'Configuration for the base Mapbox Standard style. These properties customize the underlying Standard style features - you can still add your own custom layers on top using the layers parameter. The Standard style provides a rich basemap that you can configure and enhance with additional layers.'
)
});

export type StyleBuilderToolInput = z.infer<typeof StyleBuilderToolSchema>;
Loading
Loading