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

CSB: Lookup by oracle IDs

csb_lookup_by_oracle_ids

Map Scryfall oracle_id UUIDs to Commander Spellbook numeric IDs using a local index. Convert card identifiers between systems for Magic: The Gathering data integration.

Instructions

Map Scryfall oracle_id UUIDs to Commander Spellbook numeric IDs using the local index (builds if stale).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
oracleIdsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
foundYes
missingYes

Implementation Reference

  • Main handler function that performs the lookup of CSB card IDs by Scryfall oracle IDs using the cached index. Loads index if necessary and maps provided oracleIds to CSB ids.
    export async function lookupCsbIdsByOracle(oracleIds: string[], options?: { ttlMs?: number; force?: boolean; cachePath?: string }): Promise<{ found: Record<string, number>; missing: string[] }> {
        const idx = await loadCsbIndex(options);
        const found: Record<string, number> = {};
        const missing: string[] = [];
        for (const oid of oracleIds) {
            const id = idx.oracleToId[oid];
            if (typeof id === "number") found[oid] = id;
            else missing.push(oid);
        }
        return { found, missing };
    }
  • Zod schemas defining the input (array of oracle UUIDs) and output (map of found oracleId to CSB id, and missing list) for the tool.
    const csbLookupOracleInput = { oracleIds: z.array(z.string().uuid()).min(1) } as const;
    const csbLookupOracleOutput = { found: z.record(z.string(), z.number().int()), missing: z.array(z.string()) } as const;
  • Tool registration in the MCP server, including thin wrapper handler that delegates to lookupCsbIdsByOracle.
    server.registerTool(
        "csb_lookup_by_oracle_ids",
        {
            title: "CSB: Lookup by oracle IDs",
            description: "Map Scryfall oracle_id UUIDs to Commander Spellbook numeric IDs using the local index (builds if stale).",
            inputSchema: csbLookupOracleInput,
            outputSchema: csbLookupOracleOutput
        },
        async ({ oracleIds }: { oracleIds: string[] }) => {
            const res = await lookupCsbIdsByOracle(oracleIds);
            return { structuredContent: res } as any;
        }
  • Helper function to load the CSB index from memory, disk cache, or build it if stale/missing. Called by the handler.
    export async function loadCsbIndex(options?: { ttlMs?: number; force?: boolean; cachePath?: string }): Promise<CsbCardIndex> {
        const ttl = options?.ttlMs ?? DEFAULT_TTL_MS;
        const cachePath = options?.cachePath ?? DEFAULT_CACHE_PATH;
        const now = Date.now();
    
        if (!options?.force && memCache && now - memCache.at < ttl) return memCache.data;
    
        if (!options?.force) {
            const disk = await readCsbIndex(cachePath);
            if (disk && now - disk.at < ttl) {
                memCache = { at: disk.at, data: disk.data };
                return disk.data;
            }
        }
    
        const data = await buildCsbIndex();
        memCache = { at: now, data };
        await writeCsbIndex(data, cachePath).catch(() => {});
        return data;
    }
Behavior4/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 reveals two important behavioral traits: it uses a 'local index' (implying cached data) and 'builds if stale' (indicating automatic index maintenance). This provides useful context about performance and data freshness that isn't obvious from the schema alone.

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 packs essential information: the mapping operation, input/output types, and behavioral context about the local index. Every word earns its place with no redundancy or unnecessary elaboration.

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

Completeness4/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 (mapping operation with automatic index building), no annotations, but with an output schema, the description provides good coverage. It explains the core functionality and key behavioral aspects, though additional details about error cases or performance characteristics could enhance completeness.

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 schema description coverage is 0%, but the description adds meaningful context about the parameter: it explains that 'oracleIds' are 'Scryfall oracle_id UUIDs' and that they get mapped to 'Commander Spellbook numeric IDs'. This provides semantic value beyond the bare schema, though it doesn't detail format constraints or usage examples.

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

Purpose5/5

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

The description clearly states the specific action ('Map'), the input resource ('Scryfall oracle_id UUIDs'), and the output resource ('Commander Spellbook numeric IDs'). It distinguishes from siblings by specifying the mapping functionality rather than searching, building, or other operations.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool: when you have Scryfall oracle IDs and need to map them to Commander Spellbook IDs. It doesn't explicitly mention when not to use it or name specific alternatives, but the context is sufficient for basic guidance.

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