Skip to main content
Glama
gregario

lorcana-oracle

Search Cards

search_cards

Search Disney Lorcana cards by name, rules text, or apply filters like ink color, type, rarity, set, and cost range. Paginated results are returned.

Instructions

Search Disney Lorcana cards by name, rules text, or filters (ink color, type, rarity, set, cost range). Returns paginated results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoSearch by card name or rules text
inkNoFilter by ink color (e.g. Amber, Amethyst, Emerald, Ruby, Sapphire, Steel)
typeNoFilter by card type (e.g. Character, Song, Item, Action, Location)
rarityNoFilter by rarity (e.g. Common, Uncommon, Rare, Super Rare, Legendary, Enchanted)
setNoFilter by set code
cost_minNoMinimum ink cost (inclusive)
cost_maxNoMaximum ink cost (inclusive)
limitNoMax results to return (default 20)
cursorNoOffset for pagination

Implementation Reference

  • src/server.ts:43-43 (registration)
    Registration of the search_cards tool via registerSearchCards() call in createServer()
    registerSearchCards(server, db);
  • Handler function registerSearchCards that registers the 'search_cards' tool with the MCP server, defines the Zod input schema, builds SearchFilters from args, calls the database searchCards function, and formats results
    export function registerSearchCards(server: McpServer, db: Database.Database): void {
      server.registerTool(
        'search_cards',
        {
          title: 'Search Cards',
          description:
            'Search Disney Lorcana cards by name, rules text, or filters (ink color, type, rarity, set, cost range). Returns paginated results.',
          inputSchema: {
            query: z.string().optional().describe('Search by card name or rules text'),
            ink: z.string().optional().describe('Filter by ink color (e.g. Amber, Amethyst, Emerald, Ruby, Sapphire, Steel)'),
            type: z.string().optional().describe('Filter by card type (e.g. Character, Song, Item, Action, Location)'),
            rarity: z.string().optional().describe('Filter by rarity (e.g. Common, Uncommon, Rare, Super Rare, Legendary, Enchanted)'),
            set: z.string().optional().describe('Filter by set code'),
            cost_min: z.number().optional().describe('Minimum ink cost (inclusive)'),
            cost_max: z.number().optional().describe('Maximum ink cost (inclusive)'),
            limit: z.number().optional().default(20).describe('Max results to return (default 20)'),
            cursor: z.number().optional().describe('Offset for pagination'),
          },
        },
        async (args) => {
          const filters: SearchFilters = {
            query: args.query,
            color: args.ink,
            type: args.type,
            rarity: args.rarity,
            setCode: args.set,
            costMin: args.cost_min,
            costMax: args.cost_max,
            limit: args.limit,
            offset: args.cursor,
          };
    
          const { rows, total } = searchCards(db, filters);
    
          if (rows.length === 0) {
            return {
              content: [{ type: 'text' as const, text: 'No cards found matching your search criteria.' }],
            };
          }
    
          const offset = args.cursor ?? 0;
          const parts = rows.map(formatCard);
          const footer: string[] = [];
          footer.push(`\n---\nShowing ${offset + 1}–${offset + rows.length} of ${total} results.`);
          if (offset + rows.length < total) {
            footer.push(`Use cursor: ${offset + rows.length} to see more.`);
          }
    
          return {
            content: [
              { type: 'text' as const, text: parts.join('\n\n') + footer.join(' ') },
            ],
          };
        },
      );
    }
  • formatCard helper function that formats a CardRow into a human-readable string for display
    function formatCard(card: CardRow): string {
      const lines: string[] = [];
      lines.push(`**${card.full_name ?? card.name}**`);
      lines.push(`  Ink: ${card.color} | Cost: ${card.cost ?? '—'} | Inkwell: ${card.inkwell ? 'Yes' : 'No'}`);
      lines.push(`  Type: ${card.type}${card.subtypes_text ? ` — ${card.subtypes_text}` : ''}`);
      if (card.type === 'Character') {
        lines.push(`  Strength: ${card.strength ?? '—'} | Willpower: ${card.willpower ?? '—'} | Lore: ${card.lore ?? '—'}`);
      }
      if (card.type === 'Location' && card.move_cost !== null) {
        lines.push(`  Lore: ${card.lore ?? '—'} | Move Cost: ${card.move_cost}`);
      }
      lines.push(`  Rarity: ${card.rarity ?? '—'} | Set: ${card.set_code ?? '—'}`);
      if (card.full_text) {
        lines.push(`  Text: ${card.full_text}`);
      }
      if (card.story) {
        lines.push(`  Franchise: ${card.story}`);
      }
      return lines.join('\n');
    }
  • SearchFilters interface defining all possible filter fields passed to the database search function
    export interface SearchFilters {
      query?: string;
      color?: string;
      type?: string;
      cost?: number;
      costOp?: 'eq' | 'lte' | 'gte';
      costMin?: number;
      costMax?: number;
      rarity?: string;
      setCode?: string;
      story?: string;
      inkwell?: boolean;
      hasKeyword?: string;
      limit?: number;
      offset?: number;
    }
  • Core database searchCards function that builds dynamic SQL queries with filters, FTS text search, and pagination
    export function searchCards(
      db: Database.Database,
      filters: SearchFilters,
    ): SearchResult {
      const conditions: string[] = [];
      const params: (string | number)[] = [];
    
      if (filters.query) {
        const ftsQuery = sanitizeFtsQuery(filters.query);
        if (ftsQuery.length > 0) {
          conditions.push(
            'c.id IN (SELECT rowid FROM cards_fts WHERE cards_fts MATCH ?)',
          );
          params.push(ftsQuery);
        }
      }
    
      if (filters.color) {
        conditions.push('LOWER(c.color) = LOWER(?)');
        params.push(filters.color);
      }
    
      if (filters.type) {
        conditions.push('LOWER(c.type) = LOWER(?)');
        params.push(filters.type);
      }
    
      if (filters.cost !== undefined) {
        const op = filters.costOp ?? 'eq';
        const sqlOp = op === 'lte' ? '<=' : op === 'gte' ? '>=' : '=';
        conditions.push(`c.cost ${sqlOp} ?`);
        params.push(filters.cost);
      }
    
      if (filters.costMin !== undefined) {
        conditions.push('c.cost >= ?');
        params.push(filters.costMin);
      }
    
      if (filters.costMax !== undefined) {
        conditions.push('c.cost <= ?');
        params.push(filters.costMax);
      }
    
      if (filters.rarity) {
        conditions.push('LOWER(c.rarity) = LOWER(?)');
        params.push(filters.rarity);
      }
    
      if (filters.setCode) {
        conditions.push('c.set_code = ?');
        params.push(filters.setCode);
      }
    
      if (filters.story) {
        conditions.push('LOWER(c.story) = LOWER(?)');
        params.push(filters.story);
      }
    
      if (filters.inkwell !== undefined) {
        conditions.push('c.inkwell = ?');
        params.push(filters.inkwell ? 1 : 0);
      }
    
      if (filters.hasKeyword) {
        conditions.push('c.keyword_abilities LIKE ?');
        params.push(`%${filters.hasKeyword}%`);
      }
    
      const where =
        conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : '';
      const limit = filters.limit ?? 20;
      const offset = filters.offset ?? 0;
    
      const countRow = db
        .prepare(`SELECT COUNT(*) as count FROM cards c ${where}`)
        .get(...params) as { count: number };
    
      const rows = db
        .prepare(
          `SELECT c.* FROM cards c ${where} ORDER BY c.cost ASC, c.name ASC LIMIT ? OFFSET ?`,
        )
        .all(...params, limit, offset) as CardRow[];
    
      return { rows, total: countRow.count };
    }
