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

CSB: Build card index

csb_build_card_index

Rebuilds the card index mapping for the Scryfall MCP server to maintain accurate card data retrieval and search functionality.

Instructions

Rebuild oracleId→CSB id index and write cache.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
sizeYes
totalYes
builtAtMsYes

Implementation Reference

  • The handler function registered for 'csb_build_card_index', which builds the index using buildCsbIndex and writes it using writeCsbIndex.
    async () => {
        const data = await buildCsbIndex();
        const path = await writeCsbIndex(data);
        return { structuredContent: { path, total: data.total, size: Object.keys(data.oracleToId).length, builtAtMs: data.builtAtMs } } as any;
    }
  • Output schema definition for the tool.
    const csbBuildIndexOutput = {
        path: z.string(),
        total: z.number().int().nonnegative(),
        size: z.number().int().nonnegative(),
        builtAtMs: z.number()
    } as const;
  • Registration of the 'csb_build_card_index' tool with MCP server.
    server.registerTool(
        "csb_build_card_index",
        {
            title: "CSB: Build card index",
            description: "Rebuild oracleId→CSB id index and write cache.",
            outputSchema: csbBuildIndexOutput
        },
        async () => {
            const data = await buildCsbIndex();
            const path = await writeCsbIndex(data);
            return { structuredContent: { path, total: data.total, size: Object.keys(data.oracleToId).length, builtAtMs: data.builtAtMs } } as any;
        }
    );
  • Core helper function that paginates through all CSB cards and builds the oracleId to CSB ID mapping.
    export async function buildCsbIndex(): Promise<CsbCardIndex> {
        const oracleToId: Record<string, number> = Object.create(null);
        const limit = 100;
        let offset = 0;
        let total = 0;
        while (true) {
            const page: any = await CSB.cards({ limit, offset });
            const results: any[] = Array.isArray(page?.results) ? page.results : [];
            total = Number(page?.count ?? total);
            for (const c of results) {
                const oid = c?.oracleId;
                const id = c?.id;
                if (typeof oid === "string" && typeof id === "number") {
                    if (!(oid in oracleToId)) oracleToId[oid] = id;
                }
            }
            if (!page?.next || results.length === 0) break;
            offset += limit;
        }
        return { builtAtMs: Date.now(), total, oracleToId };
    }
  • Helper function to write the built index to cache file.
    export async function writeCsbIndex(data: CsbCardIndex, cachePath = DEFAULT_CACHE_PATH): Promise<string> {
        await ensureDirFor(cachePath);
        await writeFile(cachePath, JSON.stringify(data, null, 2), "utf8");
        return cachePath;
    }
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 mentions 'Rebuild' and 'write cache', implying a mutation operation that could be resource-intensive or require specific permissions, but doesn't detail potential side effects, performance impact, or error conditions. This is insufficient for a tool that likely modifies data.

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 extremely concise—a single sentence that directly states the tool's action and outcome without any fluff. It's front-loaded and wastes no words, making it easy to parse quickly.

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 0 parameters, 100% schema coverage, and an output schema exists, the description is minimally complete. However, as a mutation tool with no annotations, it should ideally explain more about the rebuild process, cache implications, or when it's safe to use. The output schema helps, but behavioral aspects are under-specified.

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

Parameters4/5

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

The tool has 0 parameters, and schema description coverage is 100%, so no parameter documentation is needed. The description doesn't add parameter details, which is appropriate here, but it could briefly note the lack of inputs for clarity. A baseline of 4 is given as it meets minimal requirements without gaps.

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 ('Rebuild') and the resource ('oracleId→CSB id index and write cache'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'csb_read_card_index' or 'read_tagger_cache', which might involve similar index/cache operations, leaving some ambiguity about uniqueness.

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 guidance is provided on when to use this tool versus alternatives. For example, it doesn't specify if this should be run periodically, after data updates, or as a maintenance task compared to read-only siblings like 'csb_read_card_index'. This lack of context makes it hard for an agent to decide when to invoke it.

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