gitea_user_current
Retrieve details about the currently authenticated Gitea user to verify identity and access permissions for repository operations.
Instructions
Get information about the currently authenticated user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:552-585 (handler)The MCP tool handler for 'gitea_user_current'. Calls GiteaClient.getCurrentUser() and formats the response as JSON, with error handling.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/index.ts:546-587 (registration)Registration of the 'gitea_user_current' tool using mcpServer.registerTool, including title, description, and inline handler.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:225-233 (helper)GiteaClient.getCurrentUser() helper method that makes a GET request to the Gitea API endpoint '/user' to retrieve current user information.async getCurrentUser(): Promise<{ id: number; login: string; full_name: string; email: string; avatar_url: string; }> { return this.get('/user'); }