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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Keyword name to look up (case-insensitive). Examples: "Flying", "Equip", "Scry". |
Implementation Reference
- src/tools/get-keyword.ts:33-68 (handler)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, }; } - src/tools/get-keyword.ts:7-9 (schema)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".'), });