Skip to main content
Glama
gregario

lego-oracle

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
NameRequiredDescriptionDefault
themeNoTheme name or numeric ID. Omit to list all top-level themes with set counts.

Implementation Reference

  • 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);
    }
  • 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);
  • 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');
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gregario/lego-oracle'

If you have feedback or need assistance with the MCP directory API, please join our Discord server