get_rulings
Retrieve official Magic: The Gathering card rulings to clarify interactions, edge cases, and unusual situations with timestamped Wizards of the Coast guidance.
Instructions
Get official rulings for a specific Magic card. Use this when a user asks about specific interactions, edge cases, or how a card works in unusual situations. Returns timestamped rulings from Wizards of the Coast.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| card_name | Yes | Name of the card to get rulings for |
Implementation Reference
- src/tools/get-rulings.ts:32-64 (handler)The implementation of the get_rulings tool handler, which queries the database for cards and their associated rulings.
export function handler(db: Database.Database, params: GetRulingsParams): GetRulingsResult { // Look up card by name (case-insensitive exact match first, then LIKE) let card = db.prepare( 'SELECT * FROM cards WHERE LOWER(name) = LOWER(?)' ).get(params.card_name) as CardRow | undefined; if (!card) { card = db.prepare( 'SELECT * FROM cards WHERE LOWER(name) LIKE LOWER(?)' ).get(`%${params.card_name}%`) as CardRow | undefined; } if (!card) { return { found: false, message: `No card found matching "${params.card_name}"`, }; } const rows = db.prepare( 'SELECT * FROM rulings WHERE card_id = ? ORDER BY published_at' ).all(card.id) as RulingRow[]; return { found: true, card_name: card.name, rulings: rows.map(r => ({ source: r.source, published_at: r.published_at, comment: r.comment, })), }; } - src/tools/get-rulings.ts:7-9 (schema)Input schema for the get_rulings tool.
export const GetRulingsInput = z.object({ card_name: z.string().describe('Name of the card to get rulings for'), }); - src/server.ts:118-126 (registration)Registration of the get_rulings tool in the MCP server.
server.tool( 'get_rulings', 'Get official rulings for a specific Magic card. Use this when a user asks about specific interactions, edge cases, or how a card works in unusual situations. Returns timestamped rulings from Wizards of the Coast.', GetRulingsInput.shape, async (params) => { try { const result = getRulingsHandler(db, params); return { content: [{ type: 'text' as const, text: formatGetRulings(result) }] }; } catch (err) {