Skip to main content
Glama

csb_read_card_index

Access cached Oracle ID to CSB ID mappings for Magic: The Gathering cards to enable efficient card data retrieval and cross-referencing.

Instructions

Read oracleId→CSB id index from local cache.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Inline async handler function that computes the cache path, reads the CSB card index using readCsbIndex helper, computes the size, and returns structured content or error message.
    async () => { const cachePath = process.env.CSB_CARD_INDEX_PATH || require('node:path').join(process.cwd(), 'cache', 'csb-card-index.json'); const disk = await readCsbIndex(cachePath); if (!disk) return { content: [{ type: "text", text: "No CSB card index cache found" }] } as any; const size = Object.keys(disk.data.oracleToId || {}).length; return { structuredContent: { path: cachePath, total: disk.data.total, size, cachedAtMs: disk.at } } as any; }
  • Output schema (zod) for the csb_read_card_index tool response.
    const csbReadIndexOutput = { path: z.string(), total: z.number().int().nonnegative(), size: z.number().int().nonnegative(), cachedAtMs: z.number() } as const;
  • Registration of the csb_read_card_index tool using server.registerTool, specifying title, description, outputSchema, and inline handler.
    server.registerTool( "csb_read_card_index", { title: "CSB: Read card index", description: "Read oracleId→CSB id index from local cache.", outputSchema: csbReadIndexOutput }, async () => { const cachePath = process.env.CSB_CARD_INDEX_PATH || require('node:path').join(process.cwd(), 'cache', 'csb-card-index.json'); const disk = await readCsbIndex(cachePath); if (!disk) return { content: [{ type: "text", text: "No CSB card index cache found" }] } as any; const size = Object.keys(disk.data.oracleToId || {}).length; return { structuredContent: { path: cachePath, total: disk.data.total, size, cachedAtMs: disk.at } } as any; } );
  • Helper function readCsbIndex that reads and parses the CSB card index JSON file from disk, returning data and modification time or null if failed.
    export async function readCsbIndex(cachePath = DEFAULT_CACHE_PATH): Promise<{ data: CsbCardIndex; at: number } | null> { try { const [buf, st] = await Promise.all([readFile(cachePath, "utf8"), stat(cachePath)]); const data = JSON.parse(buf) as CsbCardIndex; return { data, at: st.mtimeMs }; } catch { return null; } }
  • Type definition for CsbCardIndex used in the tool's output and helpers.
    export type CsbCardIndex = { builtAtMs: number; total: number; oracleToId: Record<string, number>; };

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