Skip to main content
Glama

get_rulings

Retrieve official rulings for any Magic card to resolve specific interactions and edge cases, sourced directly from Wizards of the Coast.

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
NameRequiredDescriptionDefault
card_nameYesName of the card to get rulings for

Implementation Reference

  • Main handler function that looks up a card by name (case-insensitive exact match, then LIKE), queries rulings from the database, and returns the results or a not-found message.
    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,
        })),
      };
    }
  • Zod input schema for the 'get_rulings' tool: expects a 'card_name' string parameter.
    export const GetRulingsInput = z.object({
      card_name: z.string().describe('Name of the card to get rulings for'),
    });
  • Output types: RulingEntry interface, GetRulingsResult discriminated union (found/message).
    export interface RulingEntry {
      source: string | null;
      published_at: string | null;
      comment: string;
    }
    
    export type GetRulingsResult = {
      found: true;
      card_name: string;
      rulings: RulingEntry[];
    } | {
      found: false;
      message: string;
    };
  • src/server.ts:107-119 (registration)
    Tool registration using server.tool('get_rulings', ...) with description, input schema, and handler invocation with formatting.
    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) {
          return { content: [{ type: 'text' as const, text: `Error getting rulings: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
        }
      },
    );
  • Formatting helper that converts GetRulingsResult into a human-readable string with a heading and bullet-pointed rulings.
    export function formatGetRulings(result: GetRulingsResult): string {
      if (!result.found) {
        return result.message;
      }
    
      if (result.rulings.length === 0) {
        return `No rulings found for "${result.card_name}".`;
      }
    
      const lines: string[] = [`# Rulings for ${result.card_name} (${result.rulings.length})\n`];
      for (const ruling of result.rulings) {
        const datePart = ruling.published_at ? `${ruling.published_at}` : '';
        const sourcePart = ruling.source ? ` (${ruling.source})` : '';
        lines.push(`- ${datePart}${sourcePart}: ${ruling.comment}`);
      }
    
      return lines.join('\n');
    }
Behavior3/5

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

No annotations provided, so the description carries the full burden. It discloses that rulings are timestamped and from Wizards of the Coast, but does not cover potential error conditions or limits.

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 efficiently convey function, usage context, and output. No wasted words.

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?

For a simple tool with one parameter and no output schema, the description is fairly complete: it explains purpose, usage, and output format. Could add details on error handling or no results, but not essential.

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

Parameters3/5

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

Schema coverage is 100%, and the parameter description in the schema is adequate. The tool description does not add extra semantic value beyond the 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?

The description clearly states the verb 'get official rulings' and the resource 'specific Magic card'. It distinguishes from siblings like get_card (basic info) and lookup_rule (rules) by specifying the use case for interactions and edge cases.

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

Usage Guidelines4/5

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

Explicitly states when to use: 'when a user asks about specific interactions, edge cases, or how a card works in unusual situations.' Provides solid context, though it doesn't explicitly mention when not to use.

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

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