gitea_user_current
Retrieve details about the currently authenticated user in Gitea, including profile information and account status.
Instructions
Get information about the currently authenticated user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:546-586 (registration)Registers the 'gitea_user_current' MCP tool. Includes the tool schema (title and description, no input parameters), and the inline handler function that calls GiteaClient.getCurrentUser() and returns formatted user information or error.mcpServer.registerTool( 'gitea_user_current', { title: '获取当前用户', description: 'Get information about the currently authenticated user', }, async (_args: any, _extra: any) => { try { const user = await ctx.client.getCurrentUser(); return { content: [ { type: 'text' as const, text: JSON.stringify( { id: user.id, login: user.login, full_name: user.full_name, email: user.email, avatar_url: user.avatar_url, }, null, 2 ), }, ], }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: 'text' as const, text: `Error: ${errorMessage}`, }, ], isError: true, }; } } );
- src/gitea-client.ts:222-233 (helper)Implementation of GiteaClient.getCurrentUser() method, which performs a GET request to the Gitea API endpoint '/api/v1/user' to retrieve the current authenticated user's information./** * 获取当前认证用户信息 */ async getCurrentUser(): Promise<{ id: number; login: string; full_name: string; email: string; avatar_url: string; }> { return this.get('/user'); }