yuque_update_doc
Update existing documents in Yuque knowledge bases by modifying titles, content, and formats using document and repository IDs.
Instructions
更新文档 (Update existing document)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| docId | Yes | 文档ID (Document ID) | |
| repoId | Yes | 知识库ID (Repository ID) | |
| title | No | 文档标题 (Document title) | |
| content | No | 文档内容 (Document content) | |
| format | No | 文档格式 (Document format) |
Implementation Reference
- src/tools/definitions.ts:106-138 (schema)Tool schema definition for 'yuque_update_doc', including input validation schema.{ name: 'yuque_update_doc', description: '更新文档 (Update existing document)', inputSchema: { type: 'object', properties: { docId: { type: 'number', description: '文档ID (Document ID)', }, repoId: { type: 'number', description: '知识库ID (Repository ID)', }, title: { type: 'string', description: '文档标题 (Document title)', minLength: 1, maxLength: 200, }, content: { type: 'string', description: '文档内容 (Document content)', }, format: { type: 'string', enum: ['markdown', 'lake', 'html'], description: '文档格式 (Document format)', }, }, required: ['docId', 'repoId'], }, },
- src/tools/handlers.ts:185-210 (handler)The primary handler function that executes the yuque_update_doc tool logic by invoking the Yuque client and formatting the response.async function handleUpdateDoc( client: YuqueClient, args: { docId: number; repoId: number; title?: string; content?: string; format?: 'markdown' | 'lake' | 'html'; } ) { const doc = await client.updateDoc( args.docId, args.repoId, args.title, args.content, args.format ); return { content: [ { type: 'text', text: JSON.stringify(doc, null, 2), }, ], }; }
- src/server.ts:46-50 (registration)Registers the listTools endpoint which provides the schema for yuque_update_doc via YUQUE_TOOLS.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: YUQUE_TOOLS, }; });
- src/server.ts:53-56 (registration)Registers the callTool endpoint which dispatches to handleTool, eventually executing yuque_update_doc handler.server.setRequestHandler(CallToolRequestSchema, async (request) => { try { return await handleTool(request, { client: yuqueClient }); } catch (error) {
- src/yuque-client.ts:210-226 (helper)Helper method in YuqueClient that performs the actual API PUT request to update the document.async updateDoc( docId: number, repoId: number, title?: string, content?: string, format?: 'markdown' | 'lake' | 'html' ): Promise<YuqueDoc> { const data: any = {}; if (title) data.title = title; if (content) data.body = content; if (format) data.format = format; return this.request<YuqueDoc>(`/repos/${repoId}/docs/${docId}`, { method: 'PUT', data, }); }