Skip to main content
Glama

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
NameRequiredDescriptionDefault
fuzzyNoIf true, uses fuzzy name match
idNo
nameNo

Implementation Reference

  • 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; }
  • 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;
  • 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; } );
  • 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 }),

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/latte-chan/scryfall-connector'

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