get_prices_by_name
Retrieve Magic: The Gathering card pricing data by exact card name, returning current USD, foil, EUR, and other market values in JSON format.
Instructions
Retrieve price information for a card by its exact name. Returns JSON with usd, usd_foil, eur, tix, etc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Exact card name |
Implementation Reference
- index.ts:312-343 (handler)The handler function that fetches the Scryfall card by exact name and returns its price information in JSON format.async function handleGetPricesByName(name: string) { const url = `https://api.scryfall.com/cards/named?exact=${encodeURIComponent( name )}`; const response = await fetch(url); if (!response.ok) { return handleScryfallResponse(response); } const data = (await response.json()) as ScryfallCard; if (!data.prices) { return { content: [ { type: "text", text: "No price information found for this card." } ], isError: false }; } return { content: [ { type: "text", text: JSON.stringify(data.prices, null, 2) } ], isError: false }; }
- index.ts:169-183 (schema)Defines the tool schema, including name, description, and input schema requiring a 'name' string parameter.const GET_PRICES_BY_NAME_TOOL: Tool = { name: "get_prices_by_name", description: "Retrieve price information for a card by its exact name. Returns JSON with usd, usd_foil, eur, tix, etc.", inputSchema: { type: "object", properties: { name: { type: "string", description: "Exact card name" } }, required: ["name"] } };
- index.ts:186-194 (registration)Registers the get_prices_by_name tool by including it in the SCRYFALL_TOOLS array, which is returned by the listTools handler.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:397-400 (registration)Registers the handler for get_prices_by_name tool calls within the switch statement of the CallToolRequestSchema handler.case "get_prices_by_name": { const { name } = args as { name: string }; return await handleGetPricesByName(name); }