browse_themes
Explore LEGO theme hierarchy to discover available themes or drill into specific ones, returning sub-themes and set counts for navigation.
Instructions
Browse the LEGO theme hierarchy. With no input, returns all top-level themes with set counts. With a theme name, returns its sub-themes and sets. Use this to explore what LEGO themes exist or drill into a specific theme.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| theme | No | Theme name or numeric ID. Omit to list all top-level themes with set counts. |
Implementation Reference
- src/tools/browse-themes.ts:32-37 (handler)The main handler function that determines whether to browse top-level themes or a specific theme based on provided parameters.
export function handler(db: Database.Database, params: BrowseThemesParams): BrowseThemesResult { if (!params.theme) { return browseTopLevel(db); } return browseTheme(db, params.theme); } - src/tools/browse-themes.ts:6-10 (schema)Zod schema defining the input parameters for the browse_themes tool.
export const BrowseThemesInput = z.object({ theme: z.string().optional().describe( 'Theme name or numeric ID. Omit to list all top-level themes with set counts.' ), }); - src/server.ts:178-183 (registration)Registration and invocation logic for the 'browse_themes' tool within the server.
'browse_themes', 'Browse the LEGO theme hierarchy. With no input, returns all top-level themes with set counts. With a theme name, returns its sub-themes and sets. Use this to explore what LEGO themes exist or drill into a specific theme.', BrowseThemesInput.shape, async (params) => { try { const result = browseThemesHandler(db, params); - src/tools/browse-themes.ts:180-212 (helper)Helper function to format the browse_themes result into a human-readable markdown string.
export function formatBrowseThemes(result: BrowseThemesResult): string { if (result.theme_name === null && result.themes.length === 0) { return 'No themes found.'; } const lines: string[] = []; if (result.theme_name === null) { // Top-level listing lines.push(`# LEGO Themes (${result.themes.length} top-level themes, ${result.total_set_count} total sets)\n`); for (const t of result.themes) { const sub = t.sub_theme_count > 0 ? ` (${t.sub_theme_count} sub-themes)` : ''; lines.push(`- **${t.name}** (ID: ${t.id}): ${t.set_count} sets${sub}`); } } else { // Specific theme lines.push(`# ${result.theme_name}\n`); lines.push(`Total sets (including sub-themes): ${result.total_set_count}`); lines.push(`Direct sets: ${result.direct_set_count}\n`); if (result.themes.length > 0) { lines.push(`## Sub-themes (${result.themes.length})\n`); for (const t of result.themes) { const sub = t.sub_theme_count > 0 ? ` (${t.sub_theme_count} sub-themes)` : ''; lines.push(`- **${t.name}** (ID: ${t.id}): ${t.set_count} sets${sub}`); } } else { lines.push('No sub-themes.'); } } return lines.join('\n'); }