get_current_user
Retrieve details about the authenticated GitLab user, including profile information and account settings, using provided credentials or shared tokens.
Instructions
Get information about the current authenticated GitLab user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userCredentials | No | Your GitLab credentials (optional - uses shared token if not provided) |
Implementation Reference
- src/tools.ts:55-71 (handler)Tool registration and handler definition for get_current_user - validates credentials and calls the GitLab client method, returning the currentUser from the result
const getCurrentUserTool: Tool = { name: 'get_current_user', title: 'Current User', description: 'Get information about the current authenticated GitLab user', requiresAuth: true, requiresWrite: false, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, }, inputSchema: withUserAuth(z.object({}).strict()), handler: async (input, client, userConfig) => { const credentials = input.userCredentials ? validateUserConfig(input.userCredentials) : userConfig; const result = await client.getCurrentUser(credentials); return result.currentUser; }, - src/gitlab-client.ts:314-327 (handler)GitLab GraphQL client method that executes a query to fetch current user information (id, username, name, avatarUrl, webUrl) and returns the raw query result
async getCurrentUser(userConfig?: UserConfig): Promise<any> { const query = gql` query getCurrentUser { currentUser { id username name avatarUrl webUrl } } `; return this.query(query, undefined, userConfig); } - src/tools.ts:38-52 (schema)Helper function that wraps input schemas to include optional userCredentials field (gitlabUrl and accessToken) for authentication
// Helper to add user credentials to input schemas const withUserAuth = (baseSchema: z.ZodObject<any>, required = false) => { if (required) { return baseSchema.extend({ userCredentials: z.object({ gitlabUrl: z.string().url().optional(), accessToken: z.string().min(1), }).nullable().describe('Your GitLab credentials (required for this operation)'), }); } else { return baseSchema.extend({ userCredentials: UserCredentialsSchema.describe('Your GitLab credentials (optional - uses shared token if not provided)'), }); } }; - src/tools.ts:1339-1349 (registration)Main tools export array that includes all tool categories including userAuthTools which contains get_current_user
export const tools: Tool[] = [ ...readOnlyTools, ...userAuthTools, ...writeTools, updateIssueTool, updateMergeRequestTool, resolvePathTool, getGroupProjectsTool, getTypeFieldsTool, ...searchTools, ]; - src/tools.ts:1312-1315 (registration)Export of userAuthTools array that includes getCurrentUserTool and getProjectsTool - tools that require user authentication
export const userAuthTools: Tool[] = [ getCurrentUserTool, getProjectsTool, ];