delete_doc
Remove a document from a Yuque knowledge base by specifying its namespace and ID. This action is permanent and cannot be undone.
Instructions
从语雀知识库中删除指定文档,此操作不可撤销
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | Yes | 知识库的命名空间,格式为 user/repo | |
| id | Yes | 要删除的文档ID | |
| accessToken | No | 用于认证 API 请求的令牌 |
Implementation Reference
- src/server.ts:456-489 (handler)Full tool registration block for 'delete_doc' including inline handler function that performs the deletion logic by calling yuqueService.deleteDoc()this.server.tool( "delete_doc", "从语雀知识库中删除指定文档,此操作不可撤销", { namespace: z.string().describe("知识库的命名空间,格式为 user/repo"), id: z.number().describe("要删除的文档ID"), accessToken: z.string().optional().describe("用于认证 API 请求的令牌"), }, async ({ namespace, id, accessToken }) => { try { Logger.log(`Deleting document ${id} from repository: ${namespace}`); const yuqueService = this.createYuqueService(accessToken); await yuqueService.deleteDoc(namespace, id); Logger.log(`Successfully deleted document ${id}`); return { content: [ { type: "text", text: `Document ${id} has been successfully deleted`, }, ], }; } catch (error) { Logger.error( `Error deleting doc ${id} from repo ${namespace}:`, error ); return { content: [{ type: "text", text: `Error deleting doc: ${error}` }], }; } } );
- src/server.ts:459-463 (schema)Zod input schema definition for the delete_doc tool parameters{ namespace: z.string().describe("知识库的命名空间,格式为 user/repo"), id: z.number().describe("要删除的文档ID"), accessToken: z.string().optional().describe("用于认证 API 请求的令牌"), },
- src/services/yuque.ts:382-385 (helper)YuqueService helper method that executes the actual Yuque API DELETE request to remove the document.async deleteDoc(namespace: string, id: number): Promise<YuqueDoc> { const response = await this.client.delete(`/repos/${namespace}/docs/${id}`); return response.data.data; }