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

CSB: Parse deck text

csb_parse_deck_text

Parse plain-text decklists into Magic: The Gathering cards using Commander Spellbook to identify cards from text entries.

Instructions

Parse a plain-text decklist into cards using Commander Spellbook.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesPlain-text deck list, e.g. '1x Sol Ring' per line

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
mainYes
commandersNo

Implementation Reference

  • The main handler function for the csb_parse_deck_text tool, which calls CSB.parseCardListFromText to parse the deck text and returns structured content.
    async ({ text }: { text: string }) => {
        const res = (await CSB.parseCardListFromText(text)) as any;
        return { structuredContent: res } as any;
    }
  • Input schema (deck text string) and output schema (arrays of cards with quantities for main and optional commanders).
    const csbParseDeckInput = {
        text: z.string().min(1).describe("Plain-text deck list, e.g. '1x Sol Ring' per line")
    } as const;
    const csbParseDeckOutput = {
        main: z.array(z.object({ card: z.string(), quantity: z.number().int().positive() })),
        commanders: z.array(z.object({ card: z.string(), quantity: z.number().int().positive() })).optional()
    } as const;
  • Registers the csb_parse_deck_text tool in the MCP server with schema, description, and handler function.
    server.registerTool(
        "csb_parse_deck_text",
        {
            title: "CSB: Parse deck text",
            description: "Parse a plain-text decklist into cards using Commander Spellbook.",
            inputSchema: csbParseDeckInput,
            outputSchema: csbParseDeckOutput
        },
        async ({ text }: { text: string }) => {
            const res = (await CSB.parseCardListFromText(text)) as any;
            return { structuredContent: res } as any;
        }
    );
  • CSB client method that performs POST request to CSB API endpoint /card-list-from-text with the deck text.
    parseCardListFromText: (text: string) => postText("/card-list-from-text", text),
  • Helper function postText used by CSB methods to send POST requests to CSB API with rate limiting and retries.
    async function postText(path: string, body: string) {
        const base = process.env.CSB_BASE_URL || DEFAULT_BASE_URL;
        const url = new URL(path, base);
    
        const maxRetries = Number(process.env.CSB_MAX_RETRIES || 3);
        const retryBaseMs = Number(process.env.CSB_RETRY_BASE_MS || 250);
    
        for (let attempt = 0; attempt <= maxRetries; attempt++) {
            await acquireSlot();
            const res = await fetch(url, {
                method: "POST",
                headers: {
                    "Content-Type": "text/plain",
                    "User-Agent": "scryfall-mcp/0.1 (commanderspellbook client)"
                },
                body
            });
    
            if (res.status === 429) {
                const retryAfter = Number(res.headers.get("Retry-After") || 0);
                const backoff = retryAfter > 0 ? retryAfter * 1000 : retryBaseMs * Math.pow(2, attempt);
                if (attempt < maxRetries) {
                    await sleep(backoff);
                    continue;
                }
            }
    
            if (!res.ok) {
                const text = await res.text().catch(() => "");
                throw new Error(`CSB request failed: ${res.status} ${res.statusText} - ${text}`);
            }
    
            return res.json() as Promise<unknown>;
        }
    
        throw new Error("CSB request failed after retries");
    }
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. It mentions parsing into cards but doesn't disclose behavioral traits such as error handling (e.g., invalid text formats), performance (e.g., rate limits or processing time), or output specifics (though an output schema exists). For a tool with no annotation coverage, this is a significant gap in transparency about how the tool behaves beyond its basic function.

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 front-loads the core action ('parse a plain-text decklist') and context ('using Commander Spellbook'). Every word earns its place with no redundancy or unnecessary details, making it highly concise and well-structured for quick understanding.

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 one parameter with full schema coverage and an output schema, the description is minimally complete. It states the purpose but lacks context on usage guidelines, behavioral transparency, and integration with siblings. For a tool in a complex server with many siblings, more guidance would be helpful, but the structured data (schema, output schema) covers basic needs adequately.

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?

Schema description coverage is 100%, with the parameter 'text' fully documented in the schema. The description adds minimal value by specifying 'plain-text deck list, e.g., '1x Sol Ring' per line', which reinforces the schema but doesn't provide additional semantics like format constraints or examples beyond what's already covered. Baseline 3 is appropriate as the schema does the heavy lifting.

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 action ('parse') and resource ('plain-text decklist into cards'), specifying the target system ('using Commander Spellbook'). It distinguishes from siblings like 'csb_build_card_index' or 'csb_card' by focusing on text parsing rather than indexing or individual card lookup. However, it doesn't explicitly contrast with 'search_cards' or 'autocomplete', which might also handle text input, leaving minor ambiguity.

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?

No explicit guidance on when to use this tool versus alternatives is provided. The description implies usage for parsing deck lists, but it doesn't specify scenarios like converting user input for combo analysis (vs. 'csb_find_combos_by_names') or handling raw text vs. structured queries (vs. 'search_cards'). This lack of context leaves the agent to infer usage 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