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

Search by format legality

search_by_format

Search Magic: The Gathering cards by format legality. Filter results by format, status (legal, banned, restricted), and colors to find cards for specific game formats.

Instructions

Find cards by legality in a given format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatYes
statusNolegal
colorsNo
pageNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
totalYes
resultsYes

Implementation Reference

  • Handler function that builds a Scryfall search query for cards legal (or banned/restricted) in a specific format, optionally filtered by colors, fetches the results, summarizes each card, and returns structured output with total count and results.
    async ({ format, status, colors = [], page }: { format: typeof formats[number]; status: "legal" | "banned" | "restricted"; colors?: Array<"W" | "U" | "B" | "R" | "G">; page?: number }) => {
        const legal = `${status}:${format}`; // e.g., legal:commander
        const colorPart = colors.length ? `color>=${colors.join("")}` : undefined;
        const q = joinParts([legal, colorPart]);
        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: format (enum from formats array), status (legal/banned/restricted), optional colors array, and page.
    const searchByFormatInput = {
        format: z.enum(formats),
        status: z.enum(["legal", "banned", "restricted"]).default("legal"),
        colors: z.array(z.enum(["W", "U", "B", "R", "G"])).min(0).max(5).optional(),
        page: z.number().int().min(1).optional()
    } as const;
  • McpServer tool registration for 'search_by_format', specifying title, description, input/output schemas, and the handler function.
    server.registerTool(
        "search_by_format",
        {
            title: "Search by format legality",
            description: "Find cards by legality in a given format.",
            inputSchema: searchByFormatInput,
            outputSchema: searchByColorsOutput
        },
        async ({ format, status, colors = [], page }: { format: typeof formats[number]; status: "legal" | "banned" | "restricted"; colors?: Array<"W" | "U" | "B" | "R" | "G">; page?: number }) => {
            const legal = `${status}:${format}`; // e.g., legal:commander
            const colorPart = colors.length ? `color>=${colors.join("")}` : undefined;
            const q = joinParts([legal, colorPart]);
            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;
        }
    );
  • Const array of supported Magic: The Gathering formats used to define the enum in the input schema.
    const formats = [
        "standard",
        "pioneer",
        "modern",
        "legacy",
        "vintage",
        "commander",
        "oathbreaker",
        "pauper",
        "paupercommander",
        "historic",
        "timeless",
        "alchemy",
        "brawl",
        "duel",
        "predh"
    ] as const;
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'finds' cards, implying a read-only operation, but doesn't clarify aspects like pagination behavior (hinted by the 'page' parameter), rate limits, authentication needs, or what the output contains. For a search tool with 4 parameters and no annotation coverage, this leaves significant gaps in understanding how the tool behaves.

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: 'Find cards by legality in a given format.' It is front-loaded with the core purpose and contains no unnecessary words. Every part of the sentence contributes directly to understanding the tool's function.

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's complexity (4 parameters, no annotations, but with an output schema), the description is minimally adequate. It states the purpose but lacks details on usage guidelines, behavioral traits, and parameter meanings. The presence of an output schema means return values are documented elsewhere, so the description doesn't need to explain them. However, for a search tool with multiple filtering options, more context would be helpful.

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 'legality in a given format,' which aligns with the 'format' and 'status' parameters, but doesn't explain the meaning of 'colors' or 'page.' With 0% schema description coverage, the schema provides no parameter descriptions, so the description adds some value by hinting at the primary use case. However, it doesn't fully compensate for the lack of details on all parameters, resulting in a baseline score of 3.

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 tool's purpose: 'Find cards by legality in a given format.' It specifies the verb ('Find') and resource ('cards'), and indicates the primary filtering criterion ('by legality in a given format'). However, it doesn't explicitly differentiate from sibling tools like 'search_cards' or 'search_by_colors', which reduces the score from a perfect 5.

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. It doesn't mention sibling tools like 'search_cards' (which might be more general) or 'search_by_colors' (which filters by a different criterion), nor does it specify prerequisites or exclusions. The user must infer usage from the tool name and parameters 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