MCP server for Git repository detection and username retrieval
Project description
MCP Git Config Server
一个专门用于 Git 仓库检测和用户名获取的 Model Context Protocol (MCP) 服务器。
作者: shizeying
创建日期: 2025-08-04
版本: 1.1.0
功能特性
该 MCP 服务器提供四个主要工具:
1. is_git_repository
检测指定路径(或当前目录)是否为 Git 仓库。
参数:
path(可选): 要检查的路径,默认为当前工作目录
返回:
{
"is_git_repo": true,
"path": "/path/to/check",
"git_dir": "/path/to/check/.git",
"error": null
}
2. get_git_username
从 Git 配置中获取用户名和邮箱信息。
参数:
path(可选): Git 仓库路径,默认为当前工作目录config_type(可选): 配置类型 - "local", "global", 或 "auto" (默认)
返回:
{
"username": "Your Name",
"email": "your.email@example.com",
"config_type": "local",
"path": "/path/to/repo",
"is_git_repo": true,
"error": null
}
3. set_working_dir
设置工作目录,后续的 Git 操作将在此目录下进行。
参数:
path: 要设置为工作目录的路径
返回:
{
"success": true,
"old_dir": "/previous/working/directory",
"new_dir": "/new/working/directory",
"error": null
}
4. get_working_dir
获取当前设置的工作目录。
参数: 无
返回:
{
"current_dir": "/current/working/directory",
"is_custom": true,
"error": null
}
安装方式
方式 1: 使用 uvx (推荐)
uvx mcp-git-config
方式 2: 使用 pip
pip install mcp-git-config
方式 3: 从源码安装
git clone https://github.com/shizeying/mcp-git-config.git
cd mcp-git-config
uv pip install -e .
使用方法
作为 MCP 服务器运行
# 使用 uvx
uvx mcp-git-config
# 使用 python -m
python -m mcp_git_config
# 直接使用命令
mcp-git-config
在 Claude Desktop 中配置
在 Claude Desktop 的配置文件中添加:
{
"mcpServers": {
"git-config": {
"command": "uvx",
"args": ["mcp-git-config"]
}
}
}
在 Zed 编辑器中配置
在 Zed 的设置中添加:
{
"assistant": {
"default_model": {
"provider": "anthropic",
"model": "claude-3-5-sonnet-20241022"
},
"version": "2",
"provider": {
"name": "anthropic",
"type": "anthropic"
}
},
"context_servers": [
{
"id": "git-config",
"executable": "uvx",
"args": ["mcp-git-config"]
}
]
}
开发
环境设置
# 克隆仓库
git clone https://github.com/shizeying/mcp-git-config.git
cd mcp-git-config
# 安装开发依赖
uv sync --all-extras --dev
# 安装 pre-commit 钩子
uv run pre-commit install
运行测试
# 运行所有测试
uv run pytest
# 运行测试并显示覆盖率
uv run pytest --cov=mcp_git_config
# 运行 linting
uv run ruff check .
uv run ruff format .
# 类型检查
uv run mypy src/
本地测试服务器
# 运行服务器
python -m mcp_git_config
# 或者
uv run python -m mcp_git_config
技术细节
- 语言: Python 3.8+
- 依赖管理: uv
- MCP 框架: FastMCP
- 测试框架: pytest
- 代码格式化: ruff
- 类型检查: mypy
CI/CD 流水线
项目使用 GitHub Actions 进行持续集成和部署:
- CI: 在多个 Python 版本上运行测试、linting 和类型检查
- 发布: 当推送 tag 时自动发布到 PyPI
- 代码质量: 使用 pre-commit 确保代码质量
许可证
MIT License - 查看 LICENSE 文件了解详情。
贡献
欢迎贡献代码!请查看 CONTRIBUTING.md 了解贡献指南。
支持
如果遇到问题或有功能请求,请在 GitHub Issues 中提交。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_git_config-1.1.0.tar.gz.
File metadata
- Download URL: mcp_git_config-1.1.0.tar.gz
- Upload date:
- Size: 95.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ab27259ebb0b61162d4bc49b5391441349d289842e608c525e71a990beb24f7
|
|
| MD5 |
164c655bf33ec1b1997c1e860ae350b0
|
|
| BLAKE2b-256 |
a45e8fb03e299689bb7af7acee688adc40443bb5891394b4aa6b19ac283b0a89
|
File details
Details for the file mcp_git_config-1.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_git_config-1.1.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a18d5276e76e016b4167edcf512ca79792ce01a26b45c85cd54a4bdb1037667
|
|
| MD5 |
c5529eb4454e8e22b340dfa86d548969
|
|
| BLAKE2b-256 |
e503fc472d25b65e8b8ae89d1881ebcad6444055677ee9e15a1b78ea4afa2571
|