delete_doc
Remove a specified document from the Yuque knowledge base using namespace and document ID. Ensure proper authorization with an access token. Note: This action is irreversible.
Instructions
从语雀知识库中删除指定文档,此操作不可撤销
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accessToken | No | 用于认证 API 请求的令牌 | |
| id | Yes | 要删除的文档ID | |
| namespace | Yes | 知识库的命名空间,格式为 user/repo |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"accessToken": {
"description": "用于认证 API 请求的令牌",
"type": "string"
},
"id": {
"description": "要删除的文档ID",
"type": "number"
},
"namespace": {
"description": "知识库的命名空间,格式为 user/repo",
"type": "string"
}
},
"required": [
"namespace",
"id"
],
"type": "object"
}
Implementation Reference
- src/server.ts:464-488 (handler)The main handler function for the 'delete_doc' tool, which creates YuqueService, calls deleteDoc, and returns formatted response.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 for 'delete_doc' tool parameters: namespace, id, optional accessToken.{ namespace: z.string().describe("知识库的命名空间,格式为 user/repo"), id: z.number().describe("要删除的文档ID"), accessToken: z.string().optional().describe("用于认证 API 请求的令牌"), },
- src/server.ts:456-489 (registration)MCP server tool registration for 'delete_doc' with description, schema, and handler.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/services/yuque.ts:382-385 (helper)YuqueService helper method implementing the DELETE API call to delete the document.async deleteDoc(namespace: string, id: number): Promise<YuqueDoc> { const response = await this.client.delete(`/repos/${namespace}/docs/${id}`); return response.data.data; }