Skip to main content
Glama

get_current_user

Retrieve authenticated user information from Yuque, including user ID, username, and avatar details for account management.

Instructions

获取当前认证用户的信息,包括用户ID、用户名、头像等语雀账号基本信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accessTokenNo用于认证 API 请求的令牌

Implementation Reference

  • 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}` }, ], }; } }
  • 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}` }, ], }; } } );
  • 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; }
  • 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; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/HenryHaoson/Yuque-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server