npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

git-today-commits-mcp

v1.0.0

Published

用账号密码(HTTP Basic Auth)获取指定 Git 服务器指定仓库的今日提交代码变更记录 (Asia/Shanghai)。同时提供 CLI 与 MCP server 双入口。

Readme

git-today-commits MCP&Agent挑战赛

一个用账号密码(HTTP Basic Auth)获取指定 Git 服务器指定仓库今日提交代码变更记录的 MCP Server,同时提供命令行(CLI)入口。以 Asia/Shanghai(UTC+8)时区为准,适用于自建 Git 服务(Bonobo / Gitea / Gogs / GitLab 等开启 HTTP 智能协议的场景)。

项目简介

在日常研发协作中,团队经常需要回顾「今天都有谁提交了什么代码、改了哪些文件」。对于自建 Git 服务器(尤其是 Bonobo Git Server 这类轻量方案),平台本身往往不提供便捷的「今日变更总览」能力,逐个分支翻看 git log 既繁琐又容易遗漏。

本项目把这一流程封装为一个标准 MCP(Model Context Protocol)工具 get_today_commits,让大模型 / AI Agent 能够直接调用,自动完成:

  1. 用账号密码(HTTP Basic Auth)克隆目标仓库到临时目录(bare clone,仅元数据,体积小)
  2. 按 Asia/Shanghai 时区计算今日时间范围(00:00:00 ~ 23:59:59 +08:00),用 git log --since/--until 过滤提交(按绝对时间过滤,不受运行机器时区影响)
  3. 输出每个提交的元信息(哈希、作者、时间、主题)与变更内容(文件统计 --stat + 完整 diff --patch)
  4. 运行结束自动清理临时目录,凭据不落盘

核心特点:

  • 双入口:既可作为 MCP Server 被 AI 客户端调用,也可作为命令行工具直接使用
  • 通用 Git HTTP:不依赖任何平台 REST API,只要仓库支持 git clone 即可
  • 安全:禁用 credential helper、GIT_TERMINAL_PROMPT=0 防止认证失败时交互挂起,凭据仅存于进程内存
  • 零框架依赖:CLI 模式仅用 Node.js 内置模块;MCP 模式依赖官方 @modelcontextprotocol/sdk

部署指南

环境依赖

  • Node.js ≥ 18
  • git(系统已安装,用于克隆与日志查询)

安装

git clone https://github.com/<你的用户名>/git-today-commits-mcp.git
cd git-today-commits-mcp
npm install

作为 MCP Server 使用(推荐)

在 MCP 客户端(Claude Desktop / Cursor / Cherry Studio 等)的配置文件中添加:

{
  "mcpServers": {
    "git-today-commits": {
      "command": "node",
      "args": ["/克隆到本地的绝对路径/mcp-server.js"]
    }
  }
}

配置后重启客户端,即可在对话中让 AI 调用 get_today_commits 工具。

关于魔搭托管部署: 本 MCP 为 Node.js 实现,魔搭 MCP 广场的「可托管部署」目前仅支持 Python(PyPI/uvx)与 Gradio 链路,因此本项目以「本地使用」方式接入:克隆仓库后在本地通过 node mcp-server.js 以 stdio 方式运行。

作为命令行工具使用

node index.js --server <URL> --repo <PATH> --user <USER> --password <PASS> [选项]

必填参数(也可用同名环境变量 GIT_SERVER / GIT_REPO / GIT_USER / GIT_PASSWORD):

| 参数 | 说明 | 示例 | |---|---|---| | --server | Git 服务器地址,含协议与端口 | http://www.example.com:8888 | | --repo | 仓库路径,可带或不带 .git 后缀 | group/project 或 owner/repo.git | | --user | 账号 | alice | | --password | 密码(可为空串) | secret |

可选参数:

| 参数 | 默认 | 说明 | |---|---|---| | --no-merges[=false] | 排除 | 是否排除合并提交,设 =false 则包含 | | --stat[=true] | false | 仅输出文件变更统计,不输出完整 diff | | -h, --help | — | 显示帮助 |

使用示例

示例 1:CLI 获取今日提交(完整 diff)

node index.js --server http://www.example.com:8888 --repo myproject.git --user alice --password secret

输出效果:

════════════════════════════════════════════════════════════
  Git 今日提交变更记录
════════════════════════════════════════════════════════════
服务器 : http://www.example.com:8888
仓库   : myproject.git
账号   : alice
时区   : Asia/Shanghai (UTC+8)
合并提交: 已排除
输出模式: 完整 diff (--stat -p)
════════════════════════════════════════════════════════════

日期   : 2026-08-02
时间范围: 2026-08-02T00:00:00+08:00 ~ 2026-08-02T23:59:59+08:00

今日提交数: 2

────────────────────────────────────────────────────────────
提交: 822756b
作者: 张三 <[email protected]>
日期: 2026-08-02 14:30:00 +0800
主题: feat(calc): 新增 sub 函数
---
 calc.js | 1 +
 1 file changed, 1 insertion(+)

diff --git a/calc.js b/calc.js
index 8d1f95e..8166ac6 100644
--- a/calc.js
+++ b/calc.js
@@ -1 +1,2 @@
 function add(a,b){return a+b}
+function sub(a,b){return a-b}
────────────────────────────────────────────────────────────

示例 2:AI Agent 调用 MCP 工具

在支持 MCP 的客户端对话中,AI 会自动调用 get_today_commits 工具,传入服务器、仓库、账号、密码等参数,返回结构化的提交变更文本,效果与示例 1 一致。工具支持 noMerges、statOnly 等可选参数。

示例 3:今日无提交

今日提交数: 0

本仓库今日 (Asia/Shanghai) 无提交记录。

示例 4:认证失败

[错误] 克隆失败: 账号或密码错误 (HTTP 认证失败)。
fatal: Authentication failed for 'http://www.example.com:8888/myproject.git/'

工具参数(MCP)

get_today_commits 工具的输入 schema:

| 参数 | 类型 | 必填 | 默认 | 说明 | |---|---|---|---|---| | server | string | 是 | — | Git 服务器地址 | | repo | string | 是 | — | 仓库路径 | | user | string | 是 | — | 账号 | | password | string | 是 | — | 密码(可为空串) | | noMerges | boolean | 否 | true | 是否排除合并提交 | | statOnly | boolean | 否 | false | 仅输出统计,不输出完整 diff |

注意事项

  • 仓库需开启 HTTP 智能协议(GitLab / Gitea / Gogs / Bonobo 默认开启;纯 git:// 协议不走账号密码,不适用)
  • 默认只查询仓库默认分支(HEAD,通常为 master/main);如需扫描所有分支,可自行扩展
  • 凭据通过 URL 临时传入进程内存,不写入磁盘缓存;但 URL 可能短暂出现在进程列表中,生产环境建议用环境变量传入
  • 密码属敏感信息,请勿在公开仓库中硬编码

License

MIT