get_prices_by_id
Retrieve Magic: The Gathering card pricing data in multiple currencies by providing the Scryfall ID. Returns JSON with USD, USD foil, EUR, and tix values.
Instructions
Retrieve price information for a card by its Scryfall ID. Returns JSON with usd, usd_foil, eur, tix, etc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Scryfall ID of the card |
Implementation Reference
- index.ts:281-310 (handler)Implements the core logic for the get_prices_by_id tool: fetches card details by Scryfall ID and returns the prices object as formatted JSON.async function handleGetPricesById(id: string) { const url = `https://api.scryfall.com/cards/${encodeURIComponent(id)}`; 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:153-167 (schema)Defines the tool schema: name, description, and input schema requiring a single 'id' parameter (Scryfall ID).const GET_PRICES_BY_ID_TOOL: Tool = { name: "get_prices_by_id", description: "Retrieve price information for a card by its Scryfall ID. Returns JSON with usd, usd_foil, eur, tix, etc.", inputSchema: { type: "object", properties: { id: { type: "string", description: "Scryfall ID of the card" } }, required: ["id"] } };
- index.ts:187-194 (registration)Registers the tool in the SCRYFALL_TOOLS array, which is returned by the ListToolsRequestHandler.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:393-396 (registration)Registers the tool handler dispatch in the CallToolRequestHandler switch statement.case "get_prices_by_id": { const { id } = args as { id: string }; return await handleGetPricesById(id); }