Skip to main content
Glama

analyze_commander

Analyze legendary creatures as potential Commanders to identify 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

  • The implementation of the 'analyze_commander' tool handler, which queries the database for a legendary creature card, verifies it, and calculates strategies, archetypes, and recommended deck categories.
    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 };
    }
  • The Zod input schema for the 'analyze_commander' tool.
    export const AnalyzeCommanderInput = z.object({
      name: z.string().describe('Commander card name to analyze'),
    });
  • src/server.ts:207-213 (registration)
    Registration of the 'analyze_commander' tool in the MCP server.
    '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) }] };

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