get_repo_docs
Retrieve all documents from a Yuque knowledge repository, including titles and update timestamps, to access and organize content efficiently.
Instructions
获取特定知识库中的所有文档列表,包括文档标题、更新时间等信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | Yes | 知识库的命名空间,格式为 user/repo | |
| accessToken | No | 用于认证 API 请求的令牌 |
Implementation Reference
- src/server.ts:217-241 (handler)MCP tool registration and inline handler function that creates YuqueService, calls getRepoDocs, and returns the documents as JSON text content.this.server.tool( "get_repo_docs", "获取特定知识库中的所有文档列表,包括文档标题、更新时间等信息", { namespace: z.string().describe("知识库的命名空间,格式为 user/repo"), accessToken: z.string().optional().describe("用于认证 API 请求的令牌"), }, async ({ namespace, accessToken }) => { try { Logger.log(`Fetching documents for repository: ${namespace}`); const yuqueService = this.createYuqueService(accessToken); const docs = await yuqueService.getRepoDocs(namespace); Logger.log(`Successfully fetched ${docs.length} documents`); return { content: [{ type: "text", text: JSON.stringify(docs, null, 2) }], }; } catch (error) { Logger.error(`Error fetching docs for repo ${namespace}:`, error); return { content: [{ type: "text", text: `Error fetching docs: ${error}` }], }; } } );
- src/server.ts:220-223 (schema)Zod input schema defining parameters for the get_repo_docs tool: required namespace (user/repo format) and optional accessToken.{ namespace: z.string().describe("知识库的命名空间,格式为 user/repo"), accessToken: z.string().optional().describe("用于认证 API 请求的令牌"), },
- src/services/yuque.ts:325-333 (helper)YuqueService helper method that performs the actual API request to retrieve documents from a repository.async getRepoDocs(namespace: string, offset?: number, limit?: number, optional_properties?: string): Promise<YuqueDoc[]> { const params: any = {}; if (offset !== undefined) params.offset = offset; if (limit !== undefined) params.limit = limit; if (optional_properties !== undefined) params.optional_properties = optional_properties; const response = await this.client.get(`/repos/${namespace}/docs`, { params }); return response.data.data; }