Skip to main content
Glama

get_keyword

Retrieve official rules definitions for Magic: The Gathering keyword abilities like Flying or Deathtouch to clarify gameplay mechanics.

Instructions

Get the official rules definition for a Magic keyword ability (e.g., "Flying", "Deathtouch", "Equip"). Use this when a user asks how a keyword works or what its rules text says. Different from get_glossary — this is specifically for keyword abilities with rules text.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesKeyword name to look up (case-insensitive). Examples: "Flying", "Equip", "Scry".

Implementation Reference

  • The main handler function for the get_keyword tool, which queries the database for keyword definitions with exact match, fuzzy match, and suggestion logic.
    export function handler(db: Database.Database, params: GetKeywordParams): GetKeywordResult {
      // 1. Exact match (case-insensitive)
      const exact = db.prepare(
        'SELECT * FROM keywords WHERE LOWER(name) = LOWER(?)'
      ).get(params.name) as KeywordRow | undefined;
    
      if (exact) {
        return {
          found: true,
          keyword: toEntry(exact),
        };
      }
    
      // 2. Fuzzy fallback via LIKE
      const fuzzy = db.prepare(
        'SELECT * FROM keywords WHERE LOWER(name) LIKE LOWER(?)'
      ).get(`%${params.name}%`) as KeywordRow | undefined;
    
      if (fuzzy) {
        return {
          found: true,
          keyword: toEntry(fuzzy),
        };
      }
    
      // 3. Suggestions based on first word
      const suggestions = db.prepare(
        'SELECT name FROM keywords WHERE LOWER(name) LIKE LOWER(?) LIMIT 5'
      ).all(`%${params.name.split(' ')[0]}%`) as Array<{ name: string }>;
    
      return {
        found: false,
        message: `No keyword found matching "${params.name}"`,
        suggestions: suggestions.length > 0 ? suggestions.map(s => s.name) : undefined,
      };
    }
  • Input validation schema for the get_keyword tool.
    export const GetKeywordInput = z.object({
      name: z.string().describe('Keyword name to look up (case-insensitive). Examples: "Flying", "Equip", "Scry".'),
    });

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

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