Skip to main content

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 中提交。

Metadata

Release files for mcp-git-config 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-git-config 1.1.0
File Size Uploaded Provenance
mcp_git_config-1.1.0.tar.gz 95.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-git-config 1.1.0
File Interpreter ABI Platform
mcp_git_config-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 103.2 kB

Release files / mcp_git_config-1.1.0.tar.gz

Download URL mcp_git_config-1.1.0.tar.gz
Size 95.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0ab27259ebb0b61162d4bc49b5391441349d289842e608c525e71a990beb24f7
BLAKE2b-256 checksum
How to use checksums
a45e8fb03e299689bb7af7acee688adc40443bb5891394b4aa6b19ac283b0a89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / mcp_git_config-1.1.0-py3-none-any.whl

Download URL mcp_git_config-1.1.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a18d5276e76e016b4167edcf512ca79792ce01a26b45c85cd54a4bdb1037667
BLAKE2b-256 checksum
How to use checksums
e503fc472d25b65e8b8ae89d1881ebcad6444055677ee9e15a1b78ea4afa2571
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Security for mcp-git-config 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page