auto_match
Find relevant experts for your questions by analyzing topics and matching to legends with appropriate expertise, returning key insights and suggested next steps.
Instructions
Automatically find the most relevant legends for your question.
How it works:
Analyzes your question for topics and keywords
Matches relevant legends based on their expertise
Returns matched legends with key insights
Use this when:
You're not sure which legend to ask
You want to see who has expertise in your topic
You want quick insights before a full conversation
What you get:
Top 2-3 most relevant legends
Why each was matched
A key insight from each
Suggested next steps
Examples:
"How do I raise money for my startup?" → Paul Graham, Marc Andreessen
"What's the future of AI?" → Sam Altman, Jensen Huang
"How should I think about risk?" → Ray Dalio, Howard Marks
DISCLAIMER: AI personas for educational purposes only.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| question | Yes | Your question or topic to find relevant legends for | |
| max_matches | No | Maximum legends to match (default: 2, max: 3) | |
| include_prompts | No | Include full system prompts for each legend (default: false) |
Implementation Reference
- src/tools/auto-match.ts:163-204 (handler)Core handler function that analyzes the question, matches relevant legends using keyword expertise mapping, loads legend data, extracts key insights, generates suggested approach, and returns structured AutoMatchResponse.export function autoMatch(input: AutoMatchInput): AutoMatchResponse { const { sanitized: question } = sanitizeContext(input.question); const maxMatches = Math.min(input.max_matches || 2, 3); const includePrompts = input.include_prompts || false; // Find matching legends const matches = findMatches(question, maxMatches); // Build response const matchedLegends: MatchedLegend[] = matches.map(match => { const legend = getLegendById(match.legendId); if (!legend) return null; const result: MatchedLegend = { legend_id: legend.id, name: legend.name, relevance_reason: match.reason, expertise_match: match.matchedExpertise, key_insight: extractKeyInsight(legend), }; if (includePrompts) { result.system_prompt = buildLegendSystemPrompt(legend); } return result; }).filter((m): m is MatchedLegend => m !== null); if (matchedLegends.length === 0) { throw new Error('No matching legends found. Try rephrasing your question.'); } // Generate suggested approach const legendNames = matchedLegends.map(m => m.name); const suggestedApproach = generateApproach(question, matchedLegends); return { question: escapeBackticks(question), matches: matchedLegends, suggested_approach: suggestedApproach, }; }
- src/tools/auto-match.ts:272-316 (schema)MCP tool definition including name, detailed description, and inputSchema for validation (question required, optional max_matches and include_prompts). Includes TypeScript interfaces for input/output.export const autoMatchTool = { name: 'auto_match', description: `Automatically find the most relevant legends for your question. **How it works:** 1. Analyzes your question for topics and keywords 2. Matches relevant legends based on their expertise 3. Returns matched legends with key insights **Use this when:** - You're not sure which legend to ask - You want to see who has expertise in your topic - You want quick insights before a full conversation **What you get:** - Top 2-3 most relevant legends - Why each was matched - A key insight from each - Suggested next steps **Examples:** - "How do I raise money for my startup?" → Paul Graham, Marc Andreessen - "What's the future of AI?" → Sam Altman, Jensen Huang - "How should I think about risk?" → Ray Dalio, Howard Marks DISCLAIMER: AI personas for educational purposes only.`, inputSchema: { type: 'object' as const, properties: { question: { type: 'string', description: 'Your question or topic to find relevant legends for', }, max_matches: { type: 'number', description: 'Maximum legends to match (default: 2, max: 3)', }, include_prompts: { type: 'boolean', description: 'Include full system prompts for each legend (default: false)', }, }, required: ['question'], }, };
- src/tools/index.ts:19-31 (registration)Registration of auto_match tool: imported as autoMatchTool and added to the allTools array exported for MCP ListTools handler.import { autoMatchTool } from './auto-match.js'; import { suggestTool } from './suggest.js'; export const allTools = [ suggestTool, // First! Claude should see this first for proactive use listLegendsTool, summonLegendTool, getLegendContextTool, getLegendInsightTool, searchLegendsTool, partyModeTool, autoMatchTool, ];
- src/index.ts:225-257 (registration)MCP CallTool dispatch handler for 'auto_match': validates input, calls autoMatch handler, formats output with formatAutoMatch, and returns MCP content response.case 'auto_match': { const input = args as { question: string; max_matches?: number; include_prompts?: boolean; }; if (!input.question) { return { content: [{ type: 'text', text: 'Error: question parameter is required' }], isError: true, }; } try { const result = autoMatch(input); const formatted = formatAutoMatch(result); return { content: [{ type: 'text', text: formatted }], }; } catch (error) { return { content: [ { type: 'text', text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/tools/auto-match.ts:223-269 (helper)Helper function to format the AutoMatchResponse into a user-friendly Markdown display including question, matched legends details, suggested approach, and next steps.export function formatAutoMatch(response: AutoMatchResponse): string { const lines: string[] = [ '# Auto-Matched Legends', '', `**Your Question:** ${response.question}`, '', '---', '', '## Best Matches', '', ]; response.matches.forEach((match, i) => { lines.push(`### ${i + 1}. ${match.name}`); lines.push(`- **Why matched:** ${match.relevance_reason}`); lines.push(`- **Expertise:** ${match.expertise_match.join(', ')}`); lines.push(`- **Key insight:** "${escapeBackticks(match.key_insight)}"`); if (match.system_prompt) { lines.push(''); lines.push('<details>'); lines.push('<summary>Full System Prompt</summary>'); lines.push(''); lines.push('```'); lines.push(escapeBackticks(match.system_prompt)); lines.push('```'); lines.push('</details>'); } lines.push(''); }); lines.push('---'); lines.push(''); lines.push('## Suggested Approach'); lines.push(''); lines.push(response.suggested_approach); lines.push(''); lines.push('---'); lines.push(''); lines.push('**Next Steps:**'); lines.push('- Use `summon_legend` to get advice from a specific legend'); lines.push('- Use `party_mode` to have all matched legends discuss together'); lines.push(''); lines.push('*DISCLAIMER: AI personas for educational purposes. Not affiliated with real individuals.*'); return lines.join('\n'); }