Skip to main content
Glama
lh8966
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}`); } }

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