Skip to main content
Glama

gitlab_get_user_activities

Fetch GitLab user activities by username to monitor contributions, optionally filtered by date for tracking recent work.

Instructions

Fetches activities for a given GitLab user by their username, optionally filtered by date.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesThe username of the GitLab user.
sinceDateNoOptional: Activities since this date (YYYY-MM-DD). Defaults to 1 day ago if not provided.

Implementation Reference

  • Core handler function that executes the GitLab API call to retrieve user activities/events for a given user ID, optionally filtered by a 'since' date.
    async getUserActivities(userId: number, sinceDate?: Date): Promise<any[]> {
      let endpoint = `users/${userId}/events`;
      if (sinceDate) {
        // GitLab API expects ISO 8601 format for `after` parameter
        endpoint += `?after=${sinceDate.toISOString().split('T')[0]}`;
      }
      return this.callGitLabApi<any[]>(endpoint);
    }
  • src/index.ts:286-305 (registration)
    Tool registration including name, description, and input schema definition in the MCP tools list.
      name: 'gitlab_get_user_activities',
      description:
        'Fetches activities for a given GitLab user by their username, optionally filtered by date.',
      inputSchema: {
        type: 'object',
        properties: {
          username: {
            type: 'string',
            description: 'The username of the GitLab user.',
          },
          sinceDate: {
            type: 'string',
            format: 'date',
            description:
              'Optional: Activities since this date (YYYY-MM-DD). Defaults to 1 day ago if not provided.',
          },
        },
        required: ['username'],
      },
    },
  • MCP tool call handler that resolves username to user ID, determines the 'since' date (default 1 day ago), calls the service handler, and formats the response.
    case 'gitlab_get_user_activities': {
      if (!gitlabService) {
        throw new Error('GitLab service is not initialized.');
      }
      const { username, sinceDate } = args as {
        username: string;
        sinceDate?: string;
      };
      const userId = await gitlabService.getUserIdByUsername(username);
      let activities;
      if (sinceDate) {
        activities = await gitlabService.getUserActivities(
          userId,
          new Date(sinceDate),
        );
      } else {
        const oneDayAgo = new Date();
        oneDayAgo.setDate(oneDayAgo.getDate() - 1);
        activities = await gitlabService.getUserActivities(
          userId,
          oneDayAgo,
        );
      }
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(activities, null, 2),
          },
        ],
      };
    }
  • Helper function to resolve GitLab username to user ID, used by the tool handler. Supports exact match and fuzzy partial matching.
    async getUserIdByUsername(username: string): Promise<number> {
      // First try exact username match
      const exactUsers = await this.callGitLabApi<GitLabUser[]>(
        `users?username=${username}`,
      );
      if (exactUsers.length > 0) {
        return exactUsers[0].id;
      }
    
      // Fallback: search all users and filter by partial username (case-insensitive)
      const allUsers =
        await this.callGitLabApi<GitLabUser[]>(`users?per_page=100`);
      const lowerCaseUsername = username.toLowerCase();
    
      const matchingUsers = allUsers.filter(
        (user) =>
          user.username.toLowerCase().includes(lowerCaseUsername) ||
          user.name.toLowerCase().includes(lowerCaseUsername),
      );
    
      if (matchingUsers.length === 0) {
        throw new Error(`User with username containing '${username}' not found.`);
      }
    
      if (matchingUsers.length > 1) {
        const userList = matchingUsers
          .map((user) => `${user.username} (${user.name})`)
          .join(', ');
        throw new Error(
          `Multiple users found matching '${username}': ${userList}. Please be more specific.`,
        );
      }
    
      return matchingUsers[0].id;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states it 'fetches activities' but does not disclose behavioral traits like whether it requires authentication, rate limits, pagination, or what the return format looks like. This is a significant gap for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose and includes the optional filter. There is no wasted text, making it appropriately sized and well-structured for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete. It lacks details on behavioral aspects (e.g., authentication, response format) and does not compensate for the missing structured data, making it inadequate for a tool that fetches user data.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters fully. The description adds minimal value by mentioning optional date filtering but does not provide additional semantic context beyond what's in the schema, aligning with the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'fetches' and the resource 'activities for a given GitLab user', making the purpose specific and understandable. However, it does not explicitly differentiate from siblings like 'gitlab_get_user_id_by_username', which might be a related lookup, so it misses full sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, such as other user-related or activity-related tools in the sibling list. It mentions optional date filtering but does not specify use cases, prerequisites, or exclusions, leaving usage context vague.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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

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