Skip to main content
Glama
lh8966

GitLab WeChat MCP

by lh8966

get_gitlab_commits

Retrieve GitLab commit records for specified dates to generate work reports, with optional filtering by user or project for integration with enterprise messaging systems.

Instructions

获取GitLab用户在指定日期的代码提交记录

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameNoGitLab用户名(可选,默认使用配置的用户名)
dateYes查询日期,格式:YYYY-MM-DD
projectIdNo项目ID(可选,不指定则查询所有项目)

Implementation Reference

  • The main handler function for the 'get_gitlab_commits' MCP tool. Validates input parameters and delegates to GitLabService.getCommitsByDate to fetch the commits, then returns them as JSON.
    async handleGetGitLabCommits(args) {
      // 验证参数
      ErrorHandler.validateParams(args, {
        date: { required: true, type: 'string', format: 'date' },
        username: { required: false, type: 'string' },
        projectId: { required: false, type: 'string' },
      });
    
      const { username, date, projectId } = args;
      const gitlabConfig = config.getGitLabConfig();
      
      const commits = await this.gitlabService.getCommitsByDate(
        username || gitlabConfig.username,
        date,
        projectId
      );
    
      logger.info(`获取到 ${commits.length} 条提交记录`, { date, username: username || gitlabConfig.username });
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(commits, null, 2),
          },
        ],
      };
    }
  • Defines the tool name, description, and input schema for 'get_gitlab_commits' in the MCP tools list.
    {
      name: 'get_gitlab_commits',
      description: '获取GitLab用户在指定日期的代码提交记录',
      inputSchema: {
        type: 'object',
        properties: {
          username: {
            type: 'string',
            description: 'GitLab用户名(可选,默认使用配置的用户名)',
          },
          date: {
            type: 'string',
            description: '查询日期,格式:YYYY-MM-DD',
          },
          projectId: {
            type: 'string',
            description: '项目ID(可选,不指定则查询所有项目)',
          },
        },
        required: ['date'],
      },
    },
  • src/index.js:122-123 (registration)
    Switch case in the CallToolRequest handler that routes 'get_gitlab_commits' calls to the specific handler function.
    case 'get_gitlab_commits':
      return await this.handleGetGitLabCommits(args);
  • Core helper method in GitLabService that fetches commits for a user on a specific date, either from a single project or all user projects using GitLab API.
    async getCommitsByDate(username, date, projectId = null) {
      try {
        const startDate = new Date(date);
        const endDate = new Date(date);
        endDate.setDate(endDate.getDate() + 1);
    
        const since = startDate.toISOString();
        const until = endDate.toISOString();
    
        let commits = [];
    
        if (projectId) {
          // 查询指定项目的提交
          commits = await this.getProjectCommits(projectId, username, since, until);
        } else {
          // 查询用户所有项目的提交
          commits = await this.getAllUserCommits(username, since, until);
        }
    
        return commits;
      } catch (error) {
        console.error('获取GitLab提交记录失败:', error.message);
        throw new Error(`获取GitLab提交记录失败: ${error.message}`);
      }
    }
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 of behavioral disclosure. It states the tool retrieves commit records but doesn't describe key behaviors: whether it's read-only (implied by '获取' but not explicit), what permissions are needed, if there are rate limits, how results are formatted (e.g., list of commits with details), or error handling. For a tool with no annotations, this leaves significant gaps in understanding its operational traits.

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, clear sentence in Chinese: '获取GitLab用户在指定日期的代码提交记录'. It is front-loaded with the core purpose, has zero redundant words, and efficiently communicates the tool's function without unnecessary elaboration. This makes it easy for an agent to parse and understand quickly.

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 the complexity (3 parameters, no output schema, no annotations), the description is incomplete. It lacks details on behavioral aspects (e.g., read-only nature, authentication needs), output format (what commit data is returned), and usage context. While the schema covers parameters well, the absence of annotations and output schema means the description should compensate more to help the agent invoke the tool correctly, which it doesn't do adequately.

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?

The description adds minimal semantic context beyond the input schema. It mentions 'GitLab用户' (GitLab user) and '指定日期' (specified date), which align with the 'username' and 'date' parameters in the schema. However, with 100% schema description coverage, the schema already documents all parameters thoroughly (e.g., 'username' is optional with a default, 'date' is required in YYYY-MM-DD format, 'projectId' is optional for filtering). The description doesn't provide additional insights like example values or edge cases, so it meets the baseline for high schema 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 tool's purpose: '获取GitLab用户在指定日期的代码提交记录' (Get GitLab user's code commit records for a specified date). It specifies the verb ('获取' - get), resource ('代码提交记录' - code commit records), and scope ('GitLab用户' - GitLab user, '指定日期' - specified date). However, it doesn't explicitly differentiate from sibling tools like 'generate_daily_report' or 'send_to_wechat', which appear to serve different purposes (report generation and messaging).

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. It doesn't mention any prerequisites, exclusions, or scenarios where other tools might be more appropriate. For example, it doesn't clarify if this is for daily summaries vs. real-time monitoring or how it relates to 'generate_daily_report'. Without such context, the agent must infer usage from the tool name and parameters alone.

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

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