find_synergies
Discover synergy categories and complementary cards for Magic: The Gathering cards. Identifies archetypes like tokens or sacrifice and suggests cards that work well together.
Instructions
Find synergy categories and sample cards that work well with a specific card. Use this when a user wants to know what strategies or card types synergize with a particular card. Identifies matching archetypes (tokens, sacrifice, counters, etc.) and suggests complementary cards.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| card_name | Yes | Card name to find synergies for | |
| color_identity | No | Filter synergistic cards within this color identity | |
| format | No | Filter by format relevance | |
| category | No | Filter by specific synergy category ID | |
| limit | No | Max sample cards per category (default 5, max 50) |
Implementation Reference
- src/tools/find-synergies.ts:235-296 (handler)The `handler` function in `src/tools/find-synergies.ts` implements the logic for `find_synergies` by querying the card, matching it against synergy categories, and finding sample cards for those categories.
export function handler(db: Database.Database, params: FindSynergiesParams): FindSynergiesResult { const limit = params.limit ?? 5; // 1. Look up the card let card = db.prepare( 'SELECT * FROM cards WHERE LOWER(name) = LOWER(?)' ).get(params.card_name) as CardRow | undefined; if (!card) { card = db.prepare( 'SELECT * FROM cards WHERE LOWER(name) LIKE LOWER(?)' ).get(`%${params.card_name}%`) as CardRow | undefined; } if (!card) { return { card_name: params.card_name, creature_types: [], keywords: [], matching_categories: [], }; } // 2. Extract card data const keywords: string[] = card.keywords ? JSON.parse(card.keywords) as string[] : []; const creatureTypes = extractCreatureTypes(card.type_line); // 3. Match synergy categories const categoryMatches = matchSynergyCategories( card.oracle_text, keywords, creatureTypes, params.format, params.category, ); // 4. Build results with sample cards const matchingCategories: SynergyCategoryMatch[] = categoryMatches.map(match => { let sampleCards: string[]; if (match.category.id === 'tribal') { sampleCards = findTribalCards(db, creatureTypes, card!.name, params.color_identity, limit); } else { sampleCards = findCategoryCards(db, match.category, card!.name, params.color_identity, limit); } return { id: match.category.id, name: match.category.name, description: match.category.description, match_reason: match.reason, sample_cards: sampleCards, }; }); return { card_name: card.name, creature_types: creatureTypes, keywords, matching_categories: matchingCategories, }; } - src/tools/find-synergies.ts:11-17 (schema)Input schema definition for `find_synergies` using Zod.
export const FindSynergiesInput = z.object({ card_name: z.string().describe('Card name to find synergies for'), color_identity: z.array(z.string()).optional().describe('Filter synergistic cards within this color identity'), format: z.string().optional().describe('Filter by format relevance'), category: z.string().optional().describe('Filter by specific synergy category ID'), limit: z.number().min(1).max(50).optional().describe('Max sample cards per category (default 5, max 50)'), });