工具列表
內容詳情
替代品
安裝
🚀 MCP Git Commit Generator
MCP Git Commit Generator 藉助 Model Context Protocol (MCP),依據你暫存的 Git 更改自動生成符合規範的提交信息,助力高效的版本管理。
✨ 主要特性
- 自動生成提交信息:基於暫存的 Git 差異自動生成提交信息。
- 支持規範提交:支持 Conventional Commits 規範。
- 靈活的傳輸選項:MCP 服務器提供標準輸入輸出(默認)和 Server-Sent Events (SSE) 兩種傳輸方式。
- 交互式檢查界面:通過 MCP Inspector 提供交互式檢查界面。
📦 安裝要求
- 使用 Docker:需安裝 Docker 以在容器中運行服務器。
- 使用 PyPI/uvx:需要 Python >= 3.13.5 以及 uv(推薦)或 pip。
- 版本控制:需安裝 Git 進行版本控制。
- 兼容客戶端:需要一個支持 MCP 的客戶端,如帶有 MCP 擴展的 VS Code、Claude Desktop、Cursor、Windsurf 等。
🚀 快速開始
📦 安裝
你可以通過多種方式安裝和使用 MCP Git Commit Generator:
選項 1:使用 uvx(推薦)
使用 uvx 是使用該包的最簡單方式,它會自動管理虛擬環境:
uvx mcp-git-commit-generator
選項 2:從 PyPI 安裝
pip install mcp-git-commit-generator
或者使用 uv:
uv pip install mcp-git-commit-generator
選項 3:使用 Docker
使用來自 GitHub Container Registry 的預構建 Docker 鏡像(無需安裝):
docker run -i --rm --mount type=bind,src=${HOME},dst=${HOME} ghcr.io/theoklitosbam7/mcp-git-commit-generator:latest
💻 配置 MCP 客戶端
根據你的客戶端,選擇合適的配置方式:
VS Code
在 VS Code 的 mcp.json 文件(通常位於工作區的 .vscode/mcp.json)中添加以下配置之一:
使用 uvx(推薦)
{
"servers": {
"mcp-git-commit-generator": {
"command": "uvx",
"args": ["mcp-git-commit-generator"]
}
}
}
使用 Docker
{
"servers": {
"mcp-git-commit-generator": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--mount",
"type=bind,src=${userHome},dst=${userHome}",
"ghcr.io/theoklitosbam7/mcp-git-commit-generator:latest"
]
}
}
}
如果你想將配置添加到用戶的 settings.json 文件中,可以這樣做:
{
"mcp": {
"servers": {
"mcp-git-commit-generator": {
"command": "uvx",
"args": ["mcp-git-commit-generator"]
}
}
}
}
Cursor
在 Cursor 的 MCP 配置文件(通常位於 ~/.cursor/mcp.json)中添加以下配置之一:
使用 uvx(推薦)
{
"mcpServers": {
"mcp-git-commit-generator": {
"command": "uvx",
"args": ["mcp-git-commit-generator"]
}
}
}
使用 Docker
{
"mcpServers": {
"mcp-git-commit-generator": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--mount",
"type=bind,src=${userHome},dst=${userHome}",
"ghcr.io/theoklitosbam7/mcp-git-commit-generator:latest"
]
}
}
}
Windsurf
在 Windsurf 的 MCP 服務器設置文件(通常位於 ~/.codeium/windsurf/mcp_config.json)中添加以下配置之一:
使用 uvx(推薦)
{
"mcpServers": {
"mcp-git-commit-generator": {
"command": "uvx",
"args": ["mcp-git-commit-generator"]
}
}
}
使用 Docker
{
"mcpServers": {
"mcp-git-commit-generator": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--mount",
"type=bind,src=${userHome},dst=${userHome}",
"ghcr.io/theoklitosbam7/mcp-git-commit-generator:latest"
]
}
}
}
Claude Desktop
在 Claude Desktop 的配置文件(在 macOS 上通常位於 ~/Library/Application Support/Claude/claude_desktop_config.json)中添加以下配置之一:
使用 uvx(推薦)
{
"mcpServers": {
"mcp-git-commit-generator": {
"command": "uvx",
"args": ["mcp-git-commit-generator"]
}
}
}
使用 Docker
{
"mcpServers": {
"mcp-git-commit-generator": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--mount",
"type=bind,src=${userHome},dst=${userHome}",
"ghcr.io/theoklitosbam7/mcp-git-commit-generator:latest"
]
}
}
}
⚠️ 重要提示
Docker 配置中的
--mount選項允許 Docker 容器訪問你的主目錄,使其能夠處理文件系統中任何位置的 Git 倉庫。使用 uvx 或 pip 安裝時,不需要此掛載,因為工具直接在你的系統上運行。如果使用 Docker 時倉庫位於其他位置,請調整掛載路徑。
🚀 開始使用
- 安裝包:使用上述方法之一安裝包。
- 配置 MCP 客戶端:使用上述配置之一配置你的 MCP 客戶端。
- 暫存更改:在 Git 倉庫中暫存一些更改:
git add <files> - 使用工具:通過 MCP 客戶端使用工具:
- 使用
check_git_status查看當前倉庫狀態。 - 使用
generate_commit_message創建符合規範的提交信息。
- 使用
- 提交更改:使用生成的信息提交更改。
🛠️ 可用工具
generate_commit_message
根據你暫存的 Git 更改生成符合規範的提交信息。 參數:
repo_path(字符串,可選):Git 倉庫的路徑。如果省略,使用當前目錄。commit_type(字符串,可選):符合規範的提交類型(例如,feat、fix、docs、style、refactor、perf、build、ci、test、chore、revert)。如果省略,類型將自動檢測。scope(字符串,可選):更改的範圍(例如,文件或模塊名稱)。如果省略,範圍將根據更改的文件自動檢測。 用法:
- 暫存更改:
git add <files> - 通過 MCP 客戶端使用該工具生成提交信息。
- 工具將分析你暫存的更改並生成合適的符合規範的提交信息。
check_git_status
檢查當前 Git 倉庫的狀態,包括已暫存、未暫存和未跟蹤的文件。 參數:
repo_path(字符串,可選):Git 倉庫的路徑。如果省略,使用當前目錄。 用法: 在生成提交信息之前,使用此工具查看當前 Git 倉庫的狀態。
👨💻 開發者指南
🛠️ 本地開發設置
如果你不想在開發中使用 Docker,可以在本地運行服務器: 要求:
- Python >= 3.13.5
- MCP CLI >= 1.10.1
- uv(用於依賴管理,可選但推薦)
- Node.js(用於 Inspector UI,可選)
- Python Debugger Extension(用於調試,可選) 安裝:
-
克隆倉庫:
git clone https://github.com/theoklitosBam7/mcp-git-commit-generator.git cd mcp-git-commit-generator -
準備環境: 有兩種方法可以為這個項目設置環境。你可以根據自己的喜好選擇其中一種。
注意:創建虛擬環境後,重新加載 VSCode 或終端以確保使用虛擬環境中的 Python。
方法 步驟 使用 uv1. 創建虛擬環境: uv venv
2. 運行 VSCode 命令 "Python: Select Interpreter" 並選擇創建的虛擬環境中的 Python
3. 安裝依賴(包括開發依賴):uv pip install -r pyproject.toml --group dev
4. 使用以下命令安裝mcp-git-commit-generator:uv pip install -e .。使用 pip1. 創建虛擬環境: python -m venv .venv
2. 運行 VSCode 命令 "Python: Select Interpreter" 並選擇創建的虛擬環境中的 Python
3. 安裝依賴:pip install -e .。
4. 安裝 pip 開發依賴:pip install -r requirements-dev.txt。 -
(可選)安裝 Inspector 依賴:
cd inspector npm install
📦 發佈到 PyPI
項目包含一個自動化的 PyPI 發佈工作流(.github/workflows/pypi-publish.yml),它:
- 觸發條件:當推送匹配
v*.*.*模式的標籤、手動觸發工作流或向主分支提交拉取請求時觸發。 - 構建:使用
build包構建 Python 包分發。 - 發佈:當推送標籤時,使用可信發佈(OIDC)自動發佈到 PyPI。 要發佈新版本:
- 在
pyproject.toml中更新版本。 - 創建並推送 Git 標籤:
git tag vX.Y.Z && git push origin vX.Y.Z - 工作流將自動構建併發布到 PyPI。
🐳 使用 Docker 構建和運行
你可以使用 Docker 構建和運行 MCP Git Commit Generator。提供的 Dockerfile 使用多階段構建,使用 uv 進行依賴管理,並以非根用戶身份運行服務器以提高安全性。
構建 Docker 鏡像
docker build -t mcp-git-commit-generator .
在容器中運行服務器(默認:stdio 傳輸)
你可以直接從 GitHub Container Registry 運行已發佈的鏡像。
docker run -d \
--name mcp-git-commit-generator \
ghcr.io/theoklitosbam7/mcp-git-commit-generator:latest
默認情況下,容器運行:
mcp-git-commit-generator --transport stdio
如果你想使用 SSE 傳輸(用於 Inspector UI 或遠程訪問),可以覆蓋入口點或手動運行:
docker run -d \
--name mcp-git-commit-generator \
-p 3001:3001 \
--entrypoint mcp-git-commit-generator \
ghcr.io/theoklitosbam7/mcp-git-commit-generator:latest --transport sse --host 0.0.0.0 --port 3001
使用 SSE 時,服務器將在 http://localhost:3001 可用。
🖥️ 本地運行服務器
本地運行(不使用 Docker):
- 按照本地開發設置部分的說明設置 uv 或 Python 環境。
- 從項目根目錄運行:
mcp-git-commit-generator
```sh # 如果你在環境中安裝了 mcp-git-commit-generator(默認:stdio) mcp-git-commit-generator ```mcp-git-commit-generator with SSE transport
```sh mcp-git-commit-generator --transport sse ```Using uv
```sh uv run -m mcp_git_commit_generator --transport sse ```Using Python directly
```sh python -m mcp_git_commit_generator --transport sse ```你可以指定其他選項,例如: ```sh python -m mcp_git_commit_generator --transport sse --host 0.0.0.0 --port 3001 -v ``` > 使用 SSE 時,服務器默認監聽 `0.0.0.0:3001`,或根據上述選項指定的地址。 **注意**: - 如果你想使用 CLI 入口點,請確保包已安裝且環境已激活。 - 不要使用位置參數(例如,`python -m mcp_git_commit_generator sse`);始終使用選項,如 `--transport sse`。 - 可用的參數及其值如下: - `--transport`:傳輸類型(例如,`stdio`(默認)、`sse`)。 - `--host`:綁定服務器的主機(默認:`0.0.0.0`)。 - `--port`:綁定服務器的端口(默認:`3001`)。 - `-v`, `--verbose`:詳細程度(例如,`-v`、`-vv`)。
🔎 啟動 Inspector UI
從 inspector 目錄運行:
npm run dev:inspector
Inspector UI 將在
http://localhost:5173可用。
🗂️ 項目結構
.
├── .github/ # GitHub 工作流和問題模板
├── .gitignore
├── .markdownlint.jsonc
├── .python-version
├── .vscode/ # VSCode 配置
├── LICENSE
├── README.md
├── pyproject.toml # Python 項目配置
├── requirements-dev.txt # 開發依賴
├── uv.lock # Python 依賴鎖定文件
├── Dockerfile # Docker 構建文件
├── build/ # 構建工件
├── src/ # Python 源代碼
│ └── mcp_git_commit_generator/
│ ├── __init__.py # 主入口點
│ ├── __main__.py # CLI 入口點
│ └── server.py # 主服務器實現
└── inspector/ # Inspector 相關文件
├── package.json # Node.js 依賴
└── package-lock.json
⚙️ 開發用高級 MCP 服務器配置
.vscode/mcp.json 文件配置了 VS Code 和相關工具如何連接到 MCP Git Commit Generator 服務器。該文件定義了可用的服務器傳輸方式及其連接詳細信息,使你可以輕鬆在不同模式(默認是 stdio,可選 SSE)之間切換進行開發和調試。
示例開發 mcp.json
{
"servers": {
"mcp-git-commit-generator": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--mount",
"type=bind,src=${userHome},dst=${userHome}",
"ghcr.io/theoklitosbam7/mcp-git-commit-generator:latest"
]
},
"sse-mcp-git-commit-generator": {
"type": "sse",
"url": "http://localhost:3001/sse"
},
"stdio-mcp-git-commit-generator": {
"type": "stdio",
"command": "${command:python.interpreterPath}",
"args": ["-m", "mcp_git_commit_generator", "--transport", "stdio"]
},
"uvx-mcp-git-commit-generator": {
"command": "uvx",
"args": ["mcp-git-commit-generator"]
}
}
}
- mcp-git-commit-generator:在 Docker 容器中運行服務器(默認:stdio 傳輸),使用已發佈的鏡像。
- sse-mcp-git-commit-generator:使用 Server-Sent Events (SSE) 在
http://localhost:3001/sse連接到 MCP 服務器。僅在使用--transport sse運行服務器時有用。 - stdio-mcp-git-commit-generator:使用標準輸入輸出 (stdio) 連接,將服務器作為子進程運行。這是默認的,也是本地開發和調試的推薦方式。
- uvx-mcp-git-commit-generator:使用 uvx 自動從 PyPI 安裝和運行包。
🐞 調試 MCP 服務器
注意:
- MCP Inspector 是一個用於測試和調試 MCP 服務器的可視化開發工具。
- 所有調試模式都支持斷點,因此你可以在工具實現代碼中添加斷點。
- 你可以在 Inspector UI 中直接測試工具參數:使用 Inspector 時,選擇一個工具並在輸入字段中提供參數,以模擬實際使用並調試參數處理。
| 調試模式 | 描述 | 調試步驟 |
|---|---|---|
| MCP Inspector | 使用 MCP Inspector 調試 MCP 服務器。 | 1. 安裝 Node.js 2. 設置 Inspector: cd inspector 並執行 npm install 3. 打開 VS Code 調試面板。選擇 Debug in Inspector (Edge) 或 Debug in Inspector (Chrome)。按 F5 開始調試。4. 當 MCP Inspector 在瀏覽器中啟動時,點擊 Connect 按鈕連接此 MCP 服務器。5. 然後你可以 List Tools,選擇一個工具,輸入參數(見上述參數),並 Run Tool 來調試服務器代碼。 |
⚙️ 默認端口和自定義設置
| 調試模式 | 端口 | 定義 | 自定義 | 注意 |
|---|---|---|---|---|
| MCP Inspector | 3001(服務器,僅 SSE);5173 和 3000(Inspector) | tasks.json | 編輯 launch.json、tasks.json、__init__.py、mcp.json 以更改上述端口。 | 無 |
💬 反饋
如果你有任何反饋或建議,請在 MCP Git Commit Generator GitHub 倉庫 上創建一個問題。
📄 許可證
MIT 許可證 © 2025 Theoklitos Bampouris
替代品









