remove_document
Delete specific documents from the MCP Knowledge Base Server by providing the document ID, ensuring accurate and up-to-date document management.
Instructions
从知识库中移除文档
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| document_id | Yes | 文档ID |
Input Schema (JSON Schema)
{
"properties": {
"document_id": {
"description": "文档ID",
"type": "string"
}
},
"required": [
"document_id"
],
"type": "object"
}
Implementation Reference
- src/mcp-server.ts:266-280 (handler)Tool handler for 'remove_document' in MCP server switch statement. Extracts document_id from arguments, calls knowledgeBase.removeDocument(), and returns success/error message.case 'remove_document': { const { document_id } = args as { document_id: string }; const success = await this.knowledgeBase.removeDocument(document_id); return { content: [ { type: 'text', text: success ? `文档 "${document_id}" 已从知识库中移除` : `移除文档 "${document_id}" 失败,可能不存在` } ] }; }
- src/mcp-server.ts:120-133 (registration)Registers the 'remove_document' tool in the list of tools returned by ListToolsRequestHandler, including name, description, and input schema.{ name: 'remove_document', description: '从知识库中移除文档', inputSchema: { type: 'object', properties: { document_id: { type: 'string', description: '文档ID' } }, required: ['document_id'] } },
- src/mcp-server.ts:123-133 (schema)Input schema definition for the 'remove_document' tool: requires a string 'document_id'.inputSchema: { type: 'object', properties: { document_id: { type: 'string', description: '文档ID' } }, required: ['document_id'] } },
- src/knowledge-base.ts:170-176 (helper)Core implementation of document removal: deletes document from internal Map and saves updated index to disk.async removeDocument(id: string): Promise<boolean> { const deleted = this.documents.delete(id); if (deleted) { await this.saveIndex(); } return deleted; }