get_card
Retrieve Magic: The Gathering card data by Scryfall UUID or card name using exact or fuzzy matching.
Instructions
Get a single card by Scryfall UUID or by name (exact/fuzzy).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | ||
| name | No | ||
| fuzzy | No | If true, uses fuzzy name match |
Implementation Reference
- src/mcp-server.ts:208-213 (handler)Handler function that executes the 'get_card' tool: fetches card data from Scryfall by ID (exact) or name (exact/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) defining parameters for the 'get_card' tool: optional id (UUID), name, and fuzzy 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 with MCP server, including description, schema, and 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-101 (helper)Scryfall API helper: fetches card details by encoded ID.getCardById: (id: string) => getJson(`/cards/${encodeURIComponent(id)}`),
- src/scryfall.ts:102-103 (helper)Scryfall API helper: fetches card by name, with optional fuzzy matching.getCardNamed: (name: string, fuzzy = false) => getJson("/cards/named", fuzzy ? { fuzzy: name } : { exact: name }),