analyze_conversation
Extract insights, themes, and patterns from AI conversations to identify key information and trends.
Instructions
Analyze an AI conversation to extract insights, themes, and patterns
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| conversation_id | Yes | The conversation ID to analyze |
Implementation Reference
- src/tools/ai-conversations.ts:308-337 (handler)Primary handler function that executes the analyze_conversation tool logic: validates input, fetches conversation data, runs multiple analysis helpers, and returns comprehensive insights.export const analyzeConversation = requireAuth(async (args: any) => { const { conversation_id } = AnalyzeConversationSchema.parse(args) logger.info('Analyzing conversation', { conversation_id }) const conversation = await getConversationFromDatabase(conversation_id) if (!conversation) { throw new Error('Conversation not found') } const analysis = { conversation_flow: analyzeConversationFlow(conversation.messages), content_analysis: analyzeConversationContent(conversation.messages), ai_performance: analyzeAIPerformance(conversation.messages), topic_modeling: extractTopicsAndThemes(conversation.messages), action_items: extractActionItemsFromConversation(conversation.messages, conversation.metadata?.context), decisions_made: extractDecisions(conversation.messages), questions_raised: extractQuestions(conversation.messages), knowledge_gaps: identifyKnowledgeGaps(conversation.messages), follow_up_suggestions: generateFollowUpSuggestions(conversation.messages, conversation.metadata?.context) } return { conversation_id, analysis, summary: generateAnalysisSummary(analysis), recommendations: generateRecommendations(analysis, conversation.metadata?.context) } })
- src/tools/ai-conversations.ts:48-50 (schema)Zod input validation schema for the analyze_conversation tool, requiring a single conversation_id parameter (UUID).const AnalyzeConversationSchema = z.object({ conversation_id: z.string().uuid() })
- src/tools/ai-conversations.ts:292-306 (registration)MCPTool object registration defining the tool's metadata, name, description, and input schema for protocol discovery.export const analyzeConversationTool: MCPTool = { name: 'analyze_conversation', description: 'Analyze an AI conversation to extract insights, themes, and patterns', inputSchema: { type: 'object', properties: { conversation_id: { type: 'string', format: 'uuid', description: 'The conversation ID to analyze' } }, required: ['conversation_id'] } }
- src/tools/ai-conversations.ts:851-856 (registration)Export of handler map including analyze_conversation, imported into main server and spread into allHandlers for dynamic tool dispatching.export const conversationHandlers = { save_conversation: saveConversation, get_conversations: getConversations, analyze_conversation: analyzeConversation, extract_action_items: extractActionItems, generate_conversation_summary: generateConversationSummary
- Key helper function called by the handler to analyze conversation content statistics (messages, words, questions, code, links, balance).function analyzeConversationContent(messages: Message[]): any { const totalMessages = messages.length const userMessages = messages.filter(m => m.role === 'user').length const assistantMessages = messages.filter(m => m.role === 'assistant').length const totalWords = messages.reduce((sum, msg) => sum + msg.content.split(' ').length, 0) const avgWordsPerMessage = totalWords / totalMessages // Extract common patterns const questions = messages.filter(msg => msg.content.includes('?')).length const codeBlocks = messages.filter(msg => msg.content.includes('```')).length const urls = messages.filter(msg => /https?:\/\//.test(msg.content)).length return { message_count: totalMessages, user_messages: userMessages, assistant_messages: assistantMessages, total_words: totalWords, avg_words_per_message: Math.round(avgWordsPerMessage), questions_asked: questions, code_examples: codeBlocks, external_links: urls, conversation_balance: userMessages / (assistantMessages || 1) } }