save_conversation_context
Store conversation context with session tracking and continuation support to maintain persistent dialogue history across interactions.
Instructions
Save conversation context with continuation support
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Unique identifier for the context | |
| sessionId | Yes | Conversation session identifier | |
| content | Yes | Context content to save | |
| continuationOf | No | Optional ID of previous context | |
| tags | No | Optional tags for categorizing | |
| metadata | No | Optional additional metadata |
Implementation Reference
- src/index.ts:215-249 (registration)Registration of the 'save_conversation_context' tool including name, description, and input schema in the ListTools response.{ name: 'save_conversation_context', description: 'Save conversation context with continuation support', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Unique identifier for the context', }, sessionId: { type: 'string', description: 'Conversation session identifier', }, content: { type: 'string', description: 'Context content to save', }, continuationOf: { type: 'string', description: 'Optional ID of previous context', }, tags: { type: 'array', items: { type: 'string' }, description: 'Optional tags for categorizing', }, metadata: { type: 'object', description: 'Optional additional metadata', }, }, required: ['id', 'sessionId', 'content'], }, },
- src/index.ts:336-372 (handler)Handler logic for executing the save_conversation_context tool: destructures input arguments, builds ConversationContext object, calls saveContext helper, returns success text response.case 'save_conversation_context': { const { id, sessionId, content, continuationOf, tags, metadata, } = request.params.arguments as { id: string; sessionId: string; content: string; continuationOf?: string; tags?: string[]; metadata?: Record<string, unknown>; }; const context: ConversationContext = { id, sessionId, content, timestamp: new Date().toISOString(), continuationOf, tags, metadata, }; await this.saveContext(context); return { content: [ { type: 'text', text: `Conversation context saved with ID: ${id}`, }, ], }; }
- src/index.ts:218-248 (schema)JSON schema defining the input parameters for the save_conversation_context tool.inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Unique identifier for the context', }, sessionId: { type: 'string', description: 'Conversation session identifier', }, content: { type: 'string', description: 'Context content to save', }, continuationOf: { type: 'string', description: 'Optional ID of previous context', }, tags: { type: 'array', items: { type: 'string' }, description: 'Optional tags for categorizing', }, metadata: { type: 'object', description: 'Optional additional metadata', }, }, required: ['id', 'sessionId', 'content'], },
- src/index.ts:103-112 (helper)Core helper method that persists the context to a JSON file in the appropriate directory and updates the global index.private async saveContext(context: Context) { await this.ensureDirectories(); const contextPath = await this.getContextPath( context.id, 'projectId' in context ? context.projectId : undefined ); await fs.writeFile(contextPath, JSON.stringify(context, null, 2), 'utf-8'); await this.updateIndex(context); }