Skip to main content
Glama
jakedx6
by jakedx6

save_conversation

Store AI conversations with project context for future reference and analysis within Helios-9 MCP Server projects.

Instructions

Save an AI conversation with project context for future reference and analysis

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesThe project ID this conversation relates to
titleNoOptional title for the conversation (auto-generated if not provided)
messagesYesArray of conversation messages
contextNoContext information about the conversation
metadataNoAdditional metadata for the conversation

Implementation Reference

  • Main handler function for save_conversation tool. Validates input, processes messages, generates title/analysis/action items, saves to database, and returns results.
    export const saveConversation = requireAuth(async (args: any) => { const { project_id, title, messages, context, metadata } = SaveConversationSchema.parse(args) logger.info('Saving AI conversation', { project_id, message_count: messages.length, conversation_type: context?.conversation_type }) // Process messages and add timestamps if missing const processedMessages = messages.map(msg => ({ ...msg, timestamp: msg.timestamp || new Date().toISOString(), metadata: msg.metadata || {} })) // Generate title if not provided const conversationTitle = title || generateConversationTitle(processedMessages, context?.conversation_type) // Analyze conversation for insights const analysis = analyzeConversationContent(processedMessages) // Create conversation record const conversationData = { project_id, title: conversationTitle, messages: processedMessages, metadata: { ...metadata, context: context || {}, analysis, created_via: 'mcp', message_count: processedMessages.length, total_tokens: context?.tokens_used || estimateTokenCount(processedMessages) } } // Save to database (extend the supabase service to handle conversations) const conversation = await saveConversationToDatabase(conversationData) // Extract and optionally create action items const actionItems = extractActionItemsFromConversation(processedMessages, context) logger.info('Conversation saved successfully', { conversation_id: conversation.id, action_items_found: actionItems.length }) return { conversation, analysis, action_items: actionItems, insights: generateConversationInsights(analysis, context), message: `Conversation "${conversationTitle}" saved successfully` } })
  • Zod input validation schema for the save_conversation tool parameters.
    const SaveConversationSchema = z.object({ project_id: z.string().uuid(), title: z.string().min(1).max(500).optional(), messages: z.array(z.object({ role: z.enum(['user', 'assistant', 'system']), content: z.string(), timestamp: z.string().datetime().optional(), metadata: z.record(z.any()).optional() })), context: z.object({ task_id: z.string().uuid().optional(), document_id: z.string().uuid().optional(), conversation_type: z.enum(['task_discussion', 'document_review', 'project_planning', 'troubleshooting', 'general']).default('general'), ai_model: z.string().optional(), temperature: z.number().min(0).max(2).optional(), tokens_used: z.number().positive().optional() }).optional(), metadata: z.record(z.any()).optional() })
  • MCPTool registration object defining name, description, and inputSchema for save_conversation.
    export const saveConversationTool: MCPTool = { name: 'save_conversation', description: 'Save an AI conversation with project context for future reference and analysis', inputSchema: { type: 'object', properties: { project_id: { type: 'string', format: 'uuid', description: 'The project ID this conversation relates to' }, title: { type: 'string', maxLength: 500, description: 'Optional title for the conversation (auto-generated if not provided)' }, messages: { type: 'array', items: { type: 'object', properties: { role: { type: 'string', enum: ['user', 'assistant', 'system'], description: 'The role of the message sender' }, content: { type: 'string', description: 'The message content' }, timestamp: { type: 'string', format: 'date-time', description: 'When the message was sent (auto-generated if not provided)' }, metadata: { type: 'object', description: 'Additional metadata for the message' } }, required: ['role', 'content'] }, description: 'Array of conversation messages' }, context: { type: 'object', properties: { task_id: { type: 'string', format: 'uuid', description: 'Related task ID if conversation is about a specific task' }, document_id: { type: 'string', format: 'uuid', description: 'Related document ID if conversation is about a specific document' }, conversation_type: { type: 'string', enum: ['task_discussion', 'document_review', 'project_planning', 'troubleshooting', 'general'], description: 'Type of conversation for better categorization' }, ai_model: { type: 'string', description: 'AI model used in the conversation' }, temperature: { type: 'number', minimum: 0, maximum: 2, description: 'AI temperature setting used' }, tokens_used: { type: 'number', description: 'Total tokens consumed in the conversation' } }, description: 'Context information about the conversation' }, metadata: { type: 'object', description: 'Additional metadata for the conversation' } }, required: ['project_id', 'messages'] } }
  • Helper function called by the handler to persist the conversation data to the database (placeholder implementation).
    async function saveConversationToDatabase(conversationData: any): Promise<any> { // This would be implemented in the supabase service return { id: 'generated-uuid', ...conversationData, created_at: new Date().toISOString(), updated_at: new Date().toISOString() } }
  • Export mapping tool names to their handler functions, including save_conversation.
    export const conversationHandlers = { save_conversation: saveConversation, get_conversations: getConversations, analyze_conversation: analyzeConversation, extract_action_items: extractActionItems, generate_conversation_summary: generateConversationSummary

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jakedx6/helios9-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server