search_cards
Search Magic: The Gathering cards using Scryfall's full-text syntax to find specific cards based on type, cost, color, and other attributes.
Instructions
Search cards using Scryfall's powerful full-text syntax.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dir | No | ||
| include_extras | No | ||
| include_multilingual | No | ||
| include_variations | No | ||
| order | No | ||
| page | No | ||
| q | Yes | Scryfall search query, e.g., 't:creature cmc<=3' | |
| unique | No |
Implementation Reference
- src/mcp-server.ts:85-88 (handler)Handler function that executes the tool logic: calls Scryfall.searchCards with the input parameters and returns the raw JSON response formatted as text content.async (params: SearchParams): Promise<ToolResult> => { const data: unknown = await Scryfall.searchCards(params); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] } as any; }
- src/mcp-server.ts:50-77 (schema)Zod input schema definition for the search_cards tool, defining parameters like query, ordering, pagination, etc.const searchParamsShape = { q: z.string().describe("Scryfall search query, e.g., 't:creature cmc<=3'"), unique: z.enum(["cards", "art", "prints"]).optional(), order: z .enum([ "name", "set", "released", "rarity", "color", "usd", "tix", "eur", "cmc", "power", "toughness", "edhrec", "penny", "artist", "review" ]) .optional(), dir: z.enum(["auto", "asc", "desc"]).optional(), page: z.number().int().min(1).optional(), include_extras: z.boolean().optional(), include_multilingual: z.boolean().optional(), include_variations: z.boolean().optional() } as const;
- src/mcp-server.ts:79-89 (registration)Registration of the 'search_cards' tool on the MCP server, specifying name, description, input schema, and handler function.server.registerTool( "search_cards", { description: "Search cards using Scryfall's powerful full-text syntax.", inputSchema: searchParamsShape }, async (params: SearchParams): Promise<ToolResult> => { const data: unknown = await Scryfall.searchCards(params); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] } as any; } );
- src/scryfall.ts:100-100 (helper)Supporting utility function Scryfall.searchCards that makes the HTTP request to Scryfall API's /cards/search endpoint.searchCards: (opts: SearchParams) => getJson("/cards/search", opts),