get_current_user
Retrieve authenticated user information from Yuque, including user ID, username, and avatar details for account management.
Instructions
获取当前认证用户的信息,包括用户ID、用户名、头像等语雀账号基本信息
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_current_user"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accessToken | No | 用于认证 API 请求的令牌 |
Implementation Reference
- src/server.ts:139-158 (handler)The main execution handler for the 'get_current_user' tool. It instantiates YuqueService, calls getCurrentUser(), logs the result, and returns the user data as structured text content or an error message.
async ({ accessToken }) => { try { Logger.log("Fetching current user information"); const yuqueService = this.createYuqueService(accessToken); const user = await yuqueService.getCurrentUser(); Logger.log(`Successfully fetched user: ${user.name}`); Logger.log(JSON.stringify(user)); return { content: [{ type: "text", text: JSON.stringify(user) }], }; } catch (error) { Logger.error("Error fetching current user:", error); return { content: [ { type: "text", text: `Error fetching current user: ${error}` }, ], }; } } - src/server.ts:136-138 (schema)Zod input schema defining the optional 'accessToken' parameter for tool authentication.
{ accessToken: z.string().optional().describe("用于认证 API 请求的令牌"), }, - src/server.ts:133-159 (registration)The full MCP tool registration call in registerTools(), including name, description, input schema, and handler function.
this.server.tool( "get_current_user", "获取当前认证用户的信息,包括用户ID、用户名、头像等语雀账号基本信息", { accessToken: z.string().optional().describe("用于认证 API 请求的令牌"), }, async ({ accessToken }) => { try { Logger.log("Fetching current user information"); const yuqueService = this.createYuqueService(accessToken); const user = await yuqueService.getCurrentUser(); Logger.log(`Successfully fetched user: ${user.name}`); Logger.log(JSON.stringify(user)); return { content: [{ type: "text", text: JSON.stringify(user) }], }; } catch (error) { Logger.error("Error fetching current user:", error); return { content: [ { type: "text", text: `Error fetching current user: ${error}` }, ], }; } } ); - src/services/yuque.ts:214-217 (helper)Helper method in YuqueService class that performs the actual API request to retrieve the current user's data from Yuque API.
async getCurrentUser(): Promise<YuqueUser> { const response = await this.client.get('/user'); return response.data.data; } - src/services/yuque.ts:3-17 (schema)TypeScript interface defining the structure of the user object returned by the tool implementation.
export interface YuqueUser { id: number; type?: string; login: string; name: string; description: string; avatar_url: string; books_count?: number; public_books_count?: number; followers_count?: number; following_count?: number; public?: number; created_at: string; updated_at: string; }