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
| Name | Required | Description | Default |
|---|---|---|---|
| colors | No | ||
| max | No | ||
| min | No | ||
| page | No | ||
| type | No |
Implementation Reference
- src/mcp-server.ts:140-149 (handler)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; }
- src/mcp-server.ts:124-131 (schema)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;
- src/mcp-server.ts:132-150 (registration)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; } );