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

Search by mana value

search_by_cmc

Search Magic: The Gathering cards by converted mana cost range, with optional filters for color and card type to find specific cards for deck building.

Instructions

Find cards within a mana value range, optionally filtered by color and type.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
minNo
maxNo
colorsNo
typeNo
pageNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
totalYes
resultsYes

Implementation Reference

  • Executes the tool: builds Scryfall query for mana value (mv>=min mv<=max), optional color>=colors, type:quoted(type), searches, summarizes results into {total, results: CardSummary[]}.
    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;
    }
  • Input schema (min/max cmc, colors array, type str, page) and output schema reference (reuses search_by_colors output: {total: number, results: CardSummary[]}).
    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;
  • Registers the 'search_by_cmc' tool with MCP server, providing title, description, input/output schemas, and inline handler.
    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;
        }
    );
  • Shared output schema {total: number, results: array of summarized cards}, referenced by searchByCmcOutput.
    const searchByColorsOutput = {
        total: z.number().int().nonnegative(),
        results: z.array(z.object(cardSummaryShape))
    } as const;
  • Helper to summarize Scryfall card data into CardSummary shape used in output results.
    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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions filtering options but does not describe key behaviors like pagination (implied by the 'page' parameter in the schema), rate limits, authentication needs, or what the output contains. For a search tool with no annotation coverage, this is a significant gap in transparency.

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 within a mana value range, optionally filtered by color and type.' It is front-loaded with the core purpose and includes optional filters without unnecessary detail, making it highly concise and well-structured.

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 moderate complexity (5 parameters, no annotations, but with an output schema), the description is incomplete. It covers the basic purpose but lacks usage guidelines, behavioral details, and full parameter explanations. The presence of an output schema reduces the need to describe return values, but the description should still address when to use this tool and its operational constraints.

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 adds minimal semantics beyond the input schema. It mentions 'mana value range' (mapping to 'min' and 'max'), 'color' (mapping to 'colors'), and 'type' (mapping to 'type'), but does not explain the format of 'type' or the meaning of 'page'. With 0% schema description coverage, the description partially compensates but leaves key parameters like 'page' and the enum values for 'colors' undocumented.

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 within a mana value range, optionally filtered by color and type.' It specifies the verb ('Find'), resource ('cards'), and scope ('mana value range'), but does not explicitly differentiate from sibling tools like 'search_by_colors' or 'search_cards', which appear to offer overlapping functionality. This makes it clear but not fully distinct.

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. With sibling tools such as 'search_by_colors', 'search_by_format', and 'search_cards', there is no indication of when this specific mana-value-based search is preferred or what its limitations are. This leaves the agent without context for tool selection.

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