Skip to main content
Glama
jlgrimes

Pokemon TCG Card Search MCP

by jlgrimes

pokemon-card-price

Check the current market price of a Pokémon card by entering its name and set details using this tool from the Pokémon TCG Card Search MCP server.

Instructions

Look up the current market price for a Pokemon card

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesCRITICAL: Never infer or guess values. Never provide default values. Never make assumptions about what the user might want. Never try to be systematic or methodical. Never try to find "specific examples". Just query exactly what was asked for, nothing more and nothing less. CRITICAL: Query exactly what was asked for. Do not try to be systematic. Do not try to find specific examples. Do not try to be methodical. Just make the exact query requested. IMPORTANT: For hyphenated names like "chien-pao", you MUST preserve the hyphen exactly as it appears. For example, "chien-pao ex" should have name "chien-pao" (with the hyphen) and subtypes ["EX"]. Never remove or modify hyphens in the name. Use * for wildcard matching (e.g., "char*" to match all cards starting with "char", or "char*der" to match cards starting with "char" and ending with "der"). Use ! for exact matching (e.g., "!value" to match only exact value). IMPORTANT: If no name is explicitly provided in the query, do not include a name field at all.
setNoCRITICAL: Never infer or guess values. Never provide default values. Never make assumptions about what the user might want. Never try to be systematic or methodical. Never try to find "specific examples". Just query exactly what was asked for, nothing more and nothing less. The set information for this card. Use dot notation (.) to search nested fields (e.g., "set.id:sm1" for set ID, "attacks.name:Spelunk" for attack names). For example, "set.id:sm1" to find cards from a specific set. If no set information is explicitly mentioned, omit this field entirely.

Implementation Reference

  • Handler function that constructs a search query for the given card name and optional set, fetches the first matching card using ptcg_search, and returns its TCGPlayer and Cardmarket price information.
    async ({ name, set }) => { let query = buildQuery( name, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, set, undefined, undefined ); const result = await ptcg_search(query); if (!result.data.length) { return { content: [ { type: 'text', text: JSON.stringify({ error: 'No cards found matching the criteria', }), }, ], }; } const card = result.data[0]; const priceInfo = { name: card.name, set: card.set.name, tcgplayer: card.tcgplayer ? { url: card.tcgplayer.url, updatedAt: card.tcgplayer.updatedAt, prices: card.tcgplayer.prices, } : null, cardmarket: card.cardmarket ? { url: card.cardmarket.url, updatedAt: card.cardmarket.updatedAt, prices: card.cardmarket.prices, } : null, }; return { content: [ { type: 'text', text: JSON.stringify(priceInfo), }, ], }; }
  • Zod input schema defining required 'name' (string) and optional 'set' object (with name and series strings) for the pokemon-card-price tool.
    { name: z.string().describe(FIELD_DESCRIPTIONS_SPECIFIC.NAME), set: z .object({ name: z.string(), series: z.string(), }) .optional() .describe(FIELD_DESCRIPTIONS_SPECIFIC.SET), },
  • index.ts:346-419 (registration)
    Registration of the 'pokemon-card-price' tool on the MCP server, specifying name, description, input schema, and handler function.
    server.tool( 'pokemon-card-price', 'Look up the current market price for a Pokemon card', { name: z.string().describe(FIELD_DESCRIPTIONS_SPECIFIC.NAME), set: z .object({ name: z.string(), series: z.string(), }) .optional() .describe(FIELD_DESCRIPTIONS_SPECIFIC.SET), }, async ({ name, set }) => { let query = buildQuery( name, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, set, undefined, undefined ); const result = await ptcg_search(query); if (!result.data.length) { return { content: [ { type: 'text', text: JSON.stringify({ error: 'No cards found matching the criteria', }), }, ], }; } const card = result.data[0]; const priceInfo = { name: card.name, set: card.set.name, tcgplayer: card.tcgplayer ? { url: card.tcgplayer.url, updatedAt: card.tcgplayer.updatedAt, prices: card.tcgplayer.prices, } : null, cardmarket: card.cardmarket ? { url: card.cardmarket.url, updatedAt: card.cardmarket.updatedAt, prices: card.cardmarket.prices, } : null, }; return { content: [ { type: 'text', text: JSON.stringify(priceInfo), }, ], }; } );
  • Helper function that performs the actual API search to the Pokemon TCG API using the constructed query.
    async function ptcg_search(query: string): Promise<PtcgResponse> { const response = await fetch( `https://api.pokemontcg.io/v2/cards?q=${encodeURIComponent(query)}` ); return response.json() as Promise<PtcgResponse>; }
  • Helper function to construct the search query string from input parameters, shared with other tools.
    function buildQuery( name?: string, subtypes?: string[], legalities?: | { standard?: 'legal' | 'banned'; expanded?: 'legal' | 'banned'; unlimited?: 'legal' | 'banned'; } | string, hp?: string, types?: string[], evolvesTo?: string[], convertedRetreatCost?: number, nationalPokedexNumbers?: string, page?: number | string, pageSize?: number | string, set?: { id?: string; name?: string; series?: string } | string, attacks?: | Array<{ name?: string; cost?: string[]; damage?: string; text?: string }> | string, weaknesses?: Array<{ type?: string; value?: string }> | string, regulationMark?: string ): string { const parts: string[] = []; // Handle name with special cases if (name) { if (name.startsWith('!') || name.includes('*')) { parts.push(`name:${name}`); } else { parts.push(`name:"${name}"`); } } // Generic filter handler for arrays function addFilter( values: string[] | undefined, field: string, negative = false ) { if (!values?.length) return; const query = values .map(value => { if (value.includes('.')) return value; if (value.startsWith('!')) return `${field}:${value}`; if (negative) return `-${field}:${value}`; return `${field}:${value}`; }) .join(' OR '); parts.push(values.length === 1 ? query : `(${query})`); } // Generic nested filter handler function addNestedFilter(value: string | object | undefined, field: string) { if (!value) return; if (typeof value === 'string') { parts.push(value.includes('.') ? value : `${field}:${value}`); } else { Object.entries(value).forEach(([key, val]) => { if (val !== undefined) { parts.push(`${field}.${key}:${val}`); } }); } } // Generic range filter handler function addRangeFilter(value: string | number | undefined, field: string) { if (!value) return; const strValue = String(value); if ( strValue.startsWith('[') || strValue.startsWith('{') || strValue.startsWith('!') ) { parts.push(`${field}:${strValue}`); } else { parts.push(`${field}:${value}`); } } // Add all filters addFilter(subtypes, 'subtypes'); addNestedFilter(legalities, 'legalities'); addFilter(types, 'types'); addFilter(evolvesTo, 'evolvesTo'); addRangeFilter(hp, 'hp'); addRangeFilter(convertedRetreatCost, 'convertedRetreatCost'); addRangeFilter(nationalPokedexNumbers, 'nationalPokedexNumbers'); addRangeFilter(page, 'page'); addRangeFilter(pageSize, 'pageSize'); addNestedFilter(set, 'set'); addNestedFilter(attacks, 'attacks'); addNestedFilter(weaknesses, 'weaknesses'); // Add regulation mark filter if (regulationMark) { parts.push(`regulationMark:${regulationMark}`); } return parts.join(' '); }

Other Tools

Related Tools

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/jlgrimes/ptcg-mcp'

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