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

Search by colors

search_by_colors

Search Magic: The Gathering cards by color combinations, color identity, or colorless options using Scryfall's comprehensive database.

Instructions

Find cards by colors or color identity.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
colorsNo
modeNocontains
include_colorlessNoInclude colorless cards
identityNoFilter by color identity instead of printed colors
pageNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
totalYes
resultsYes

Implementation Reference

  • Input schema (searchByColorsInput) and output schema (searchByColorsOutput) Zod shapes for the search_by_colors tool, defining parameters like colors array, mode (exact/contains/at_most), and output with total count and summarized card results.
    const searchByColorsInput = {
        colors: z.array(z.enum(["W", "U", "B", "R", "G"])).min(0).max(5).optional(),
        mode: z.enum(["exact", "contains", "at_most"]).default("contains"),
        include_colorless: z.boolean().optional().describe("Include colorless cards"),
        identity: z.boolean().optional().describe("Filter by color identity instead of printed colors"),
        page: z.number().int().min(1).optional()
    } as const;
    const searchByColorsOutput = {
        total: z.number().int().nonnegative(),
        results: z.array(z.object(cardSummaryShape))
    } as const;
  • Registration of the search_by_colors tool using server.registerTool, including title, description, schemas, and the inline async handler function that builds a Scryfall color query and returns summarized results.
    server.registerTool(
        "search_by_colors",
        {
            title: "Search by colors",
            description: "Find cards by colors or color identity.",
            inputSchema: searchByColorsInput,
            outputSchema: searchByColorsOutput
        },
        async ({ colors = [], mode, include_colorless, identity, page }: { colors?: Array<"W" | "U" | "B" | "R" | "G">; mode: "exact" | "contains" | "at_most"; include_colorless?: boolean; identity?: boolean; page?: number }) => {
            const op = mode === "exact" ? "=" : mode === "contains" ? ">=" : "<=";
            const opKey = identity ? "c" : "color"; // c = color identity
            const parts = [colors.length ? `${opKey}${op}${colors.join("")}` : undefined, include_colorless ? "is:colorless" : undefined];
            const q = joinParts(parts);
            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;
        }
    );
  • The core handler logic for search_by_colors: constructs Scryfall query using color operator based on mode and identity flag, optionally adds colorless filter, fetches cards via Scryfall.searchCards, summarizes results, and returns structured content with total and card summaries.
    async ({ colors = [], mode, include_colorless, identity, page }: { colors?: Array<"W" | "U" | "B" | "R" | "G">; mode: "exact" | "contains" | "at_most"; include_colorless?: boolean; identity?: boolean; page?: number }) => {
        const op = mode === "exact" ? "=" : mode === "contains" ? ">=" : "<=";
        const opKey = identity ? "c" : "color"; // c = color identity
        const parts = [colors.length ? `${opKey}${op}${colors.join("")}` : undefined, include_colorless ? "is:colorless" : undefined];
        const q = joinParts(parts);
        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;
    }
  • Shared helper: cardSummaryShape Zod object used in output schema, and summarize function that extracts key fields from Scryfall card data into a compact summary used by search_by_colors and other tools.
    const cardSummaryShape = {
        name: z.string(),
        mana_cost: z.string().optional(),
        type_line: z.string(),
        oracle_text: z.string().optional(),
        set: z.string(),
        collector_number: z.string(),
        scryfall_uri: z.string().url(),
        image: z.string().url().optional(),
        prices: z
            .object({ usd: z.string().nullable().optional(), eur: z.string().nullable().optional(), tix: z.string().nullable().optional() })
            .partial()
            .optional()
    } as const;
    type CardSummary = z.infer<z.ZodObject<typeof cardSummaryShape>>;
    const summarize = (card: any): CardSummary => ({
        name: card?.name,
        mana_cost: card?.mana_cost,
        type_line: card?.type_line,
        oracle_text: card?.oracle_text,
        set: card?.set,
        collector_number: String(card?.collector_number ?? ""),
        scryfall_uri: card?.scryfall_uri,
        image: card?.image_uris?.normal ?? card?.image_uris?.large ?? card?.image_uris?.small,
        prices: card?.prices
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't describe how it behaves: no information about pagination (implied by 'page' parameter), rate limits, authentication needs, error conditions, or what the output contains. This is inadequate for a search tool with 5 parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point with zero wasted words. It's appropriately sized for a search tool and front-loads the core functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 5 parameters, no annotations, and an output schema exists (which reduces the need to describe return values), the description is minimally complete. It states what the tool does but lacks behavioral context and parameter guidance that would help an agent use it effectively. The existence of an output schema prevents a lower score.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description mentions 'colors or color identity' which hints at the 'colors' and 'identity' parameters, but with only 40% schema description coverage, it doesn't explain the 'mode', 'include_colorless', or 'page' parameters. The description adds minimal value beyond what the schema's enum values and descriptions already provide for some parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Find' and resource 'cards' with the specific criteria 'by colors or color identity', making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'search_cards' or 'search_by_format', which likely also search cards with different filters.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'search_cards' or 'search_by_format'. It doesn't mention prerequisites, exclusions, or comparative use cases, leaving the agent to guess based on tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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