random_card
Retrieve a random Magic: The Gathering card with JSON data using the Scryfall API. Simplify access to card details for integration or exploration purposes.
Instructions
Retrieve a random Magic card from Scryfall. Returns JSON data for that random card.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.ts:265-269 (handler)The handler function that implements the random_card tool by fetching a random card from the Scryfall API endpoint and returning the processed response.async function handleRandomCard() { const url = "https://api.scryfall.com/cards/random"; const response = await fetch(url); return handleScryfallResponse(response); }
- index.ts:124-133 (schema)The schema definition for the random_card tool, specifying name, description, and empty input schema (no parameters required).const RANDOM_CARD_TOOL: Tool = { name: "random_card", description: "Retrieve a random Magic card from Scryfall. Returns JSON data for that random card.", inputSchema: { type: "object", properties: {}, required: [] } };
- index.ts:186-194 (registration)Registration of the random_card tool (RANDOM_CARD_TOOL) in the array of all available tools, returned by the listTools handler.const SCRYFALL_TOOLS = [ SEARCH_CARDS_TOOL, GET_CARD_BY_ID_TOOL, GET_CARD_BY_NAME_TOOL, RANDOM_CARD_TOOL, GET_RULINGS_TOOL, GET_PRICES_BY_ID_TOOL, GET_PRICES_BY_NAME_TOOL ] as const;
- index.ts:386-388 (registration)Dispatch/registration of the random_card tool in the switch statement of the CallToolRequestHandler, routing to the handleRandomCard function.case "random_card": { return await handleRandomCard(); }