analyze_conversation
Extract insights, themes, and patterns from AI conversations to inform project decisions and identify trends.
Instructions
Analyze an AI conversation to extract insights, themes, and patterns
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"conversation_id": "<conversation_id>"
},
"name": "analyze_conversation"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| conversation_id | Yes | The conversation ID to analyze |
Implementation Reference
- src/tools/ai-conversations.ts:308-337 (handler)Main handler for the analyze_conversation tool. Parses conversation_id, fetches conversation from database, and runs analysis (flow, content, AI performance, topics, action items, decisions, questions, knowledge gaps, follow-ups).
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 schema for input validation - expects a single conversation_id as UUID string.
const AnalyzeConversationSchema = z.object({ conversation_id: z.string().uuid() }) - src/index.ts:143-155 (registration)Registers all handlers including conversationHandlers which maps 'analyze_conversation' to the analyzeConversation function.
this.allHandlers = { ...projectHandlers, ...taskHandlers, ...documentHandlers, ...conversationHandlers, ...contextAggregationHandlers, ...workflowAutomationHandlers, ...intelligentSearchHandlers, ...analyticsInsightsHandlers, ...initiativeHandlers, ...promptToProjectTools.reduce((acc, tool) => ({ ...acc, [tool.name]: tool.handler }), {}), ...debugHandlers, } - src/tools/ai-conversations.ts:292-306 (registration)Tool definition with name 'analyze_conversation', description, and input schema exposed via MCP.
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'] } } - Helper that analyzes message content statistics (counts, word counts, questions, code blocks, URLs, balance ratio).
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) } }