remove_documentation
Remove outdated or incorrect documentation sources by URL to clean up your RAG system and improve search accuracy.
Instructions
Remove specific documentation sources from the system by their URLs. Use this tool to clean up outdated documentation, remove incorrect sources, or manage the documentation collection. The removal is permanent and will affect future search results. Supports removing multiple URLs in a single operation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| urls | Yes | Array of URLs to remove from the database |
Implementation Reference
- RemoveDocumentationHandler class implementing the core execution logic for the 'remove_documentation' tool. Deletes documentation from Qdrant collection using URL filters, with input validation and error handling.export class RemoveDocumentationHandler extends BaseHandler { async handle(args: any): Promise<McpToolResponse> { if (!args.urls || !Array.isArray(args.urls) || args.urls.length === 0) { throw new McpError(ErrorCode.InvalidParams, 'urls must be a non-empty array'); } if (!args.urls.every((url: string) => typeof url === 'string')) { throw new McpError(ErrorCode.InvalidParams, 'All URLs must be strings'); } try { // Delete using filter to match any of the provided URLs const result = await this.apiClient.qdrantClient.delete(COLLECTION_NAME, { filter: { should: args.urls.map((url: string) => ({ key: 'url', match: { value: url } })) }, wait: true // Ensure deletion is complete before responding }); if (!['acknowledged', 'completed'].includes(result.status)) { throw new Error('Delete operation failed'); } return { content: [ { type: 'text', text: `Successfully removed documentation from ${args.urls.length} source${args.urls.length > 1 ? 's' : ''}: ${args.urls.join(', ')}`, }, ], }; } catch (error) { if (error instanceof Error) { if (error.message.includes('unauthorized')) { throw new McpError( ErrorCode.InvalidRequest, 'Failed to authenticate with Qdrant cloud while removing documentation' ); } else if (error.message.includes('ECONNREFUSED') || error.message.includes('ETIMEDOUT')) { throw new McpError( ErrorCode.InternalError, 'Connection to Qdrant cloud failed while removing documentation' ); } } return { content: [ { type: 'text', text: `Failed to remove documentation: ${error}`, }, ], isError: true, }; } } }
- src/handler-registry.ts:96-113 (schema)Tool schema definition for 'remove_documentation' returned by list_tools request handler.{ name: 'remove_documentation', description: 'Remove specific documentation sources from the system by their URLs. Use this tool to clean up outdated documentation, remove incorrect sources, or manage the documentation collection. The removal is permanent and will affect future search results. Supports removing multiple URLs in a single operation.', inputSchema: { type: 'object', properties: { urls: { type: 'array', items: { type: 'string', description: 'The complete URL of the documentation source to remove. Must exactly match the URL used when the documentation was added.', }, description: 'Array of URLs to remove from the database', }, }, required: ['urls'], }, } as ToolDefinition,
- src/handler-registry.ts:40-40 (registration)Registers the RemoveDocumentationHandler instance under the 'remove_documentation' tool name in the handler map used for call_tool requests.this.handlers.set('remove_documentation', new RemoveDocumentationHandler(this.server, this.apiClient));
- Alternative tool definition/schema in the BaseTool subclass.get definition(): ToolDefinition { return { name: 'remove_documentation', description: 'Remove one or more documentation sources by their URLs', inputSchema: { type: 'object', properties: { urls: { type: 'array', items: { type: 'string', description: 'URL of a documentation source to remove' }, description: 'Array of URLs to remove. Can be a single URL or multiple URLs.', minItems: 1 } }, required: ['urls'], }, }; }
- src/tools/remove-documentation.ts:8-96 (handler)RemoveDocumentationTool class with execute method implementing similar logic, possibly for client-side or alternative use.export class RemoveDocumentationTool extends BaseTool { private apiClient: ApiClient; constructor(apiClient: ApiClient) { super(); this.apiClient = apiClient; } get definition(): ToolDefinition { return { name: 'remove_documentation', description: 'Remove one or more documentation sources by their URLs', inputSchema: { type: 'object', properties: { urls: { type: 'array', items: { type: 'string', description: 'URL of a documentation source to remove' }, description: 'Array of URLs to remove. Can be a single URL or multiple URLs.', minItems: 1 } }, required: ['urls'], }, }; } async execute(args: { urls: string[] }): Promise<McpToolResponse> { if (!Array.isArray(args.urls) || args.urls.length === 0) { throw new McpError(ErrorCode.InvalidParams, 'At least one URL is required'); } if (!args.urls.every(url => typeof url === 'string')) { throw new McpError(ErrorCode.InvalidParams, 'All URLs must be strings'); } try { // Delete using filter to match any of the provided URLs const result = await this.apiClient.qdrantClient.delete(COLLECTION_NAME, { filter: { should: args.urls.map(url => ({ key: 'url', match: { value: url } })) }, wait: true }); if (!['acknowledged', 'completed'].includes(result.status)) { throw new Error('Delete operation failed'); } return { content: [ { type: 'text', text: `Successfully removed documentation from ${args.urls.length} source${args.urls.length > 1 ? 's' : ''}: ${args.urls.join(', ')}`, }, ], }; } catch (error) { if (error instanceof Error) { if (error.message.includes('unauthorized')) { throw new McpError( ErrorCode.InvalidRequest, 'Failed to authenticate with Qdrant cloud while removing documentation' ); } else if (error.message.includes('ECONNREFUSED') || error.message.includes('ETIMEDOUT')) { throw new McpError( ErrorCode.InternalError, 'Connection to Qdrant cloud failed while removing documentation' ); } } return { content: [ { type: 'text', text: `Failed to remove documentation: ${error}`, }, ], isError: true, }; } } }