Skip to main content
Glama

get_prices

Retrieve current market prices for Magic: The Gathering cards in USD, EUR, and MTGO tix to evaluate card values, calculate deck costs, and compare pricing across formats.

Instructions

Look up current market prices for one or more Magic cards. Returns USD, USD Foil, EUR, and MTGO tix prices from Scryfall. Use this when a user asks about card prices, deck costs, or wants to compare card values.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namesYesCard names to look up prices for (1-50)

Implementation Reference

  • The main logic for retrieving prices from the database for a list of card names.
    export function handler(db: Database.Database, params: GetPricesParams): GetPricesResult {
      const cards: CardPriceEntry[] = [];
    
      for (const name of params.names) {
        // 1. Exact match (case-insensitive)
        let card = db.prepare(
          'SELECT * FROM cards WHERE LOWER(name) = LOWER(?)'
        ).get(name) as CardRow | undefined;
    
        // 2. Fuzzy fallback via LIKE
        if (!card) {
          card = db.prepare(
            'SELECT * FROM cards WHERE LOWER(name) LIKE LOWER(?)'
          ).get(`%${name}%`) as CardRow | undefined;
        }
    
        if (!card) {
          cards.push({
            name,
            found: false,
            price_usd: null,
            price_usd_foil: null,
            price_eur: null,
            price_eur_foil: null,
            price_tix: null,
          });
        } else {
          cards.push({
            name: card.name,
            found: true,
            price_usd: card.price_usd,
            price_usd_foil: card.price_usd_foil,
            price_eur: card.price_eur,
            price_eur_foil: card.price_eur_foil,
            price_tix: card.price_tix,
          });
        }
      }
    
      return { cards };
    }
  • Zod schema defining the input validation for 'get_prices'.
    export const GetPricesInput = z.object({
      names: z.array(z.string()).min(1).max(50).describe('Card names to look up prices for (1-50)'),
    });
  • src/server.ts:264-275 (registration)
    Tool registration in the MCP server for 'get_prices'.
    server.tool(
      'get_prices',
      'Look up current market prices for one or more Magic cards. Returns USD, USD Foil, EUR, and MTGO tix prices from Scryfall. Use this when a user asks about card prices, deck costs, or wants to compare card values.',
      GetPricesInput.shape,
      async (params) => {
        try {
          const result = getPricesHandler(db, params);
          return { content: [{ type: 'text' as const, text: formatGetPrices(result) }] };
        } catch (err) {
          return { content: [{ type: 'text' as const, text: `Error getting prices: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
        }
      },

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/gregario/mtg-oracle'

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