yuque_get_doc
Retrieve document details from a Yuque repository by providing document ID and repository ID.
Instructions
获取文档详情 (Get document details)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| docId | Yes | 文档ID (Document ID) | |
| repoId | Yes | 知识库ID (Repository ID) |
Implementation Reference
- src/tools/handlers.ts:145-158 (handler)The `handleGetDoc` function is the handler for the 'yuque_get_doc' tool. It accepts `docId` and `repoId` arguments, calls `client.getDoc(docId, repoId)` on the YuqueClient, and returns the document details as JSON text content.
async function handleGetDoc( client: YuqueClient, args: { docId: number; repoId: number } ) { const doc = await client.getDoc(args.docId, args.repoId); return { content: [ { type: 'text', text: JSON.stringify(doc, null, 2), }, ], }; } - src/tools/handlers.ts:36-40 (registration)The 'yuque_get_doc' tool is dispatched in the switch statement inside the `handleTool` function. When the tool name matches 'yuque_get_doc', it calls `handleGetDoc` with the client and typed arguments.
case 'yuque_get_doc': return await handleGetDoc( client, args as { docId: number; repoId: number } ); - src/tools/definitions.ts:58-75 (schema)The tool definition for 'yuque_get_doc' registers the tool name, description ('获取文档详情 (Get document details)'), and input schema with required fields `docId` (number) and `repoId` (number).
{ name: 'yuque_get_doc', description: '获取文档详情 (Get document details)', inputSchema: { type: 'object', properties: { docId: { type: 'number', description: '文档ID (Document ID)', }, repoId: { type: 'number', description: '知识库ID (Repository ID)', }, }, required: ['docId', 'repoId'], }, }, - src/yuque-client.ts:183-185 (helper)The `getDoc` method on `YuqueClient` makes the actual API request to fetch a document. It calls GET `/repos/${repoId}/docs/${docId}` via the internal `request` method and returns a `YuqueDoc`.
async getDoc(docId: number, repoId: number): Promise<YuqueDoc> { return this.request<YuqueDoc>(`/repos/${repoId}/docs/${docId}`); }