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

random_card

Fetch a random Magic: The Gathering card from Scryfall's database, with optional search filters to narrow results.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qNo

Implementation Reference

  • Executes the random_card tool by calling Scryfall.getRandomCard with optional query 'q' and returns the result formatted as MCP ToolResult 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;
    }
  • Registers the 'random_card' tool with the MCP server, specifying description, input schema, and handler function.
    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;
        }
    );
  • Defines the Zod input schema for the random_card tool: optional 'q' string for filtering the random card.
    const randomCardParamsShape = { q: z.string().optional() } as const;
  • Helper method in Scryfall class that performs the API call to /cards/random endpoint with optional query parameter.
    getRandomCard: (q?: string) => getJson("/cards/random", q ? { q } : undefined),
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 fetching a random card with optional search filtering, but fails to describe key behaviors such as how randomness is determined, whether results are paginated or single, error handling, or any rate limits. This leaves significant gaps in understanding the tool's operation.

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 front-loads the core purpose ('fetch a random card') and adds necessary detail about the optional filter. There is no wasted language, making it highly concise and well-structured for quick comprehension.

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

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a random fetch operation with filtering, no annotations, and no output schema, the description is incomplete. It doesn't explain what a 'card' entails in this context, the return format, or how the randomness interacts with the query, making it inadequate for full understanding without additional context.

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 input schema has 1 parameter with 0% description coverage, so the description must compensate. It adds meaning by explaining that 'q' is an optional search query for filtering, which clarifies its purpose beyond the schema. However, it doesn't detail the query format, syntax, or examples, leaving some ambiguity.

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 ('fetch') and resource ('a random card'), making the purpose immediately understandable. It distinguishes itself from most siblings by focusing on randomness rather than specific lookup or search operations, though it doesn't explicitly contrast with tools like 'get_card' or 'search_cards'.

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

Usage Guidelines3/5

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

The description implies usage through the phrase 'optionally filtered by a 'q' search query,' suggesting this tool is for obtaining random cards with possible filtering. However, it lacks explicit guidance on when to use this versus alternatives like 'get_card' for specific cards or 'search_cards' for broader searches, leaving the context somewhat vague.

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