Skip to main content
Glama

analyze_commander

Analyze a legendary creature as a potential Commander, returning color identity, strategies, archetypes, and recommended card categories for deck building.

Instructions

Analyze a legendary creature as a potential Commander. Returns color identity, suggested strategies, archetypes, and recommended card categories for building a deck around this commander. Use this when a user wants help building or evaluating a Commander deck.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesCommander card name to analyze

Implementation Reference

  • Main handler function that looks up a card in the database, verifies it's a legendary creature, extracts color identity/keywords, checks for Partner, matches strategies by color identity, matches archetypes by oracle text/keywords, recommends card categories, and returns a structured CommanderAnalysis result.
    export function handler(db: Database.Database, params: AnalyzeCommanderParams): AnalyzeCommanderResult {
      // 1. Look up the card
      let card = db.prepare(
        'SELECT * FROM cards WHERE LOWER(name) = LOWER(?)'
      ).get(params.name) as CardRow | undefined;
    
      if (!card) {
        card = db.prepare(
          'SELECT * FROM cards WHERE LOWER(name) LIKE LOWER(?)'
        ).get(`%${params.name}%`) as CardRow | undefined;
      }
    
      if (!card) {
        return {
          found: false,
          message: `No card found matching "${params.name}"`,
        };
      }
    
      // 2. Verify it's a legendary creature
      const typeLine = card.type_line ?? '';
      if (!typeLine.toLowerCase().includes('legendary') || !typeLine.toLowerCase().includes('creature')) {
        return {
          found: false,
          message: `"${card.name}" is not a legendary creature (type: ${typeLine}). Only legendary creatures can be commanders.`,
        };
      }
    
      // 3. Extract data
      const colorIdentity: string[] = card.color_identity
        ? JSON.parse(card.color_identity) as string[]
        : [];
      const keywords: string[] = card.keywords
        ? JSON.parse(card.keywords) as string[]
        : [];
    
      // 4. Check for Partner
      const hasPartner = keywords.some(k =>
        k.toLowerCase() === 'partner' ||
        k.toLowerCase().startsWith('partner with')
      ) || (card.oracle_text ?? '').toLowerCase().includes('partner');
    
      // 5. Match strategies & archetypes
      const strategies = matchStrategies(colorIdentity);
      const archetypes = matchArchetypes(card.oracle_text, keywords, colorIdentity);
      const categories = recommendCategories(card.oracle_text, keywords, card.type_line);
    
      const analysis: CommanderAnalysis = {
        name: card.name,
        color_identity: colorIdentity,
        type_line: typeLine,
        oracle_text: card.oracle_text,
        edhrec_rank: card.edhrec_rank,
        has_partner: hasPartner,
        suggested_strategies: strategies.map(s => ({
          id: s.id,
          name: s.name,
          description: s.description,
          power_brackets: [...s.powerBrackets],
          staple_cards: [...s.stapleCards],
          key_synergies: [...s.keySynergies],
        })),
        suggested_archetypes: archetypes.map(a => ({
          id: a.id,
          name: a.name,
          description: a.description,
          key_mechanics: [...a.keyMechanics],
        })),
        recommended_categories: categories,
      };
    
      return { found: true, analysis };
    }
  • Input schema (Zod) accepting a commander name string, output types including CommanderAnalysis interface with strategies/archetypes/categories, and the discriminated union result type.
    export const AnalyzeCommanderInput = z.object({
      name: z.string().describe('Commander card name to analyze'),
    });
    
    export type AnalyzeCommanderParams = z.infer<typeof AnalyzeCommanderInput>;
    
    // --- Output types ---
    
    export interface CommanderAnalysis {
      name: string;
      color_identity: string[];
      type_line: string;
      oracle_text: string | null;
      edhrec_rank: number | null;
      has_partner: boolean;
      suggested_strategies: Array<{
        id: string;
        name: string;
        description: string;
        power_brackets: string[];
        staple_cards: string[];
        key_synergies: string[];
      }>;
      suggested_archetypes: Array<{
        id: string;
        name: string;
        description: string;
        key_mechanics: string[];
      }>;
      recommended_categories: string[];
    }
    
    export type AnalyzeCommanderResult =
      | { found: true; analysis: CommanderAnalysis }
      | { found: false; message: string };
  • src/server.ts:195-207 (registration)
    Registration of the 'analyze_commander' tool in the MCP server via server.tool(), linking the Zod input schema, the handler, and the formatter.
    server.tool(
      'analyze_commander',
      'Analyze a legendary creature as a potential Commander. Returns color identity, suggested strategies, archetypes, and recommended card categories for building a deck around this commander. Use this when a user wants help building or evaluating a Commander deck.',
      AnalyzeCommanderInput.shape,
      async (params) => {
        try {
          const result = analyzeCommanderHandler(db, params);
          return { content: [{ type: 'text' as const, text: formatAnalyzeCommander(result) }] };
        } catch (err) {
          return { content: [{ type: 'text' as const, text: `Error analyzing commander: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
        }
      },
    );
  • Helper to build a WUBRG color identity key string (e.g., 'WU', 'BRG') used for matching against commander strategies.
    function buildColorIdentityKey(colors: string[]): ColorIdentity {
      if (colors.length === 0) return 'colorless';
      const order = ['W', 'U', 'B', 'R', 'G'];
      const sorted = colors.slice().sort((a, b) => order.indexOf(a) - order.indexOf(b));
      return sorted.join('') as ColorIdentity;
    }
  • Helper that recommends card categories (e.g., Token Generators, Graveyard Recursion, Sacrifice Outlets) based on the commander's oracle text, keywords, and type line.
    function recommendCategories(
      oracleText: string | null,
      keywords: string[],
      typeLine: string | null,
    ): string[] {
      const categories: string[] = ['Ramp', 'Card Draw', 'Removal', 'Board Wipes'];
      const text = (oracleText ?? '').toLowerCase();
      const type = (typeLine ?? '').toLowerCase();
    
      if (text.includes('token') || text.includes('create')) categories.push('Token Generators');
      if (text.includes('counter') && !text.includes('counterspell')) categories.push('+1/+1 Counter Support');
      if (text.includes('graveyard') || text.includes('return from')) categories.push('Graveyard Recursion');
      if (text.includes('sacrifice') || text.includes('dies')) categories.push('Sacrifice Outlets');
      if (keywords.includes('Flying') || keywords.includes('Trample')) categories.push('Evasion');
      if (text.includes('equipment') || text.includes('equip')) categories.push('Equipment');
      if (text.includes('enchantment') || type.includes('enchantment')) categories.push('Enchantments');
      if (text.includes('artifact') || type.includes('artifact')) categories.push('Artifacts');
      if (text.includes('land') || text.includes('landfall')) categories.push('Lands Matter');
    
      return categories;
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It discloses the output type but does not mention any behavioral traits such as handling of invalid names, caching behavior, or prerequisites. For a tool that likely interacts with external data, more behavioral context (e.g., cases where the tool might fail) is missing.

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 consists of two concise sentences that front-load the purpose and usage. Every sentence adds value, with no redundancy or filler.

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 simplicity (single parameter, no output schema), the description adequately explains what it does and what it returns. It does not cover error cases or fallback behavior, but for a straightforward analysis tool, the level of detail is almost complete.

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 only parameter 'name' has a schema description 'Commander card name to analyze', which already covers its meaning. The description adds no additional semantics beyond what the schema provides. With 100% schema coverage, a 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?

The description clearly states the verb 'analyze' and the resource 'legendary creature as a potential Commander', and lists the returned information (color identity, strategies, archetypes, recommended card categories). It distinguishes from sibling tools like analyze_deck (whole deck) and find_synergies (specific card synergies).

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 explicitly states 'Use this when a user wants help building or evaluating a Commander deck', providing clear context for when to invoke. It does not enumerate when not to use or mention alternatives, but the specialized nature makes the guidance sufficient.

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