get_card
Retrieve Magic: The Gathering card data using Scryfall UUID or card name search with exact or fuzzy matching options.
Instructions
Get a single card by Scryfall UUID or by name (exact/fuzzy).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fuzzy | No | If true, uses fuzzy name match | |
| id | No | ||
| name | No |
Implementation Reference
- src/mcp-server.ts:208-213 (handler)Handler function that implements the core logic of the 'get_card' tool by fetching card data via Scryfall API based on ID (UUID) or name (exact or fuzzy).async ({ id, name, fuzzy }: { id?: string; name?: string; fuzzy?: boolean }): Promise<ToolResult> => { const data: unknown = id ? await Scryfall.getCardById(id) : await Scryfall.getCardNamed(name as string, Boolean(fuzzy)); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] } as any; }
- src/mcp-server.ts:196-200 (schema)Input schema (Zod shape) defining parameters for the 'get_card' tool: optional id (UUID), name, and fuzzy matching flag.const getCardParamsShape = { id: z.string().uuid().optional(), name: z.string().optional(), fuzzy: z.boolean().optional().describe("If true, uses fuzzy name match") } as const;
- src/mcp-server.ts:202-214 (registration)Registration of the 'get_card' tool on the MCP server, including description, input schema reference, and inline handler.server.registerTool( "get_card", { description: "Get a single card by Scryfall UUID or by name (exact/fuzzy).", inputSchema: getCardParamsShape }, async ({ id, name, fuzzy }: { id?: string; name?: string; fuzzy?: boolean }): Promise<ToolResult> => { const data: unknown = id ? await Scryfall.getCardById(id) : await Scryfall.getCardNamed(name as string, Boolean(fuzzy)); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] } as any; } );
- src/scryfall.ts:101-103 (helper)Helper methods on Scryfall object: getCardById and getCardNamed, which perform the actual API calls to fetch card data and are invoked by the tool handler.getCardById: (id: string) => getJson(`/cards/${encodeURIComponent(id)}`), getCardNamed: (name: string, fuzzy = false) => getJson("/cards/named", fuzzy ? { fuzzy: name } : { exact: name }),