yuque_get_docs
Retrieve document lists from a Yuque knowledge base repository using repository ID, with pagination controls for managing results.
Instructions
获取文档列表 (List documents in a repository)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repoId | Yes | 知识库ID (Repository ID) | |
| limit | No | 返回数量限制,默认20 (Result limit, default 20) | |
| offset | No | 偏移量,默认0 (Offset for pagination, default 0) |
Implementation Reference
- src/tools/handlers.ts:127-143 (handler)The handler function that executes the yuque_get_docs tool logic: extracts repoId, limit, offset from arguments, calls yuqueClient.getDocs API, and returns the result as JSON-formatted text content.async function handleGetDocs( client: YuqueClient, args: { repoId: number; limit?: number; offset?: number } ) { const docs = await client.getDocs(args.repoId, { limit: args.limit, offset: args.offset, }); return { content: [ { type: 'text', text: JSON.stringify(docs, null, 2), }, ], }; }
- src/tools/definitions.ts:33-57 (schema)Input schema and metadata definition for the yuque_get_docs tool.{ name: 'yuque_get_docs', description: '获取文档列表 (List documents in a repository)', inputSchema: { type: 'object', properties: { repoId: { type: 'number', description: '知识库ID (Repository ID)', }, limit: { type: 'number', description: '返回数量限制,默认20 (Result limit, default 20)', minimum: 1, maximum: 100, }, offset: { type: 'number', description: '偏移量,默认0 (Offset for pagination, default 0)', minimum: 0, }, }, required: ['repoId'], }, },
- src/server.ts:46-50 (registration)Server registration for listing tools, which includes the yuque_get_docs schema from YUQUE_TOOLS array.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: YUQUE_TOOLS, }; });
- src/server.ts:53-67 (registration)Server registration for tool calls, which dispatches to handleTool (containing switch for yuque_get_docs).server.setRequestHandler(CallToolRequestSchema, async (request) => { try { return await handleTool(request, { client: yuqueClient }); } catch (error) { if (error instanceof McpError) { throw error; } const errorMessage = error instanceof Error ? error.message : String(error); throw new McpError( ErrorCode.InternalError, `Error executing tool: ${errorMessage}` ); } });
- src/yuque-client.ts:171-178 (helper)Supporting utility in YuqueClient that performs the actual HTTP request to Yuque API /repos/{repoId}/docs endpoint with optional pagination parameters.async getDocs(repoId: number, options?: { limit?: number; offset?: number }): Promise<YuqueDoc[]> { const params = new URLSearchParams(); if (options?.limit) params.append('limit', options.limit.toString()); if (options?.offset) params.append('offset', options.offset.toString()); const endpoint = `/repos/${repoId}/docs${params.toString() ? '?' + params.toString() : ''}`; return this.request<YuqueDoc[]>(endpoint); }