get_conversations
Retrieve AI conversations for a project with filters for conversation type, related task or document, and message content inclusion.
Instructions
Retrieve AI conversations for a project with optional filtering
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | The project ID to get conversations for | |
| limit | No | Maximum number of conversations to return | |
| conversation_type | No | Filter by conversation type | |
| related_to | No | Filter by related task or document ID | |
| include_messages | No | Whether to include full message content |
Implementation Reference
- src/tools/ai-conversations.ts:251-287 (handler)The main handler function for the 'get_conversations' tool. Validates inputs via GetConversationsSchema, calls getConversationsFromDatabase, computes analytics (conversation types, total messages, average length, recent activity), and returns the conversations along with analytics and applied filters.
export const getConversations = requireAuth(async (args: any) => { const { project_id, limit, conversation_type, related_to, include_messages } = GetConversationsSchema.parse(args) logger.info('Getting conversations', { project_id, conversation_type, related_to, limit }) // Get conversations from database const conversations = await getConversationsFromDatabase({ project_id, limit, conversation_type, related_to, include_messages }) // Add analytics const analytics = { total_conversations: conversations.length, conversation_types: conversations.reduce((acc, conv) => { const type = conv.metadata?.context?.conversation_type || 'general' acc[type] = (acc[type] || 0) + 1 return acc }, {} as Record<string, number>), total_messages: conversations.reduce((sum, conv) => sum + (conv.metadata?.message_count || 0), 0), average_length: conversations.length > 0 ? conversations.reduce((sum, conv) => sum + (conv.metadata?.message_count || 0), 0) / conversations.length : 0, recent_activity: conversations.filter(conv => new Date(conv.created_at).getTime() > Date.now() - (7 * 24 * 60 * 60 * 1000) ).length } return { conversations, analytics, filters_applied: { conversation_type, related_to } } }) - src/tools/ai-conversations.ts:40-46 (schema)Zod schema definition for the get_conversations tool inputs. Validates project_id (UUID), limit (1-100, default 20), conversation_type (enum), related_to (UUID), and include_messages (boolean, default true).
const GetConversationsSchema = z.object({ project_id: z.string().uuid(), limit: z.number().int().positive().max(100).default(20), conversation_type: z.enum(['task_discussion', 'document_review', 'project_planning', 'troubleshooting', 'general']).optional(), related_to: z.string().uuid().optional(), // task_id or document_id include_messages: z.boolean().default(true) }) - src/tools/ai-conversations.ts:213-249 (registration)MCPTool definition (tool registration object) with name 'get_conversations', description, and JSON Schema inputSchema matching the Zod schema. Exported as part of conversationTools and conversationHandlers.
export const getConversationsTool: MCPTool = { name: 'get_conversations', description: 'Retrieve AI conversations for a project with optional filtering', inputSchema: { type: 'object', properties: { project_id: { type: 'string', format: 'uuid', description: 'The project ID to get conversations for' }, limit: { type: 'number', minimum: 1, maximum: 100, default: 20, description: 'Maximum number of conversations to return' }, conversation_type: { type: 'string', enum: ['task_discussion', 'document_review', 'project_planning', 'troubleshooting', 'general'], description: 'Filter by conversation type' }, related_to: { type: 'string', format: 'uuid', description: 'Filter by related task or document ID' }, include_messages: { type: 'boolean', default: true, description: 'Whether to include full message content' } }, required: ['project_id'] } } - src/tools/ai-conversations.ts:851-857 (registration)Export map that registers the handler function under the key 'get_conversations' in conversationHandlers, which is then spread into allHandlers in src/index.ts.
export const conversationHandlers = { save_conversation: saveConversation, get_conversations: getConversations, analyze_conversation: analyzeConversation, extract_action_items: extractActionItems, generate_conversation_summary: generateConversationSummary } - Database helper function (placeholder) that receives filters (project_id, limit, conversation_type, related_to, include_messages) and returns conversation data. Currently returns an empty array; intended to be implemented in the supabase service.
async function getConversationsFromDatabase(filters: any): Promise<any[]> { // This would be implemented in the supabase service return [] }