mcp-git-config


Namemcp-git-config JSON
Version 1.1.0 PyPI version JSON
download
home_pageNone
SummaryMCP server for Git repository detection and username retrieval
upload_time2025-08-04 05:15:30
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License
keywords git mcp model-context-protocol server
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MCP Git Config Server

一个专门用于 Git 仓库检测和用户名获取的 Model Context Protocol (MCP) 服务器。

**作者**: shizeying  
**创建日期**: 2025-08-04  
**版本**: 1.1.0

## 功能特性

该 MCP 服务器提供四个主要工具:

### 1. `is_git_repository`
检测指定路径(或当前目录)是否为 Git 仓库。

**参数**:
- `path` (可选): 要检查的路径,默认为当前工作目录

**返回**:
```json
{
  "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" (默认)

**返回**:
```json
{
  "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`: 要设置为工作目录的路径

**返回**:
```json
{
  "success": true,
  "old_dir": "/previous/working/directory",
  "new_dir": "/new/working/directory",
  "error": null
}
```

### 4. `get_working_dir`
获取当前设置的工作目录。

**参数**: 无

**返回**:
```json
{
  "current_dir": "/current/working/directory",
  "is_custom": true,
  "error": null
}
```

## 安装方式

### 方式 1: 使用 uvx (推荐)
```bash
uvx mcp-git-config
```

### 方式 2: 使用 pip
```bash
pip install mcp-git-config
```

### 方式 3: 从源码安装
```bash
git clone https://github.com/shizeying/mcp-git-config.git
cd mcp-git-config
uv pip install -e .
```

## 使用方法

### 作为 MCP 服务器运行
```bash
# 使用 uvx
uvx mcp-git-config

# 使用 python -m
python -m mcp_git_config

# 直接使用命令
mcp-git-config
```

### 在 Claude Desktop 中配置

在 Claude Desktop 的配置文件中添加:

```json
{
  "mcpServers": {
    "git-config": {
      "command": "uvx",
      "args": ["mcp-git-config"]
    }
  }
}
```

### 在 Zed 编辑器中配置

在 Zed 的设置中添加:

```json
{
  "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"]
    }
  ]
}
```

## 开发

### 环境设置
```bash
# 克隆仓库
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
```

### 运行测试
```bash
# 运行所有测试
uv run pytest

# 运行测试并显示覆盖率
uv run pytest --cov=mcp_git_config

# 运行 linting
uv run ruff check .
uv run ruff format .

# 类型检查
uv run mypy src/
```

### 本地测试服务器
```bash
# 运行服务器
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](LICENSE) 文件了解详情。

## 贡献

欢迎贡献代码!请查看 [CONTRIBUTING.md](CONTRIBUTING.md) 了解贡献指南。

## 支持

如果遇到问题或有功能请求,请在 [GitHub Issues](https://github.com/shizeying/mcp-git-config/issues) 中提交。
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mcp-git-config",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "git, mcp, model-context-protocol, server",
    "author": null,
    "author_email": "shizeying <w741069229@163.com>",
    "download_url": "https://files.pythonhosted.org/packages/a4/5e/8fb03e299689bb7af7acee688adc40443bb5891394b4aa6b19ac283b0a89/mcp_git_config-1.1.0.tar.gz",
    "platform": null,
    "description": "# MCP Git Config Server\n\n\u4e00\u4e2a\u4e13\u95e8\u7528\u4e8e Git \u4ed3\u5e93\u68c0\u6d4b\u548c\u7528\u6237\u540d\u83b7\u53d6\u7684 Model Context Protocol (MCP) \u670d\u52a1\u5668\u3002\n\n**\u4f5c\u8005**: shizeying  \n**\u521b\u5efa\u65e5\u671f**: 2025-08-04  \n**\u7248\u672c**: 1.1.0\n\n## \u529f\u80fd\u7279\u6027\n\n\u8be5 MCP \u670d\u52a1\u5668\u63d0\u4f9b\u56db\u4e2a\u4e3b\u8981\u5de5\u5177\uff1a\n\n### 1. `is_git_repository`\n\u68c0\u6d4b\u6307\u5b9a\u8def\u5f84\uff08\u6216\u5f53\u524d\u76ee\u5f55\uff09\u662f\u5426\u4e3a Git \u4ed3\u5e93\u3002\n\n**\u53c2\u6570**:\n- `path` (\u53ef\u9009): \u8981\u68c0\u67e5\u7684\u8def\u5f84\uff0c\u9ed8\u8ba4\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\n\n**\u8fd4\u56de**:\n```json\n{\n  \"is_git_repo\": true,\n  \"path\": \"/path/to/check\",\n  \"git_dir\": \"/path/to/check/.git\",\n  \"error\": null\n}\n```\n\n### 2. `get_git_username`\n\u4ece Git \u914d\u7f6e\u4e2d\u83b7\u53d6\u7528\u6237\u540d\u548c\u90ae\u7bb1\u4fe1\u606f\u3002\n\n**\u53c2\u6570**:\n- `path` (\u53ef\u9009): Git \u4ed3\u5e93\u8def\u5f84\uff0c\u9ed8\u8ba4\u4e3a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\n- `config_type` (\u53ef\u9009): \u914d\u7f6e\u7c7b\u578b - \"local\", \"global\", \u6216 \"auto\" (\u9ed8\u8ba4)\n\n**\u8fd4\u56de**:\n```json\n{\n  \"username\": \"Your Name\",\n  \"email\": \"your.email@example.com\",\n  \"config_type\": \"local\",\n  \"path\": \"/path/to/repo\",\n  \"is_git_repo\": true,\n  \"error\": null\n}\n```\n\n### 3. `set_working_dir`\n\u8bbe\u7f6e\u5de5\u4f5c\u76ee\u5f55\uff0c\u540e\u7eed\u7684 Git \u64cd\u4f5c\u5c06\u5728\u6b64\u76ee\u5f55\u4e0b\u8fdb\u884c\u3002\n\n**\u53c2\u6570**:\n- `path`: \u8981\u8bbe\u7f6e\u4e3a\u5de5\u4f5c\u76ee\u5f55\u7684\u8def\u5f84\n\n**\u8fd4\u56de**:\n```json\n{\n  \"success\": true,\n  \"old_dir\": \"/previous/working/directory\",\n  \"new_dir\": \"/new/working/directory\",\n  \"error\": null\n}\n```\n\n### 4. `get_working_dir`\n\u83b7\u53d6\u5f53\u524d\u8bbe\u7f6e\u7684\u5de5\u4f5c\u76ee\u5f55\u3002\n\n**\u53c2\u6570**: \u65e0\n\n**\u8fd4\u56de**:\n```json\n{\n  \"current_dir\": \"/current/working/directory\",\n  \"is_custom\": true,\n  \"error\": null\n}\n```\n\n## \u5b89\u88c5\u65b9\u5f0f\n\n### \u65b9\u5f0f 1: \u4f7f\u7528 uvx (\u63a8\u8350)\n```bash\nuvx mcp-git-config\n```\n\n### \u65b9\u5f0f 2: \u4f7f\u7528 pip\n```bash\npip install mcp-git-config\n```\n\n### \u65b9\u5f0f 3: \u4ece\u6e90\u7801\u5b89\u88c5\n```bash\ngit clone https://github.com/shizeying/mcp-git-config.git\ncd mcp-git-config\nuv pip install -e .\n```\n\n## \u4f7f\u7528\u65b9\u6cd5\n\n### \u4f5c\u4e3a MCP \u670d\u52a1\u5668\u8fd0\u884c\n```bash\n# \u4f7f\u7528 uvx\nuvx mcp-git-config\n\n# \u4f7f\u7528 python -m\npython -m mcp_git_config\n\n# \u76f4\u63a5\u4f7f\u7528\u547d\u4ee4\nmcp-git-config\n```\n\n### \u5728 Claude Desktop \u4e2d\u914d\u7f6e\n\n\u5728 Claude Desktop \u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\uff1a\n\n```json\n{\n  \"mcpServers\": {\n    \"git-config\": {\n      \"command\": \"uvx\",\n      \"args\": [\"mcp-git-config\"]\n    }\n  }\n}\n```\n\n### \u5728 Zed \u7f16\u8f91\u5668\u4e2d\u914d\u7f6e\n\n\u5728 Zed \u7684\u8bbe\u7f6e\u4e2d\u6dfb\u52a0\uff1a\n\n```json\n{\n  \"assistant\": {\n    \"default_model\": {\n      \"provider\": \"anthropic\",\n      \"model\": \"claude-3-5-sonnet-20241022\"\n    },\n    \"version\": \"2\",\n    \"provider\": {\n      \"name\": \"anthropic\",\n      \"type\": \"anthropic\"\n    }\n  },\n  \"context_servers\": [\n    {\n      \"id\": \"git-config\",\n      \"executable\": \"uvx\",\n      \"args\": [\"mcp-git-config\"]\n    }\n  ]\n}\n```\n\n## \u5f00\u53d1\n\n### \u73af\u5883\u8bbe\u7f6e\n```bash\n# \u514b\u9686\u4ed3\u5e93\ngit clone https://github.com/shizeying/mcp-git-config.git\ncd mcp-git-config\n\n# \u5b89\u88c5\u5f00\u53d1\u4f9d\u8d56\nuv sync --all-extras --dev\n\n# \u5b89\u88c5 pre-commit \u94a9\u5b50\nuv run pre-commit install\n```\n\n### \u8fd0\u884c\u6d4b\u8bd5\n```bash\n# \u8fd0\u884c\u6240\u6709\u6d4b\u8bd5\nuv run pytest\n\n# \u8fd0\u884c\u6d4b\u8bd5\u5e76\u663e\u793a\u8986\u76d6\u7387\nuv run pytest --cov=mcp_git_config\n\n# \u8fd0\u884c linting\nuv run ruff check .\nuv run ruff format .\n\n# \u7c7b\u578b\u68c0\u67e5\nuv run mypy src/\n```\n\n### \u672c\u5730\u6d4b\u8bd5\u670d\u52a1\u5668\n```bash\n# \u8fd0\u884c\u670d\u52a1\u5668\npython -m mcp_git_config\n\n# \u6216\u8005\nuv run python -m mcp_git_config\n```\n\n## \u6280\u672f\u7ec6\u8282\n\n- **\u8bed\u8a00**: Python 3.8+\n- **\u4f9d\u8d56\u7ba1\u7406**: uv\n- **MCP \u6846\u67b6**: FastMCP\n- **\u6d4b\u8bd5\u6846\u67b6**: pytest\n- **\u4ee3\u7801\u683c\u5f0f\u5316**: ruff\n- **\u7c7b\u578b\u68c0\u67e5**: mypy\n\n## CI/CD \u6d41\u6c34\u7ebf\n\n\u9879\u76ee\u4f7f\u7528 GitHub Actions \u8fdb\u884c\u6301\u7eed\u96c6\u6210\u548c\u90e8\u7f72\uff1a\n\n- **CI**: \u5728\u591a\u4e2a Python \u7248\u672c\u4e0a\u8fd0\u884c\u6d4b\u8bd5\u3001linting \u548c\u7c7b\u578b\u68c0\u67e5\n- **\u53d1\u5e03**: \u5f53\u63a8\u9001 tag \u65f6\u81ea\u52a8\u53d1\u5e03\u5230 PyPI\n- **\u4ee3\u7801\u8d28\u91cf**: \u4f7f\u7528 pre-commit \u786e\u4fdd\u4ee3\u7801\u8d28\u91cf\n\n## \u8bb8\u53ef\u8bc1\n\nMIT License - \u67e5\u770b [LICENSE](LICENSE) \u6587\u4ef6\u4e86\u89e3\u8be6\u60c5\u3002\n\n## \u8d21\u732e\n\n\u6b22\u8fce\u8d21\u732e\u4ee3\u7801\uff01\u8bf7\u67e5\u770b [CONTRIBUTING.md](CONTRIBUTING.md) \u4e86\u89e3\u8d21\u732e\u6307\u5357\u3002\n\n## \u652f\u6301\n\n\u5982\u679c\u9047\u5230\u95ee\u9898\u6216\u6709\u529f\u80fd\u8bf7\u6c42\uff0c\u8bf7\u5728 [GitHub Issues](https://github.com/shizeying/mcp-git-config/issues) \u4e2d\u63d0\u4ea4\u3002",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "MCP server for Git repository detection and username retrieval",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/shizeying/mcp-git-config",
        "Issues": "https://github.com/shizeying/mcp-git-config/issues",
        "Repository": "https://github.com/shizeying/mcp-git-config"
    },
    "split_keywords": [
        "git",
        " mcp",
        " model-context-protocol",
        " server"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e503fc472d25b65e8b8ae89d1881ebcad6444055677ee9e15a1b78ea4afa2571",
                "md5": "c5529eb4454e8e22b340dfa86d548969",
                "sha256": "8a18d5276e76e016b4167edcf512ca79792ce01a26b45c85cd54a4bdb1037667"
            },
            "downloads": -1,
            "filename": "mcp_git_config-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c5529eb4454e8e22b340dfa86d548969",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 7938,
            "upload_time": "2025-08-04T05:15:28",
            "upload_time_iso_8601": "2025-08-04T05:15:28.564482Z",
            "url": "https://files.pythonhosted.org/packages/e5/03/fc472d25b65e8b8ae89d1881ebcad6444055677ee9e15a1b78ea4afa2571/mcp_git_config-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a45e8fb03e299689bb7af7acee688adc40443bb5891394b4aa6b19ac283b0a89",
                "md5": "164c655bf33ec1b1997c1e860ae350b0",
                "sha256": "0ab27259ebb0b61162d4bc49b5391441349d289842e608c525e71a990beb24f7"
            },
            "downloads": -1,
            "filename": "mcp_git_config-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "164c655bf33ec1b1997c1e860ae350b0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 95257,
            "upload_time": "2025-08-04T05:15:30",
            "upload_time_iso_8601": "2025-08-04T05:15:30.314955Z",
            "url": "https://files.pythonhosted.org/packages/a4/5e/8fb03e299689bb7af7acee688adc40443bb5891394b4aa6b19ac283b0a89/mcp_git_config-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-04 05:15:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "shizeying",
    "github_project": "mcp-git-config",
    "github_not_found": true,
    "lcname": "mcp-git-config"
}
        
Elapsed time: 1.33976s