Skip to main content
Glama
gregario

lorcana-oracle

Analyze Lore

analyze_lore

Analyze a deck list for lore potential or discover top lore-generating cards with optional filters.

Instructions

Analyze lore generation in a deck list, or find the top lore-generating cards. In deck mode, shows total lore potential and efficiency ranking. In query mode, shows top lore generators with optional filters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deck_listNoDeck list text to analyze for lore potential
inkNoFilter by ink color
cost_minNoMinimum ink cost filter
cost_maxNoMaximum ink cost filter
limitNoMax results (default 20)

Implementation Reference

  • The `registerAnalyzeLore` function that registers the 'analyze_lore' MCP tool. Contains the handler logic: in deck mode, it parses the deck list, resolves cards, computes total lore potential and efficiency ranking; in query mode, it fetches top lore generators with optional filters (ink color, cost range, limit).
    export function registerAnalyzeLore(server: McpServer, db: Database.Database): void {
      server.registerTool(
        'analyze_lore',
        {
          title: 'Analyze Lore',
          description:
            'Analyze lore generation in a deck list, or find the top lore-generating cards. In deck mode, shows total lore potential and efficiency ranking. In query mode, shows top lore generators with optional filters.',
          inputSchema: {
            deck_list: z.string().optional().describe('Deck list text to analyze for lore potential'),
            ink: z.string().optional().describe('Filter by ink color'),
            cost_min: z.number().optional().describe('Minimum ink cost filter'),
            cost_max: z.number().optional().describe('Maximum ink cost filter'),
            limit: z.number().optional().default(20).describe('Max results (default 20)'),
          },
        },
        async (args) => {
          // Deck mode
          if (args.deck_list) {
            const entries = parseDeckList(args.deck_list);
            if (entries.length === 0) {
              return {
                content: [{ type: 'text' as const, text: 'Error: Could not parse any cards from the deck list.' }],
                isError: true,
              };
            }
    
            const result = resolveDeck(db, entries);
            if (result.entries.length === 0) {
              return {
                content: [{ type: 'text' as const, text: 'Error: No recognized cards found.' }],
                isError: true,
              };
            }
    
            // Filter to cards with lore (characters and locations)
            const loreEntries = result.entries.filter((e) => e.card.lore !== null && e.card.lore > 0);
            const nonLoreEntries = result.entries.filter((e) => e.card.lore === null || e.card.lore === 0);
    
            let totalLore = 0;
            let totalLoreCards = 0;
            for (const entry of loreEntries) {
              totalLore += (entry.card.lore ?? 0) * entry.quantity;
              totalLoreCards += entry.quantity;
            }
    
            const avgLore = totalLoreCards > 0 ? (totalLore / totalLoreCards).toFixed(2) : '0';
    
            // Sort by efficiency
            const sorted = [...loreEntries].sort((a, b) => loreEfficiency(b.card) - loreEfficiency(a.card));
    
            const lines: string[] = [];
            lines.push('## Deck Lore Analysis\n');
            lines.push(`**Total Lore Potential:** ${totalLore} (across ${totalLoreCards} lore-generating cards)`);
            lines.push(`**Average Lore per Card:** ${avgLore}\n`);
            lines.push('### Lore Generators (by efficiency)');
            for (const entry of sorted) {
              lines.push(`  ${formatLoreCard(entry.card, entry.quantity)}`);
            }
    
            if (nonLoreEntries.length > 0) {
              const nonLoreCount = nonLoreEntries.reduce((sum, e) => sum + e.quantity, 0);
              lines.push(`\n*${nonLoreCount} non-lore cards excluded (Songs, Items, Actions without lore value).*`);
            }
    
            if (result.unrecognized.length > 0) {
              lines.push('\n### Unrecognized Cards');
              for (const name of result.unrecognized) {
                lines.push(`  - ${name}`);
              }
            }
    
            return {
              content: [{ type: 'text' as const, text: lines.join('\n') }],
            };
          }
    
          // Query mode — find top lore generators
          // Use searchCards with filters if color/cost provided, otherwise getTopLoreGenerators
          let cards: CardRow[];
    
          if (args.ink || args.cost_min !== undefined || args.cost_max !== undefined) {
            // Use searchCards with filters
            const { rows } = searchCards(db, {
              color: args.ink,
              cost: args.cost_min,
              costOp: args.cost_min !== undefined ? 'gte' : undefined,
              limit: 200, // Get more to filter and sort
            });
    
            cards = rows
              .filter((c) => c.lore !== null && c.lore > 0)
              .filter((c) => args.cost_max === undefined || (c.cost !== null && c.cost <= args.cost_max));
    
            // Sort by lore desc, then efficiency
            cards.sort((a, b) => {
              const loreDiff = (b.lore ?? 0) - (a.lore ?? 0);
              if (loreDiff !== 0) return loreDiff;
              return loreEfficiency(b) - loreEfficiency(a);
            });
    
            cards = cards.slice(0, args.limit);
          } else {
            cards = getTopLoreGenerators(db, args.limit);
          }
    
          if (cards.length === 0) {
            return {
              content: [{ type: 'text' as const, text: 'No lore-generating cards found matching your filters.' }],
            };
          }
    
          const lines: string[] = [];
          lines.push('## Top Lore Generators\n');
          for (const card of cards) {
            lines.push(formatLoreCard(card));
          }
    
          return {
            content: [{ type: 'text' as const, text: lines.join('\n') }],
          };
        },
      );
    }
  • Input schema for 'analyze_lore': deck_list (optional string), ink (optional string), cost_min (optional number), cost_max (optional number), limit (optional number, default 20).
    {
      title: 'Analyze Lore',
      description:
        'Analyze lore generation in a deck list, or find the top lore-generating cards. In deck mode, shows total lore potential and efficiency ranking. In query mode, shows top lore generators with optional filters.',
      inputSchema: {
        deck_list: z.string().optional().describe('Deck list text to analyze for lore potential'),
        ink: z.string().optional().describe('Filter by ink color'),
        cost_min: z.number().optional().describe('Minimum ink cost filter'),
        cost_max: z.number().optional().describe('Maximum ink cost filter'),
        limit: z.number().optional().default(20).describe('Max results (default 20)'),
      },
    },
  • src/server.ts:48-49 (registration)
    Registration of `registerAnalyzeLore` in the MCP server setup, called within `createServer()` to wire the tool.
    registerAnalyzeLore(server, db);
    registerFindSongSynergies(server, db);
  • Helper function `loreEfficiency` that computes lore/cost ratio for a card (returns 0 if no lore or cost is 0/null).
    function loreEfficiency(card: CardRow): number {
      if (!card.lore || !card.cost || card.cost === 0) return 0;
      return card.lore / card.cost;
    }
  • Helper function `formatLoreCard` that formats a card with its quantity, name, lore value, cost, efficiency, and color for display.
    function formatLoreCard(card: CardRow, quantity?: number): string {
      const qtyStr = quantity !== undefined ? `${quantity}x ` : '';
      const efficiency = loreEfficiency(card).toFixed(2);
      return `${qtyStr}**${card.full_name ?? card.name}** — Lore: ${card.lore ?? 0} | Cost: ${card.cost ?? '—'} | Efficiency: ${efficiency} lore/cost | ${card.color}`;
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry full weight. It explains the analysis behavior (showing lore potential, ranking, filtering) but does not disclose read-only nature, rate limits, or side effects. Adequate but not comprehensive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences efficiently cover purpose, modes, and filtering. No redundant or extraneous text; front-loaded with the main function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description explains output in each mode (total lore potential, ranking, top generators). For a tool with 5 parameters, this is sufficient but could mention pagination or result format.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 100% description coverage, so baseline is 3. The description mentions optional filters but does not add any meaning beyond what the schema already provides for parameters like ink, cost_min, cost_max, limit.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the tool analyzes lore generation in deck lists and finds top lore-generating cards, with two distinct modes (deck and query). This is specific and differentiates from siblings like analyze_ink_curve or browse_franchise.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains when to use each mode (deck vs query), providing clear context. However, it does not explicitly state when not to use this tool or mention alternatives, leaving some ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/lorcana-oracle'

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