Skip to main content
Glama
cryppadotta

Scryfall MCP Server

by cryppadotta

search_cards

Search Magic: The Gathering cards using text queries to find specific cards by name, type, abilities, or other attributes. Returns matching cards with basic details like name, set, and collector number.

Instructions

Search for MTG cards by a text query, e.g. 'oracle text includes: draw cards'. Returns a list of matching cards (with basic fields: name, set, collector_number, ID). If no matches are found, returns an error message from Scryfall.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesA full text query, e.g. 't:goblin pow=2 o:haste'

Implementation Reference

  • The handler function that executes the search_cards tool by querying the Scryfall API search endpoint with the provided query string and processing the response.
    async function handleSearchCards(query: string) {
      const url = `https://api.scryfall.com/cards/search?q=${encodeURIComponent(
        query
      )}`;
      const response = await fetch(url);
      return handleScryfallResponse(response);
    }
  • Defines the input schema, name, and description for the search_cards tool.
    const SEARCH_CARDS_TOOL: Tool = {
      name: "search_cards",
      description:
        "Search for MTG cards by a text query, e.g. 'oracle text includes: draw cards'. " +
        "Returns a list of matching cards (with basic fields: name, set, collector_number, ID). " +
        "If no matches are found, returns an error message from Scryfall.",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "A full text query, e.g. 't:goblin pow=2 o:haste'"
          }
        },
        required: ["query"]
      }
    };
  • index.ts:186-194 (registration)
    Registers the search_cards tool (via SEARCH_CARDS_TOOL) in the list of available tools returned by listTools.
    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:374-377 (registration)
    Dispatches calls to the search_cards tool by extracting the query argument and invoking the handler function.
    case "search_cards": {
      const { query } = args as { query: string };
      return await handleSearchCards(query);
    }
  • Helper function used by the search_cards handler to process Scryfall API responses, handling errors and formatting successful JSON results.
    async function handleScryfallResponse(response: Response) {
      if (!response.ok) {
        // Attempt to parse Scryfall error
        let errorObj: ScryfallError | null = null;
        try {
          errorObj = (await response.json()) as ScryfallError;
        } catch {
          // fall back to generic
        }
        if (errorObj && errorObj.object === "error") {
          return {
            content: [
              {
                type: "text",
                text: `Scryfall error: ${errorObj.details} (code=${errorObj.code}, status=${errorObj.status})`
              }
            ],
            isError: true
          };
        } else {
          return {
            content: [
              {
                type: "text",
                text: `HTTP error ${response.status}: ${response.statusText}`
              }
            ],
            isError: true
          };
        }
      }
      // If okay, parse JSON
      const data = await response.json();
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(data, null, 2)
          }
        ],
        isError: false
      };
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it returns a list of matching cards with specified basic fields, and returns an error message from Scryfall if no matches are found. However, it does not cover other important aspects like rate limits, pagination, or authentication requirements, leaving gaps for a search tool.

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 front-loaded with the core purpose, followed by return details and error handling in two efficient sentences. Every sentence adds value without redundancy, making it appropriately sized and easy to parse for an AI agent.

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 (search with one parameter), no annotations, and no output schema, the description does well by specifying return fields and error behavior. However, it could improve by mentioning limitations (e.g., result limits) or linking to sibling tools for more specific queries, keeping it from a perfect score.

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?

Schema description coverage is 100%, so the schema already documents the single 'query' parameter with an example. The description adds marginal value by providing a different example ('oracle text includes: draw cards') that illustrates semantic usage, but does not significantly expand beyond what the schema provides. Baseline 3 is appropriate given high schema coverage.

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 ('Search for MTG cards by a text query'), identifies the resource ('MTG cards'), and distinguishes it from siblings like 'get_card_by_id' or 'get_card_by_name' by emphasizing text-based search rather than direct lookup. It provides concrete examples ('oracle text includes: draw cards') that reinforce the purpose.

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 implies usage context through the query example and mentions error handling for no matches, but does not explicitly state when to use this tool versus alternatives like 'get_card_by_name' for exact name matches or 'random_card' for non-search purposes. It provides clear operational context but lacks explicit sibling differentiation.

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/cryppadotta/scryfall-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server