clear_data
Remove stored files, vector memory, or all data from the RAG system to free storage space or reset the knowledge base.
Instructions
Clear data from the RAG system
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | Type of data to clear |
Input Schema (JSON Schema)
{
"properties": {
"type": {
"description": "Type of data to clear",
"enum": [
"files",
"memory",
"all"
],
"type": "string"
}
},
"required": [
"type"
],
"type": "object"
}
Implementation Reference
- src/index.ts:470-479 (handler)MCP tool handler for 'clear_data': delegates to ragService.clearData and formats the response as MCP content.private async handleClearData(args: { type: 'files' | 'memory' | 'all' }) { const result = await this.ragService.clearData(args.type); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], };
- src/services/ragService.ts:235-260 (helper)Core implementation of clearData: clears vector database collections for files and/or memory based on type.async clearData(type: 'files' | 'memory' | 'all'): Promise<{ success: boolean; message: string; }> { try { if (type === 'files' || type === 'all') { await this.vectorDatabase.clearCollection('files'); } if (type === 'memory' || type === 'all') { await this.vectorDatabase.clearCollection('memory'); } logger.info(`Cleared ${type} data`); return { success: true, message: `${type} data cleared successfully` }; } catch (error) { logger.error(`Error clearing data: ${error}`); return { success: false, message: `Failed to clear data: ${error}` }; }
- src/index.ts:196-210 (registration)Tool registration in ListTools handler: defines name, description, and input schema for 'clear_data'.{ name: 'clear_data', description: 'Clear data from the RAG system', inputSchema: { type: 'object', properties: { type: { type: 'string', enum: ['files', 'memory', 'all'], description: 'Type of data to clear', }, }, required: ['type'], }, },
- src/index.ts:272-273 (registration)Dispatch case in CallToolRequestHandler switch statement that routes to the clear_data handler.case 'clear_data': return await this.handleClearData(args as { type: 'files' | 'memory' | 'all' });
- src/index.ts:199-209 (schema)Input schema definition for the 'clear_data' tool, specifying the 'type' parameter.inputSchema: { type: 'object', properties: { type: { type: 'string', enum: ['files', 'memory', 'all'], description: 'Type of data to clear', }, }, required: ['type'], },