Skip to main content
Glama
matthewdtowles

iwantmymtg-mcp

search_cards

Search Magic: The Gathering cards by name, set, rarity, type, or format legality. Returns paginated results with prices and metadata.

Instructions

Search Magic: The Gathering cards by name (substring), set code, rarity, type, or format legality. Returns a paginated list with prices and basic metadata. Use this for catalog lookups; for a specific printing prefer get_card with set+number.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qNoSubstring to search card name + flavor name. Optional; omit to filter purely by setCode/rarity/type/format.
setCodeNo3-5 character set code (e.g. 'lea', 'mh3').
rarityNoFilter by rarity.
typeNoSubstring match against card type line (e.g. 'Goblin', 'Instant').
formatNoFilter to cards with a legality entry in this format (e.g. 'modern', 'commander').
legalityNoUsed with 'format'. Defaults to 'legal' when format is set.
pageNo1-based page index.
limitNoPage size (max 100).

Implementation Reference

  • The handler function that executes the search_cards tool logic. It calls the external API at /api/v1/cards passing all filter parameters as query string.
    export async function searchCards(input: Record<string, unknown>) {
      return apiFetch({
        path: "/api/v1/cards",
        query: input as Record<string, string | number | undefined>,
      });
    }
  • Input validation schema using Zod. Defines all search parameters: q (substring), setCode, rarity, type, format, legality, page, and limit.
    export const searchCardsInputSchema = {
      q: z
        .string()
        .optional()
        .describe("Substring to search card name + flavor name. Optional; omit to filter purely by setCode/rarity/type/format."),
      setCode: z.string().optional().describe("3-5 character set code (e.g. 'lea', 'mh3')."),
      rarity: z
        .enum(["common", "uncommon", "rare", "mythic"])
        .optional()
        .describe("Filter by rarity."),
      type: z
        .string()
        .optional()
        .describe("Substring match against card type line (e.g. 'Goblin', 'Instant')."),
      format: z
        .string()
        .optional()
        .describe("Filter to cards with a legality entry in this format (e.g. 'modern', 'commander')."),
      legality: z
        .enum(["legal", "banned", "restricted"])
        .optional()
        .describe("Used with 'format'. Defaults to 'legal' when format is set."),
      page: z.number().int().min(1).optional().describe("1-based page index."),
      limit: z.number().int().min(1).max(100).optional().describe("Page size (max 100)."),
    };
  • The tool definition/registration object with name 'search_cards', description, input schema, and handler reference.
    export const searchCardsTool = {
      name: "search_cards",
      description:
        "Search Magic: The Gathering cards by name (substring), set code, rarity, type, or format legality. Returns a paginated list with prices and basic metadata. Use this for catalog lookups; for a specific printing prefer get_card with set+number.",
      inputSchema: z.object(searchCardsInputSchema),
      handler: searchCards,
    };
  • Tool imported and included in the tools array (line 50) that is registered with the MCP server in src/server.ts.
    searchCardsTool,
Behavior3/5

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

No annotations provided, so description carries full burden. Mentions pagination and return of prices/metadata, but does not disclose rate limits or idle behavior. Acceptable for a read-only 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?

Two sentences: first enumerates filters and output, second provides usage guidance. Efficient and front-loaded with no redundant words.

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?

Lacks output schema but describes basic return structure. References sibling tool for specific needs. Adequate for a multi-filter search tool with 8 parameters.

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 coverage is 100% with descriptions. Description adds minimal value beyond schema (e.g., clarifying q as substring and optional). Baseline score of 3 is appropriate.

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?

Description clearly states the tool searches MTG cards by multiple filters and returns paginated results with prices and metadata. It also distinguishes from the sibling get_card tool, clarifying precise scope.

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?

Explicitly advises using this for catalog lookups and preferring get_card for specific printings. Provides clear context but could additionally exclude scenarios like returning all cards without filters.

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/matthewdtowles/iwantmymtg-mcp'

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