Skip to main content
Glama

get_card

Retrieve complete details for any Hearthstone card by name, including stats, text, keywords, and type. Supports partial name matching.

Instructions

Get complete details for a specific Hearthstone card including stats, text, keywords, and type. Use this when you know the card name (or close to it) and need full information. Supports fuzzy matching.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesCard name to look up (exact or partial match)

Implementation Reference

  • The main handler function that executes the 'get_card' tool logic. It first tries an exact case-insensitive match on the card name, then a fuzzy (LIKE) match, and finally returns suggestions based on the first word if no match is found.
    export function getCard(
      db: Database.Database,
      input: GetCardInputType,
    ): GetCardResult {
      // 1. Exact match (case-insensitive)
      const exact = db
        .prepare('SELECT * FROM cards WHERE LOWER(name) = LOWER(?)')
        .get(input.name) as CardRow | undefined;
    
      if (exact) {
        return { found: true, card: toCardDetail(exact) };
      }
    
      // 2. Fuzzy match via LIKE
      const fuzzy = db
        .prepare('SELECT * FROM cards WHERE LOWER(name) LIKE LOWER(?)')
        .get(`%${input.name}%`) as CardRow | undefined;
    
      if (fuzzy) {
        return { found: true, card: toCardDetail(fuzzy) };
      }
    
      // 3. Not found — provide suggestions based on first word
      const firstWord = input.name.split(/\s+/)[0];
      const suggestions = db
        .prepare('SELECT name FROM cards WHERE LOWER(name) LIKE LOWER(?) LIMIT 5')
        .all(`%${firstWord}%`) as Array<{ name: string }>;
    
      const suggestionNames = suggestions.map((s) => s.name);
    
      return {
        found: false,
        message: `No card found matching "${input.name}".`,
        suggestions: suggestionNames.length > 0 ? suggestionNames : undefined,
      };
    }
  • Zod input schema for the 'get_card' tool. Requires a single 'name' field (string) for the card name to look up.
    export const GetCardInput = z.object({
      name: z.string().describe('Card name to look up (exact or partial match)'),
    });
    
    export type GetCardInputType = z.infer<typeof GetCardInput>;
  • Type definition for the 'get_card' tool result. A discriminated union: either {found: true, card: CardDetail} or {found: false, message: string, suggestions?: string[]}.
    export type GetCardResult =
      | { found: true; card: CardDetail }
      | { found: false; message: string; suggestions?: string[] };
  • src/server.ts:83-108 (registration)
    Registration of the 'get_card' tool on the MCP server. Uses server.tool() with the name 'get_card', description, GetCardInput.shape schema, and an async handler that calls getCard() and formats the result.
    // 2. get_card
    server.tool(
      'get_card',
      'Get complete details for a specific Hearthstone card including stats, text, keywords, and type. Use this when you know the card name (or close to it) and need full information. Supports fuzzy matching.',
      GetCardInput.shape,
      async (params) => {
        try {
          const result = getCard(db, params);
          return {
            content: [
              { type: 'text' as const, text: formatGetCard(result) },
            ],
          };
        } catch (err) {
          return {
            content: [
              {
                type: 'text' as const,
                text: `Error: ${err instanceof Error ? err.message : String(err)}`,
              },
            ],
            isError: true,
          };
        }
      },
    );
  • Formats the 'get_card' result into a human-readable string. Handles both found (displaying full card details including stats, keywords, flavor text) and not-found cases (with suggestions).
    export function formatGetCard(result: GetCardResult): string {
      if (!result.found) {
        let msg = result.message;
        if (result.suggestions && result.suggestions.length > 0) {
          msg += '\n\nDid you mean:\n';
          msg += result.suggestions.map(s => `- ${s}`).join('\n');
        }
        return msg;
      }
    
      const card = result.card;
      const lines: string[] = [];
    
      // Header
      lines.push(`# ${card.name} {${card.mana_cost ?? '?'} mana}`);
    
      // Type line
      const typeParts: string[] = [];
      if (card.rarity) typeParts.push(card.rarity);
      if (card.type) typeParts.push(card.type);
      if (card.race) typeParts.push(`(${card.race})`);
      if (card.player_class) typeParts.push(`[${card.player_class}]`);
      lines.push(typeParts.join(' '));
    
      // Set
      if (card.card_set || card.set_name) {
        lines.push(`Set: ${card.set_name ?? card.card_set}`);
      }
    
      // Text
      if (card.text) {
        lines.push('');
        lines.push(card.text);
      }
    
      // Stats
      if (card.type === 'MINION' && card.attack != null && card.health != null) {
        lines.push('');
        lines.push(`${card.attack}/${card.health}`);
      } else if (card.type === 'WEAPON' && card.attack != null && card.durability != null) {
        lines.push('');
        lines.push(`${card.attack}/${card.durability}`);
      } else if (card.type === 'HERO' && card.armor != null) {
        lines.push('');
        lines.push(`Armor: ${card.armor}`);
      }
    
      // Keywords
      if (card.keywords.length > 0) {
        lines.push(`Keywords: ${card.keywords.join(', ')}`);
      }
    
      // Spell school
      if (card.spell_school) {
        lines.push(`Spell School: ${card.spell_school}`);
      }
    
      // Flavor
      if (card.flavor) {
        lines.push('');
        lines.push(`*${card.flavor}*`);
      }
    
      return lines.join('\n');
    }
Behavior3/5

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

No annotations provided, so description must convey behavioral traits. It mentions fuzzy matching but does not disclose behavior on missing cards, multiple matches, or any side effects. Returns are described as 'complete details' but lacks specificity on structure.

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?

Two sentences, no redundant information. Action and resource are front-loaded. Every part adds value without fluff.

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 single parameter, no output schema, and no annotations, the description provides sufficient context for a basic lookup tool. It could be improved by noting error handling or behavior for non-existent cards, but it is adequate.

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

Parameters4/5

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

Schema covers 100% with one parameter 'name' described as 'exact or partial match'. Description adds 'supports fuzzy matching' which clarifies schema's 'partial match' and provides extra context beyond schema.

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 'Get complete details for a specific Hearthstone card' and lists included fields (stats, text, keywords, type). Distinguishes from sibling 'search_cards' by specifying use when card name is known.

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

Usage Guidelines5/5

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

Explicitly states when to use: 'when you know the card name (or close to it) and need full information.' Mentions fuzzy matching, implying tolerance for partial names, and contrasts with search-based alternatives.

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

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