yuque_get_repos
List knowledge repositories from Yuque. Optionally filter by user ID to retrieve repositories for a specific user.
Instructions
获取知识库列表 (List knowledge repositories)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | No | 用户ID,不提供则获取当前用户的知识库 (User ID, defaults to current user) |
Implementation Reference
- src/tools/handlers.ts:115-125 (handler)The handler function for 'yuque_get_repos' tool. It calls client.getRepos(args.userId) and returns the JSON-stringified list of repos.
async function handleGetRepos(client: YuqueClient, args: { userId?: string }) { const repos = await client.getRepos(args.userId); return { content: [ { type: 'text', text: JSON.stringify(repos, null, 2), }, ], }; } - src/tools/definitions.ts:20-31 (schema)Tool definition/schema for 'yuque_get_repos', specifying the name, description, and input schema (optional userId string).
{ name: 'yuque_get_repos', description: '获取知识库列表 (List knowledge repositories)', inputSchema: { type: 'object', properties: { userId: { type: 'string', description: '用户ID,不提供则获取当前用户的知识库 (User ID, defaults to current user)', }, }, }, - src/tools/handlers.ts:23-40 (registration)The case statement in the switch handler that routes 'yuque_get_repos' calls to handleGetRepos().
switch (name) { case 'yuque_get_user': return await handleGetUser(client); case 'yuque_get_repos': return await handleGetRepos(client, args as { userId?: string }); case 'yuque_get_docs': return await handleGetDocs( client, args as { repoId: number; limit?: number; offset?: number } ); case 'yuque_get_doc': return await handleGetDoc( client, args as { docId: number; repoId: number } ); - src/server.ts:46-50 (registration)Tool registration via ListToolsRequestSchema returning YUQUE_TOOLS array, which includes 'yuque_get_repos'.
server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: YUQUE_TOOLS, }; }); - src/yuque-client.ts:159-166 (helper)The YuqueClient.getRepos() method that fetches repos from the Yuque API via GET /users/{userId}/repos. If no userId is provided, it first fetches the current user.
async getRepos(userId?: string): Promise<YuqueRepo[]> { // Use /users/{userId}/repos as confirmed working endpoint if (!userId) { const user = await this.getUser(); userId = user.id.toString(); } return this.request<YuqueRepo[]>(`/users/${userId}/repos`); }