Skip to main content
Glama

lookup_rule

Find Magic: The Gathering rules by section number or search text to resolve gameplay questions and verify official rule interactions.

Instructions

Look up a specific section of the Magic: The Gathering Comprehensive Rules by section number (e.g., "702", "702.1") or search rules text. Use this when a user asks about specific game rules, rule interactions, or needs the official rule text. Returns the rule and its subsections.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sectionNoRule section number to look up (e.g. "702" or "702.1"). Returns exact match plus all subsections.
queryNoText to search for across all rule titles and text (case-insensitive).

Implementation Reference

  • The handler function that dispatches the request to either lookupBySection or searchByText based on the provided params.
    export function handler(db: Database.Database, params: LookupRuleParams): LookupRuleResult {
      if (params.section) {
        return lookupBySection(db, params.section);
      }
      return searchByText(db, params.query!);
    }
  • Input validation schema for the lookup_rule tool.
    export const LookupRuleInput = z.object({
      section: z.string().optional().describe('Rule section number to look up (e.g. "702" or "702.1"). Returns exact match plus all subsections.'),
      query: z.string().optional().describe('Text to search for across all rule titles and text (case-insensitive).'),
    }).refine(data => data.section || data.query, {
      message: 'Either section or query must be provided',
    });
  • src/server.ts:163-169 (registration)
    The registration and invocation of lookup_rule in the main MCP server.
    'lookup_rule',
    'Look up a specific section of the Magic: The Gathering Comprehensive Rules by section number (e.g., "702", "702.1") or search rules text. Use this when a user asks about specific game rules, rule interactions, or needs the official rule text. Returns the rule and its subsections.',
    LookupRuleInput.innerType().shape,
    async (params) => {
      try {
        const result = lookupRuleHandler(db, params);
        return { content: [{ type: 'text' as const, text: formatLookupRule(result) }] };

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