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

mcp-git-fetcher

v0.1.8

Published

MCP server to fetch skills/rules files from internal GitLab repositories

Readme

mcp-git-fetcher

MCP 服务:从公司内部 GitLab 仓库下载 skills/rules 文件到指定目录,支持 Trae CN、Hermes Agent、Cursor 等各种 AI Agent 工具。

同时支持 Python 和 Node.js 双版本,Node.js 版已发布到 npm,推荐使用。


快速开始

方式 A:Node.js 全局安装(推荐)

# 直接安装到系统
npm install -g mcp-git-fetcher

# 启动服务
mcp-git-fetcher

或通过 npx 临时运行:

npx -y mcp-git-fetcher@latest

方式 B:Node.js 本地开发

git clone <repo-url>
cd mcp-git-fetcher
npm install
npm run build
npm start

方式 C:Python

pip install -e .
python -m mcp_git_fetcher.server

配置环境变量

复制 .env.example 为 .env,填入实际参数:

copy .env.example .env

| 变量 | 说明 | 示例 | |------|------|------| | GIT_REPO_URL | GitLab 仓库地址(必需) | http://your-gitlab/group/repo.git | | GIT_AUTH_TOKEN | GitLab Personal Access Token | glpat-xxxxxx | | GIT_BRANCH | 分支(默认 main) | main |

Token 说明:Token 只配在 MCP 客户端配置的 env 中,不会写进代码,也不会存到 git 缓存目录。

注册为 MCP 服务

Trae CN

编辑 %APPDATA%\Trae CN\User\mcp.json:

{
  "mcpServers": {
    "git-fetcher": {
      "command": "mcp-git-fetcher",
      "args": [],
      "env": {
        "GIT_REPO_URL": "http://your-gitlab/group/repo.git",
        "GIT_AUTH_TOKEN": "glpat-xxxxx"
      }
    }
  }
}

本地开发调试版:

{
  "mcpServers": {
    "git-fetcher": {
      "command": "node",
      "args": ["D:\\your-path\\mcp-git-fetcher\\dist\\cli.js"],
      "env": {
        "GIT_REPO_URL": "http://your-gitlab/group/repo.git",
        "GIT_AUTH_TOKEN": "glpat-xxxxx"
      }
    }
  }
}

Hermes Agent

mcp_servers:
  git-fetcher:
    command: "mcp-git-fetcher"
    args: []
    env:
      GIT_REPO_URL: "http://your-gitlab/group/repo.git"
      GIT_AUTH_TOKEN: "glpat-xxxxx"
    connect_timeout: 60
    timeout: 300

提供工具

该 MCP 服务暴露三个工具:

list_resources

功能:扫描 GitLab 仓库,列出所有 skills/rules 文件及描述信息。

参数:

| 参数 | 必需 | 说明 | |------|------|------| | category | ❌ | 筛选类型:skills / rules / all(默认) | | pattern | ❌ | 按文件名 glob 过滤,如 react*、*.md | | repo_url | ❌ | 临时覆盖仓库 URL |

返回示例:

{
  "success": true,
  "message": "Found 15 resources (commit a1b2c3d4)",
  "resources": {
    "skills": [
      { "name": "brainstorming", "description": "创意脑暴和方案设计流程" }
    ],
    "rules": [
      { "name": "agent_routing_rule.md", "description": "智能体路由规则" }
    ]
  }
}

download_resources

功能:按文件名模式选择性下载 skills/rules。

参数:

| 参数 | 必需 | 说明 | |------|------|------| | patterns | ✅ | 文件名匹配模式,如 ["react*", "*.md"] | | target_skills_dir | ❌ | skills 写入目录 | | target_rules_dir | ❌ | rules 写入目录 | | category | ❌ | 筛选类型:skills / rules / all(默认) | | repo_url | ❌ | 临时覆盖仓库 URL |

返回示例:

{
  "success": true,
  "message": "Downloaded 2 files (0 skipped, commit a1b2c3d4)",
  "copied": 2,
  "skipped": 0
}

fetch_resources

功能:全量同步所有 skills/rules 到目标目录。

参数:

| 参数 | 必需 | 说明 | |------|------|------| | target_skills_dir | ✅ | skills 写入目录 | | target_rules_dir | ✅ | rules 写入目录 | | repo_url | ❌ | 临时覆盖仓库 URL |

返回示例:

{
  "success": true,
  "message": "Synced 12 files (3 skipped, commit a1b2c3d4)",
  "skills": { "copied": 8, "skipped": 2, "errors": [] },
  "rules": { "copied": 4, "skipped": 1, "errors": [] }
}

工作原理

Agent/IDE → 调用 MCP 工具
  ├─ ① git clone/pull 到本地缓存 (~/.mcp-git-fetcher/cache/)
  ├─ ② 提取仓库中的 skills/ 和 rules/
  └─ ③ 复制到目标目录(SHA-256 去重,相同则跳过)
  • 增量更新:第二次调用只需 git pull,更快
  • 内容去重:SHA-256 对比,内容不变不写盘
  • 描述提取:自动读取文件头部注释/标题作为描述
  • Token 安全:只存在于客户端配置,不进代码和 git 缓存

项目结构

mcp-git-fetcher/
├── mcp_git_fetcher/          # Python 版源码
│   ├── server.py             # MCP 服务入口
│   ├── git_ops.py            # Git 操作
│   ├── file_sync.py          # 文件同步
│   └── config.py             # 配置管理
├── src/                      # Node.js 版源码 (TypeScript)
│   ├── cli.ts                # MCP 服务主入口
│   ├── entry.ts              # 入口 shim(兼容 Windows npm)
│   ├── config.ts             # 配置管理
│   ├── git-ops.ts            # Git 操作
│   ├── file-sync.ts          # 文件同步
│   └── analyzer.ts           # 文件内容分析
├── dist/                     # TypeScript 编译产物
├── package.json              # Node.js 依赖 + npm 发布配置
├── pyproject.toml            # Python 依赖
├── .env.example              # 环境变量模板
├── .gitignore
└── README.md

环境变量

| 变量 | 必需 | 默认值 | 说明 | |------|------|--------|------| | GIT_REPO_URL | ✅ | — | GitLab 仓库 HTTP(S) 地址 | | GIT_AUTH_TOKEN | ❌ | — | GitLab Personal Access Token | | GIT_BRANCH | ❌ | main | 拉取的分支 | | SKILLS_SUBDIR | ❌ | skills | 仓库内 skills 目录名 | | RULES_SUBDIR | ❌ | rules | 仓库内 rules 目录名 | | CACHE_DIR | ❌ | ~/.mcp-git-fetcher/cache | 本地 Git 缓存目录 | | HTTP_PROXY | ❌ | — | HTTP 代理 | | HTTPS_PROXY | ❌ | — | HTTPS 代理 |


开发

# Node.js 版
npm install
npm run build
npm start

# Python 版
pip install -e .
python -m mcp_git_fetcher.server

License

MIT