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
| Name | Required | Description | Default |
|---|---|---|---|
| section | No | Rule section number to look up (e.g. "702" or "702.1"). Returns exact match plus all subsections. | |
| query | No | Text to search for across all rule titles and text (case-insensitive). |
Implementation Reference
- src/tools/lookup-rule.ts:36-41 (handler)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!); } - src/tools/lookup-rule.ts:7-12 (schema)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) }] };