get_user_docs
Retrieve a comprehensive list of all knowledge base documents, including private and collaborative files, associated with the current user on the Yuque platform.
Instructions
获取当前用户的所有知识库文档列表,包括私人和协作文档
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accessToken | No | 用于认证 API 请求的令牌 |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"accessToken": {
"description": "用于认证 API 请求的令牌",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/server.ts:167-185 (handler)MCP tool handler for 'get_user_docs'. Creates YuqueService with optional accessToken, fetches user docs via service method, logs, and returns JSON stringified docs or error message in MCP content format.}, async ({ accessToken }) => { try { Logger.log("Fetching user's documents"); const yuqueService = this.createYuqueService(accessToken); const docs = await yuqueService.getUserDocs(); Logger.log(`Successfully fetched ${docs.length} documents`); return { content: [{ type: "text", text: JSON.stringify(docs) }], }; } catch (error) { Logger.error("Error fetching user docs:", error); return { content: [ { type: "text", text: `Error fetching user docs: ${error}` }, ], }; }
- src/server.ts:162-186 (registration)Registration of the 'get_user_docs' tool on the MCP server, including name, Chinese description, Zod input schema, and inline handler function.this.server.tool( "get_user_docs", "获取当前用户的所有知识库文档列表,包括私人和协作文档", { accessToken: z.string().optional().describe("用于认证 API 请求的令牌"), }, async ({ accessToken }) => { try { Logger.log("Fetching user's documents"); const yuqueService = this.createYuqueService(accessToken); const docs = await yuqueService.getUserDocs(); Logger.log(`Successfully fetched ${docs.length} documents`); return { content: [{ type: "text", text: JSON.stringify(docs) }], }; } catch (error) { Logger.error("Error fetching user docs:", error); return { content: [ { type: "text", text: `Error fetching user docs: ${error}` }, ], }; } }
- src/server.ts:165-166 (schema)Zod input schema for the tool, defining optional accessToken parameter.{ accessToken: z.string().optional().describe("用于认证 API 请求的令牌"),
- src/services/yuque.ts:219-222 (helper)YuqueService helper method implementing the core API call to fetch current user's docs from Yuque API endpoint '/user/docs'.async getUserDocs(): Promise<YuqueDoc[]> { const response = await this.client.get('/user/docs'); return response.data.data; }