Skip to main content
Glama

get_format_staples

Retrieve staple cards and popular archetypes for any Magic: The Gathering format. Optionally filter by archetype to see meta-defining cards for specific deck types.

Instructions

Get staple cards and popular archetypes for a specific format (Commander, Modern, Legacy, etc.). Use this when a user asks about the meta, popular decks, or key cards in a format. Optionally filter by archetype.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatYesFormat to get staples for (e.g. "commander", "modern", "legacy")
archetypeNoOptional archetype filter (e.g. "aggro-red", "control-uw")

Implementation Reference

  • Main handler function that executes the 'get_format_staples' tool logic. Looks up format info, finds relevant archetypes, collects staple cards, and returns a FormatStaplesResult.
    export function handler(_db: Database.Database, params: GetFormatStaplesParams): FormatStaplesResult {
      const formatLower = params.format.toLowerCase();
    
      // 1. Find format info
      const formatInfo = FORMATS.find(f =>
        f.id === formatLower || f.name.toLowerCase() === formatLower
      );
    
      // 2. If format is commander, include commander strategies
      const isCommander = formatLower === 'commander' || formatLower === 'edh';
    
      // 3. Find relevant archetypes
      let archetypes: Archetype[];
      if (params.archetype) {
        const arch = ARCHETYPES.find(a =>
          a.id === params.archetype!.toLowerCase() ||
          a.name.toLowerCase() === params.archetype!.toLowerCase()
        );
        archetypes = arch ? [arch] : [];
      } else {
        archetypes = ARCHETYPES.filter(a =>
          a.formatPresence.some(f => f.toLowerCase() === formatLower)
        );
      }
    
      // 4. Collect staple cards
      const stapleSet = new Set<string>();
    
      // From archetypes
      for (const arch of archetypes) {
        for (const card of arch.exampleCards) {
          stapleSet.add(card);
        }
      }
    
      // From commander strategies if format is commander
      if (isCommander) {
        let strategies: CommanderStrategy[];
        if (params.archetype) {
          const strat = COMMANDER_STRATEGIES.find(s =>
            s.id === params.archetype!.toLowerCase() ||
            s.name.toLowerCase() === params.archetype!.toLowerCase()
          );
          strategies = strat ? [strat] : [];
    
          // If we found a commander strategy, use it even if no archetype matched
          if (strategies.length > 0 && archetypes.length === 0) {
            // Commander strategies are valid archetype sources too
          }
        } else {
          strategies = [...COMMANDER_STRATEGIES];
        }
    
        for (const strat of strategies) {
          for (const card of strat.stapleCards) {
            stapleSet.add(card);
          }
        }
      }
    
      // Build archetype output — include commander strategies as pseudo-archetypes
      const archetypeOutput: Array<{ id: string; name: string; example_cards: string[] }> = [];
    
      for (const arch of archetypes) {
        archetypeOutput.push({
          id: arch.id,
          name: arch.name,
          example_cards: [...arch.exampleCards],
        });
      }
    
      if (isCommander) {
        let strategies: CommanderStrategy[];
        if (params.archetype) {
          const strat = COMMANDER_STRATEGIES.find(s =>
            s.id === params.archetype!.toLowerCase() ||
            s.name.toLowerCase() === params.archetype!.toLowerCase()
          );
          strategies = strat ? [strat] : [];
        } else {
          strategies = [...COMMANDER_STRATEGIES];
        }
    
        for (const strat of strategies) {
          archetypeOutput.push({
            id: strat.id,
            name: strat.name,
            example_cards: [...strat.stapleCards],
          });
        }
      }
    
      return {
        format: params.format,
        format_info: formatInfo
          ? {
              name: formatInfo.name,
              description: formatInfo.description,
              power_level: formatInfo.powerLevel,
            }
          : null,
        archetype_filter: params.archetype ?? null,
        staple_cards: [...stapleSet],
        archetypes: archetypeOutput,
      };
    }
  • Input schema using Zod: validates 'format' (string, required) and 'archetype' (string, optional).
    export const GetFormatStaplesInput = z.object({
      format: z.string().describe('Format to get staples for (e.g. "commander", "modern", "legacy")'),
      archetype: z.string().optional().describe('Optional archetype filter (e.g. "aggro-red", "control-uw")'),
    });
    
    export type GetFormatStaplesParams = z.infer<typeof GetFormatStaplesInput>;
  • Output type interface 'FormatStaplesResult' defining the shape of the returned data (format info, staple cards, archetypes).
    export interface FormatStaplesResult {
      format: string;
      format_info: {
        name: string;
        description: string;
        power_level: number;
      } | null;
      archetype_filter: string | null;
      staple_cards: string[];
      archetypes: Array<{
        id: string;
        name: string;
        example_cards: string[];
      }>;
    }
  • src/server.ts:237-249 (registration)
    Registration of the 'get_format_staples' tool with the MCP server, wiring up the schema, handler, and formatter.
    server.tool(
      'get_format_staples',
      'Get staple cards and popular archetypes for a specific format (Commander, Modern, Legacy, etc.). Use this when a user asks about the meta, popular decks, or key cards in a format. Optionally filter by archetype.',
      GetFormatStaplesInput.shape,
      async (params) => {
        try {
          const result = getFormatStaplesHandler(db, params);
          return { content: [{ type: 'text' as const, text: formatGetFormatStaples(result) }] };
        } catch (err) {
          return { content: [{ type: 'text' as const, text: `Error getting format staples: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
        }
      },
    );
  • Formatting function that converts the FormatStaplesResult into a human-readable string for the response.
    export function formatGetFormatStaples(result: FormatStaplesResult): string {
      const lines: string[] = [];
    
      const title = result.archetype_filter
        ? `# ${capitalize(result.format)} Staples — ${result.archetype_filter}`
        : `# ${capitalize(result.format)} Staples`;
      lines.push(title);
    
      if (result.format_info) {
        lines.push(`${result.format_info.description}`);
        lines.push(`Power Level: ${result.format_info.power_level}/10`);
      }
    
      if (result.staple_cards.length > 0) {
        lines.push(`\n## Key Cards (${result.staple_cards.length})`);
        lines.push(result.staple_cards.map(c => `- ${c}`).join('\n'));
      }
    
      if (result.archetypes.length > 0) {
        lines.push('\n## Archetypes');
        for (const arch of result.archetypes) {
          lines.push(`\n### ${arch.name}`);
          if (arch.example_cards.length > 0) {
            lines.push(arch.example_cards.map(c => `- ${c}`).join('\n'));
          }
        }
      }
    
      return lines.join('\n');
    }
Behavior3/5

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

No annotations are provided, so the description carries the burden. It implies a read operation but does not disclose any potential behaviors such as error handling, rate limits, or data freshness. Adequate but not detailed.

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, no redundancy, front-loaded with the core action. Every word serves a purpose.

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?

For a simple retrieval tool with two well-described parameters and no output schema, the description covers the essential purpose and usage context. It could mention the return format, but this is not critical given the tool's straightforward nature.

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%, and the description adds minimal additional meaning beyond the schema, only noting that the archetype filter is optional. Baseline score of 3 applies.

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 tool retrieves staple cards and popular archetypes for a format, with examples of formats. It does not explicitly differentiate from sibling tools, but the purpose is distinct enough given the sibling names.

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 states when to use: 'when a user asks about the meta, popular decks, or key cards in a format.' No alternatives or when-not-to-use are given, but the context is clear.

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/gregario/mtg-oracle'

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