Skip to main content
Glama
cryppadotta

Scryfall MCP Server

by cryppadotta

get_prices_by_id

Retrieve Magic: The Gathering card pricing data by Scryfall ID to access current market values including USD, foil, EUR, and tix prices.

Instructions

Retrieve price information for a card by its Scryfall ID. Returns JSON with usd, usd_foil, eur, tix, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesScryfall ID of the card

Implementation Reference

  • Handler function that fetches the full card by Scryfall ID from the API, extracts the prices object, and returns it as formatted JSON text. Handles errors and missing prices.
    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 }; }
  • Tool definition with name, description, and input schema (object with required 'id' string field).
    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:186-194 (registration)
    Registration of the tool in the SCRYFALL_TOOLS array, which is returned by the listTools request 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:393-396 (registration)
    Dispatcher switch case in the callToolRequest handler that extracts the 'id' argument and invokes the handler function.
    case "get_prices_by_id": { const { id } = args as { id: string }; return await handleGetPricesById(id); }
  • Shared helper function to process Scryfall API responses into MCP content format, handling errors and formatting successful JSON responses. Called by the handler on API errors.
    async function handleScryfallResponse(response: Response) { if (!response.ok) { // Attempt to parse Scryfall error let errorObj: ScryfallError | null = null; try { errorObj = (await response.json()) as ScryfallError; } catch { // fall back to generic } if (errorObj && errorObj.object === "error") { return { content: [ { type: "text", text: `Scryfall error: ${errorObj.details} (code=${errorObj.code}, status=${errorObj.status})` } ], isError: true }; } else { return { content: [ { type: "text", text: `HTTP error ${response.status}: ${response.statusText}` } ], isError: true }; } } // If okay, parse JSON const data = await response.json(); return { content: [ { type: "text", text: JSON.stringify(data, null, 2) } ], isError: false }; }

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/cryppadotta/scryfall-mcp'

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