Skip to main content
Glama

search_by_cmc

Search Magic: The Gathering cards by mana value range, with optional filters for color identity and card type to find specific cards for deck building or strategy.

Instructions

Find cards within a mana value range, optionally filtered by color and type.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
colorsNo
maxNo
minNo
pageNo
typeNo

Implementation Reference

  • Handler function that constructs a Scryfall search query using mana value filters (mv>=min, mv<=max), optional colors and type, fetches cards via Scryfall.searchCards, summarizes results into total and array of card summaries, returns structured content.
    async ({ min, max, colors = [], type, page }: { min?: number; max?: number; colors?: Array<"W" | "U" | "B" | "R" | "G">; type?: string; page?: number }) => { const range = [typeof min === "number" ? `mv>=${min}` : undefined, typeof max === "number" ? `mv<=${max}` : undefined]; const colorPart = colors.length ? `color>=${colors.join("")}` : undefined; const typePart = type ? `type:${quote(type)}` : undefined; const q = joinParts([...range, colorPart, typePart]); const data: any = (await Scryfall.searchCards({ q, page })) as any; const items: any[] = Array.isArray(data?.data) ? data.data : []; const out = { total: Number(data?.total_cards ?? items.length), results: items.map(summarize) }; return { structuredContent: out } as any; }
  • Zod input schema defining parameters for mana value range (min/max), colors array, type string, page; output schema references the one from search_by_colors tool (total and results array).
    const searchByCmcInput = { min: z.number().int().min(0).optional(), max: z.number().int().min(0).optional(), colors: z.array(z.enum(["W", "U", "B", "R", "G"])).min(0).max(5).optional(), type: z.string().optional(), page: z.number().int().min(1).optional() } as const; const searchByCmcOutput = searchByColorsOutput;
  • MCP server tool registration for 'search_by_cmc' including title, description, input/output schemas, and inline async handler function.
    server.registerTool( "search_by_cmc", { title: "Search by mana value", description: "Find cards within a mana value range, optionally filtered by color and type.", inputSchema: searchByCmcInput, outputSchema: searchByCmcOutput }, async ({ min, max, colors = [], type, page }: { min?: number; max?: number; colors?: Array<"W" | "U" | "B" | "R" | "G">; type?: string; page?: number }) => { const range = [typeof min === "number" ? `mv>=${min}` : undefined, typeof max === "number" ? `mv<=${max}` : undefined]; const colorPart = colors.length ? `color>=${colors.join("")}` : undefined; const typePart = type ? `type:${quote(type)}` : undefined; const q = joinParts([...range, colorPart, typePart]); const data: any = (await Scryfall.searchCards({ q, page })) as any; const items: any[] = Array.isArray(data?.data) ? data.data : []; const out = { total: Number(data?.total_cards ?? items.length), results: items.map(summarize) }; return { structuredContent: out } as any; } );

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/latte-chan/scryfall-connector'

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