yuque_get_repos
Retrieve knowledge repository lists from Yuque platform. Specify a user ID to get their repositories or use default for current user's repositories.
Instructions
获取知识库列表 (List knowledge repositories)
Input Schema
TableJSON 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 that implements the core logic for the 'yuque_get_repos' tool. It extracts the userId from arguments, calls YuqueClient.getRepos, and formats the response as MCP content.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-32 (schema)The tool schema definition specifying name, description, and inputSchema with optional userId parameter.{ name: 'yuque_get_repos', description: '获取知识库列表 (List knowledge repositories)', inputSchema: { type: 'object', properties: { userId: { type: 'string', description: '用户ID,不提供则获取当前用户的知识库 (User ID, defaults to current user)', }, }, }, },
- src/server.ts:46-50 (registration)Registration of tool list handlers that returns all tool definitions, including 'yuque_get_repos' schema from YUQUE_TOOLS.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: YUQUE_TOOLS, }; });
- src/server.ts:52-67 (registration)Registration of tool call handler that dispatches to handleTool function, which routes 'yuque_get_repos' to its specific handler.// Handle tool execution requests 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:159-166 (helper)Supporting method in YuqueClient that performs the actual API call to fetch repositories for a given user ID (defaults to current user). Called by the tool handler.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`); }