Skip to main content
Glama
latte-chan
by latte-chan

search_cards

Search Magic: The Gathering cards using Scryfall's full-text syntax to find specific cards, art variants, or printings with customizable filters and sorting options.

Instructions

Search cards using Scryfall's powerful full-text syntax.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesScryfall search query, e.g., 't:creature cmc<=3'
uniqueNo
orderNo
dirNo
pageNo
include_extrasNo
include_multilingualNo
include_variationsNo

Implementation Reference

  • The handler function for the 'search_cards' tool. It takes search parameters, calls Scryfall.searchCards, and returns the raw JSON response 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;
    }
  • Zod shape defining the input schema for the search_cards tool, matching Scryfall's SearchParams.
    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;
  • Registration of the 'search_cards' tool with the MCP server, including name, schema, description, and handler.
    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;
        }
    );
  • The Scryfall.searchCards helper method that makes the API request to /cards/search endpoint.
    searchCards: (opts: SearchParams) => getJson("/cards/search", opts),
  • TypeScript type definition for SearchParams used by the searchCards method and tool input.
    export type SearchParams = {
        q: string;
        unique?: "cards" | "art" | "prints";
        order?:
        | "name"
        | "set"
        | "released"
        | "rarity"
        | "color"
        | "usd"
        | "tix"
        | "eur"
        | "cmc"
        | "power"
        | "toughness"
        | "edhrec"
        | "penny"
        | "artist"
        | "review";
        dir?: "auto" | "asc" | "desc";
        page?: number;
        include_extras?: boolean;
        include_multilingual?: boolean;
        include_variations?: boolean;
    };

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