get_repo_docs
Retrieve a list of all documents within a specific knowledge repository, including titles and update timestamps, using the namespace and access token for API authentication.
Instructions
获取特定知识库中的所有文档列表,包括文档标题、更新时间等信息
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accessToken | No | 用于认证 API 请求的令牌 | |
| namespace | Yes | 知识库的命名空间,格式为 user/repo |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"accessToken": {
"description": "用于认证 API 请求的令牌",
"type": "string"
},
"namespace": {
"description": "知识库的命名空间,格式为 user/repo",
"type": "string"
}
},
"required": [
"namespace"
],
"type": "object"
}
Implementation Reference
- src/server.ts:217-241 (handler)Primary handler for the 'get_repo_docs' MCP tool: registers the tool, defines input schema, creates YuqueService instance, calls getRepoDocs service method, and returns JSON-formatted documents or error.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 for get_repo_docs tool: requires 'namespace' (string, format user/repo), optional 'accessToken' (string).{ namespace: z.string().describe("知识库的命名空间,格式为 user/repo"), accessToken: z.string().optional().describe("用于认证 API 请求的令牌"), },
- src/services/yuque.ts:325-333 (helper)Supporting helper method in YuqueService: makes API GET request to `/repos/${namespace}/docs` with optional pagination and properties params, returns array of YuqueDoc.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; }