Skip to main content
Glama

random_card

Fetch a random Magic: The Gathering card from Scryfall API, with optional search query filtering to narrow results.

Instructions

Fetch a random card, optionally filtered by a 'q' search query.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qNo

Implementation Reference

  • The handler function for the 'random_card' tool. It takes an optional query 'q', fetches a random card from Scryfall, and returns the JSON data as text content.
    async ({ q }: { q?: string }): Promise<ToolResult> => { const data: unknown = await Scryfall.getRandomCard(q); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] } as any; }
  • Input schema for the 'random_card' tool, defining an optional 'q' string parameter.
    const randomCardParamsShape = { q: z.string().optional() } as const;
  • Registers the 'random_card' tool with the MCP server, including name, description, input schema reference, and inline handler.
    server.registerTool( "random_card", { description: "Fetch a random card, optionally filtered by a 'q' search query.", inputSchema: randomCardParamsShape }, async ({ q }: { q?: string }): Promise<ToolResult> => { const data: unknown = await Scryfall.getRandomCard(q); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] } as any; } );
  • The Scryfall.getRandomCard utility function invoked by the tool handler, which calls the Scryfall /cards/random API endpoint.
    getRandomCard: (q?: string) => getJson("/cards/random", q ? { q } : undefined),

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