lspace_list_knowledge_base_history
Track and display all knowledge base changes, including file uploads and generation events, in a human-readable format. Filter by change type and limit results for precise insights.
Instructions
📜 HISTORY: List all changes made to the knowledge base in human-friendly format. Shows both file uploads and knowledge base generations separately. Example: repositoryId='b3fcb584-5fd9-4098-83b8-8c5d773d86eb'
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| changeType | No | Filter by type of change: 'file_upload', 'knowledge_base_generation', or 'both' | |
| limit | No | Maximum number of changes to return (default: 20) | |
| repositoryId | Yes | The ID of the Lspace repository. Use 'lspace_list_repositories' first to get repository IDs. |
Implementation Reference
- lspace-mcp-server.js:241-263 (registration)Tool registration entry defining name, description, and input schema{ name: "lspace_list_knowledge_base_history", description: "📜 HISTORY: List all changes made to the knowledge base in human-friendly format. Shows both file uploads and knowledge base generations separately. Example: repositoryId='b3fcb584-5fd9-4098-83b8-8c5d773d86eb'", inputSchema: { type: "object", properties: { repositoryId: { type: "string", description: "The ID of the Lspace repository. Use 'lspace_list_repositories' first to get repository IDs." }, limit: { type: "number", description: "Maximum number of changes to return (default: 20)" }, changeType: { type: "string", description: "Filter by type of change: 'file_upload', 'knowledge_base_generation', or 'both'", enum: ["file_upload", "knowledge_base_generation", "both"] } }, required: ["repositoryId"] } },
- lspace-mcp-server.js:868-908 (handler)MCP server handler for the tool: validates input, calls KnowledgeBaseHistoryService.listKnowledgeBaseChanges, formats response, handles errorscase 'lspace_list_knowledge_base_history': const { repositoryId: historyRepoId, limit: historyLimit, changeType } = args; if (!historyRepoId) { return { jsonrpc: "2.0", id, error: { code: -32000, message: `Missing required parameter: repositoryId. Use 'lspace_list_repositories' to get repository IDs.` } }; } try { const changes = await this.historyService.listKnowledgeBaseChanges(historyRepoId, { limit: historyLimit || 20, changeType: changeType || 'both' }); return { jsonrpc: "2.0", id, result: { content: [ { type: "text", text: this.formatHistoryResponse(changes, changeType || 'both') } ] } }; } catch (error) { return { jsonrpc: "2.0", id, error: { code: -32000, message: `Error retrieving history: ${error.message}` } }; }
- lspace-mcp-server.js:977-1004 (helper)Helper function to format history changes into human-readable text responseformatHistoryResponse(changes, changeType) { if (changes.length === 0) { return `No ${changeType === 'both' ? '' : changeType + ' '}changes found in the knowledge base history.`; } let response = `Knowledge Base History (${changes.length} change${changes.length === 1 ? '' : 's'}):\n\n`; changes.forEach((change, index) => { const typeIcon = change.changeType === 'file_upload' ? '📄' : '🧠'; const operationIcon = change.operation === 'added' ? '➕' : change.operation === 'updated' ? '✏️' : '🗑️'; response += `${index + 1}. ${typeIcon} ${operationIcon} ${change.description}\n`; response += ` ID: ${change.id}\n`; response += ` When: ${change.userFriendlyDate}\n`; response += ` Type: ${change.changeType.replace('_', ' ')}\n`; if (change.details?.user) response += ` User: ${change.details.user}\n`; if (change.filesAffected.length > 0) response += ` Files: ${change.filesAffected.join(', ')}\n`; response += '\n'; }); response += `💡 Use 'lspace_undo_knowledge_base_changes' to revert any of these changes.\n`; response += `📋 Refer to changes by their ID or use human-friendly commands like:\n`; response += ` • "undo changes for filename.txt"\n`; response += ` • "undo last 3 changes"\n`; response += ` • revertType options: 'file_upload', 'knowledge_base_generation', 'both'`; return response; }
- Core implementation: retrieves timeline history, converts to KnowledgeBaseChange objects distinguishing file uploads and KB generations, applies filtersasync listKnowledgeBaseChanges( repositoryId: string, options: { limit?: number; includeDetails?: boolean; changeType?: 'file_upload' | 'knowledge_base_generation' | 'both'; } = {} ): Promise<KnowledgeBaseChange[]> { const repository = this.repositoryManager.getRepository(repositoryId); const filterOptions: TimelineFilterOptions = { limit: options.limit || 20, offset: 0 }; const historyEntries = await this.timelineService.getDetailedHistoryEntries(repository, filterOptions); const changes = historyEntries.flatMap(entry => this.convertToKnowledgeBaseChanges(entry)); // Filter by change type if specified if (options.changeType && options.changeType !== 'both') { return changes.filter(change => change.changeType === options.changeType); } return changes; }
- Type definition for KnowledgeBaseChange used in history listingexport interface KnowledgeBaseChange { id: string; timestamp: string; description: string; // Human-friendly description operation: 'added' | 'updated' | 'removed' | 'organized'; changeType: 'file_upload' | 'knowledge_base_generation'; // Key distinction! filesAffected: string[]; userFriendlyDate: string; canRevert: boolean; internalCommitId: string; relatedCommitId?: string; // Links file upload to its KB generation details?: { title?: string; user?: string; category?: string; sourceFile?: string; // For KB changes, which file triggered them }; }