Behavior3/5

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

No annotations are provided, so the description must cover behavioral traits. It mentions pagination via 'Returns paginated results', but does not disclose read-only nature, error handling, or behavior when filters yield no results. The pagination hint is helpful but limited.

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

Conciseness4/5

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

The description is a single sentence that efficiently conveys the core functionality. It front-loads the verb and lists filters compactly. Minor improvement could be separating the pagination mention for clarity, but overall concise.

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?

Given no output schema, the description covers essential aspects: input types (name, rules text, filters) and pagination. It does not specify optionality of parameters or default limit, but for a search tool with extensive schema, it is reasonably complete.

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?

Schema coverage is 100% with clear parameter descriptions. The description adds little beyond summarizing filter options; it does not clarify parameter interactions (e.g., how query works with filters) or provide examples. Baseline 3 is appropriate.

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?

The description clearly states the tool's purpose: searching Disney Lorcana cards by name, rules text, or multiple filters. It distinguishes itself from sibling analysis tools like analyze_ink_curve and browse_sets, which have different focuses.

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

Usage Guidelines3/5

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

The description implies usage for finding cards via various criteria, but lacks explicit guidance on when to use this tool versus alternatives, such as analyze_ink_curve for ink cost distribution or find_song_synergies for synergies. No when-not-to-use or alternative references are provided.

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