get_glossary
Look up Magic: The Gathering game terminology definitions to understand terms like 'permanent', 'spell', or 'stack' during gameplay.
Instructions
Look up a term in the Magic: The Gathering glossary. Use this when a user asks "what does X mean" for game-specific terminology like "permanent", "spell", "stack", "priority", etc. Supports partial matching.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| term | Yes | Glossary term to look up (case-insensitive). Supports exact and partial matching. |
Implementation Reference
- src/tools/get-glossary.ts:30-59 (handler)The core handler function that executes the database query to retrieve glossary entries.
export function handler(db: Database.Database, params: GetGlossaryParams): GetGlossaryResult { // 1. Exact match (case-insensitive) const exact = db.prepare( 'SELECT * FROM glossary WHERE LOWER(term) = LOWER(?)' ).get(params.term) as GlossaryRow | undefined; if (exact) { return { found: true, entries: [{ term: exact.term, definition: exact.definition }], }; } // 2. Partial match (case-insensitive) const partials = db.prepare( 'SELECT * FROM glossary WHERE LOWER(term) LIKE LOWER(?) ORDER BY term LIMIT 20' ).all(`%${params.term}%`) as GlossaryRow[]; if (partials.length > 0) { return { found: true, entries: partials.map(row => ({ term: row.term, definition: row.definition })), }; } return { found: false, message: `No glossary entry found for "${params.term}"`, }; } - src/tools/get-glossary.ts:7-9 (schema)Input validation schema for the get_glossary tool.
export const GetGlossaryInput = z.object({ term: z.string().describe('Glossary term to look up (case-insensitive). Supports exact and partial matching.'), }); - src/server.ts:176-188 (registration)Tool registration in the MCP server.
server.tool( 'get_glossary', 'Look up a term in the Magic: The Gathering glossary. Use this when a user asks "what does X mean" for game-specific terminology like "permanent", "spell", "stack", "priority", etc. Supports partial matching.', GetGlossaryInput.shape, async (params) => { try { const result = getGlossaryHandler(db, params); return { content: [{ type: 'text' as const, text: formatGetGlossary(result) }] }; } catch (err) { return { content: [{ type: 'text' as const, text: `Error getting glossary entry: ${err instanceof Error ? err.message : String(err)}` }], isError: true }; } }, );