get_card_by_name
Retrieve Magic: The Gathering card data by exact English name. Returns JSON with card details, rulings, and pricing information from Scryfall.
Instructions
Retrieve a card by its exact English name, e.g. 'Black Lotus'. Returns the card data in JSON. If multiple cards share that exact name, Scryfall returns one (usually the most relevant printing).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Exact name of the card, e.g. 'Lightning Bolt' |
Implementation Reference
- index.ts:256-263 (handler)The main handler function that performs the HTTP fetch to Scryfall API for the exact card name and processes the response.async function handleGetCardByName(name: string) { // Tilde in URL means 'exact' mode for the card name const url = `https://api.scryfall.com/cards/named?exact=${encodeURIComponent( name )}`; const response = await fetch(url); return handleScryfallResponse(response); }
- index.ts:107-122 (schema)Defines the tool schema including name, description, and input validation schema.const GET_CARD_BY_NAME_TOOL: Tool = { name: "get_card_by_name", description: "Retrieve a card by its exact English name, e.g. 'Black Lotus'. Returns the card data in JSON. " + "If multiple cards share that exact name, Scryfall returns one (usually the most relevant printing).", inputSchema: { type: "object", properties: { name: { type: "string", description: "Exact name of the card, e.g. 'Lightning Bolt'" } }, required: ["name"] } };
- index.ts:186-194 (registration)Registers the get_card_by_name tool by including it in the array of tools served to listTools requests.const SCRYFALL_TOOLS = [ SEARCH_CARDS_TOOL, GET_CARD_BY_ID_TOOL, GET_CARD_BY_NAME_TOOL, RANDOM_CARD_TOOL, GET_RULINGS_TOOL, GET_PRICES_BY_ID_TOOL, GET_PRICES_BY_NAME_TOOL ] as const;
- index.ts:382-385 (handler)Switch case in the main CallToolRequestSchema handler that routes calls to the specific get_card_by_name handler.case "get_card_by_name": { const { name } = args as { name: string }; return await handleGetCardByName(name); }