feat(mcp): implement Git Operations MCP server with Gitea provider

Implements the Git Operations MCP server (Issue #58) providing:

Core features:
- GitPython wrapper for local repository operations (clone, commit, push, pull, diff, log)
- Branch management (create, delete, list, checkout)
- Workspace isolation per project with file-based locking
- Gitea provider for remote PR operations

MCP Tools (17 registered):
- clone_repository, git_status, create_branch, list_branches
- checkout, commit, push, pull, diff, log
- create_pull_request, get_pull_request, list_pull_requests
- merge_pull_request, get_workspace, lock_workspace, unlock_workspace

Technical details:
- FastMCP + FastAPI with JSON-RPC 2.0 protocol
- pydantic-settings for configuration (env prefix: GIT_OPS_)
- Comprehensive error hierarchy with structured codes
- 131 tests passing with 67% coverage
- Async operations via ThreadPoolExecutor

Closes: #105, #106, #107, #108, #109

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-06 20:48:20 +01:00
parent 4ad3d20cf2
commit 9dfa76aa41
19 changed files with 9544 additions and 0 deletions

View File

@@ -0,0 +1,118 @@
[project]
name = "syndarix-mcp-git-ops"
version = "0.1.0"
description = "Syndarix Git Operations MCP Server - Repository management, branching, commits, and PR workflows"
requires-python = ">=3.12"
dependencies = [
"fastmcp>=2.0.0",
"gitpython>=3.1.0",
"httpx>=0.27.0",
"redis>=5.0.0",
"pydantic>=2.0.0",
"pydantic-settings>=2.0.0",
"uvicorn>=0.30.0",
"fastapi>=0.115.0",
"filelock>=3.15.0",
"aiofiles>=24.1.0",
]
[project.optional-dependencies]
dev = [
"pytest>=8.0.0",
"pytest-asyncio>=0.24.0",
"pytest-cov>=5.0.0",
"fakeredis>=2.25.0",
"ruff>=0.8.0",
"mypy>=1.11.0",
"respx>=0.21.0",
]
[project.scripts]
git-ops = "server:main"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["."]
exclude = ["tests/", "*.md", "Dockerfile"]
[tool.hatch.build.targets.sdist]
include = ["*.py", "pyproject.toml"]
[tool.ruff]
target-version = "py312"
line-length = 88
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"UP", # pyupgrade
"ARG", # flake8-unused-arguments
"SIM", # flake8-simplify
"S", # flake8-bandit (security)
]
ignore = [
"E501", # line too long (handled by formatter)
"B008", # do not perform function calls in argument defaults
"B904", # raise from in except (too noisy)
"S104", # possible binding to all interfaces
"S110", # try-except-pass (intentional for optional operations)
"S603", # subprocess without shell=True (safe usage in git wrapper)
"S607", # starting a process with a partial path (git CLI)
"ARG002", # unused method arguments (for API compatibility)
"SIM102", # nested if statements (sometimes more readable)
"SIM105", # contextlib.suppress (sometimes more readable)
"SIM108", # ternary operator (sometimes more readable)
"SIM118", # dict.keys() (explicit is fine)
]
[tool.ruff.lint.isort]
known-first-party = ["config", "models", "exceptions", "git_wrapper", "workspace", "providers"]
[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = ["S101", "ARG001", "S105", "S106", "S108", "F841", "B007"]
[tool.pytest.ini_options]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
testpaths = ["tests"]
addopts = "-v --tb=short"
filterwarnings = [
"ignore::DeprecationWarning",
]
[tool.coverage.run]
source = ["."]
omit = ["tests/*", "conftest.py"]
branch = true
[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"raise NotImplementedError",
"if TYPE_CHECKING:",
"if __name__ == .__main__.:",
]
fail_under = 65 # TODO: Increase to 80% once more tool tests are added
show_missing = true
[tool.mypy]
python_version = "3.12"
warn_return_any = false
warn_unused_ignores = false
disallow_untyped_defs = true
ignore_missing_imports = true
plugins = ["pydantic.mypy"]
[[tool.mypy.overrides]]
module = "tests.*"
disallow_untyped_defs = false
ignore_errors = true