remove_file
Delete files from the RAG system to manage storage and maintain relevant content for retrieval-augmented generation tasks.
Instructions
Remove a file from the RAG system
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Path to the file to remove from the RAG system |
Input Schema (JSON Schema)
{
"properties": {
"filePath": {
"description": "Path to the file to remove from the RAG system",
"type": "string"
}
},
"required": [
"filePath"
],
"type": "object"
}
Implementation Reference
- src/index.ts:362-372 (handler)MCP tool handler for 'remove_file': calls ragService.removeFile and returns formatted JSON response.private async handleRemoveFile(args: { filePath: string }) { const result = await this.ragService.removeFile(args.filePath); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/index.ts:72-85 (schema)Input schema and metadata for the 'remove_file' tool in ListTools response.{ name: 'remove_file', description: 'Remove a file from the RAG system', inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'Path to the file to remove from the RAG system', }, }, required: ['filePath'], }, },
- src/index.ts:239-240 (registration)Routes 'remove_file' tool calls to the handleRemoveFile method in CallToolRequestHandler.case 'remove_file': return await this.handleRemoveFile(args as { filePath: string });
- src/services/ragService.ts:83-105 (helper)Implements the file removal logic by deleting associated document chunks from the vector database.async removeFile(filePath: string): Promise<{ success: boolean; message: string; }> { try { logger.info(`Removing file from RAG: ${filePath}`); await this.vectorDatabase.deleteDocumentsBySource(filePath); logger.info(`Successfully removed file: ${filePath}`); return { success: true, message: 'File removed successfully' }; } catch (error) { logger.error(`Error removing file: ${error}`); return { success: false, message: `Failed to remove file: ${error}` }; } }