Skip to main content
Glama
ttpears

GitLab MCP Server

by ttpears

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
NameRequiredDescriptionDefault
userCredentialsNoYour GitLab credentials (optional - uses shared token if not provided)

Implementation Reference

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

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/ttpears/gitlab-mcp'

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