Skip to main content
Glama
lh8966
by lh8966

generate_daily_report

Generate and send daily GitLab commit reports to WeChat Work groups, tracking project contributions by date and user for team visibility.

Instructions

生成并发送GitLab提交记录的日报到企业微信

Input Schema

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

Input Schema (JSON Schema)

{ "properties": { "date": { "description": "查询日期,格式:YYYY-MM-DD", "type": "string" }, "projectId": { "description": "项目ID(可选,不指定则查询所有项目)", "type": "string" }, "username": { "description": "GitLab用户名(可选,默认使用配置的用户名)", "type": "string" } }, "required": [ "date" ], "type": "object" }

Implementation Reference

  • The primary handler function for the 'generate_daily_report' tool. Validates parameters, fetches GitLab commits for the specified date and user, generates a markdown report, sends it to WeChat, logs the result, and returns a response content.
    async handleGenerateDailyReport(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 actualUsername = username || gitlabConfig.username; logger.info('开始生成日报', { date, username: actualUsername, projectId }); // 获取提交记录 const commits = await this.gitlabService.getCommitsByDate( actualUsername, date, projectId ); // 生成日报内容 const report = this.generateReportContent(commits, date, actualUsername); // 发送到企业微信 const result = await this.wechatService.sendMessage(report, 'markdown'); logger.info(`日报生成并发送${result.success ? '成功' : '失败'}`, { commitCount: commits.length }); return { content: [ { type: 'text', text: `日报生成并发送${result.success ? '成功' : '失败'}\n\n报告内容:\n${report}`, }, ], }; }
  • Input schema for the 'generate_daily_report' tool, defining parameters: date (required), username and projectId (optional).
    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:88-109 (registration)
    Registration of the 'generate_daily_report' tool in the ListTools response, including name, description, and input schema.
    { name: 'generate_daily_report', 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:126-127 (registration)
    Dispatch case in the CallToolRequest handler that routes 'generate_daily_report' calls to the handler function.
    case 'generate_daily_report': return await this.handleGenerateDailyReport(args);
  • Helper function that generates the markdown-formatted daily report content from commit data, including summary and detailed list.
    generateReportContent(commits, date, username) { const commitCount = commits.length; const projects = [...new Set(commits.map(c => c.project_name))]; let report = `# ${username} 的代码提交日报\n\n`; report += `**日期**: ${date}\n`; report += `**提交数量**: ${commitCount}\n`; report += `**涉及项目**: ${projects.join(', ')}\n\n`; if (commitCount === 0) { report += '今日无代码提交记录。'; } else { report += '## 提交详情\n\n'; commits.forEach((commit, index) => { report += `### ${index + 1}. ${commit.title}\n`; report += `- **项目**: ${commit.project_name}\n`; report += `- **时间**: ${new Date(commit.committed_date).toLocaleString('zh-CN')}\n`; report += `- **分支**: ${commit.ref_name || 'unknown'}\n`; if (commit.message && commit.message !== commit.title) { report += `- **详情**: ${commit.message.replace(commit.title, '').trim()}\n`; } report += `- **链接**: [查看提交](${commit.web_url})\n\n`; }); } return report; }

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