Skip to main content
Glama

get_format_staples

Retrieve staple cards and popular archetypes for Magic: The Gathering formats like Commander, Modern, or Legacy to analyze the meta and identify key deck components.

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

  • The handler function that implements the tool logic to fetch format staples and related archetypes/commander strategies.
    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 validation schema for the get_format_staples tool.
    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>;
  • src/server.ts:249-254 (registration)
    Tool registration and call site within the main server file.
    '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);

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