mcp-win-stdio-git 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_win_stdio_git-0.2.3/.gitignore +60 -0
- mcp_win_stdio_git-0.2.3/PKG-INFO +118 -0
- mcp_win_stdio_git-0.2.3/README.md +94 -0
- mcp_win_stdio_git-0.2.3/pyproject.toml +41 -0
- mcp_win_stdio_git-0.2.3/src/mcp_win_stdio/git/__init__.py +5 -0
- mcp_win_stdio_git-0.2.3/src/mcp_win_stdio/git/__main__.py +8 -0
- mcp_win_stdio_git-0.2.3/src/mcp_win_stdio/git/cli.py +134 -0
- mcp_win_stdio_git-0.2.3/src/mcp_win_stdio/git/guide.py +150 -0
- mcp_win_stdio_git-0.2.3/src/mcp_win_stdio/git/server.py +1899 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*$py.class
|
|
4
|
+
*.so
|
|
5
|
+
.Python
|
|
6
|
+
build/
|
|
7
|
+
develop-eggs/
|
|
8
|
+
dist/
|
|
9
|
+
downloads/
|
|
10
|
+
eggs/
|
|
11
|
+
.eggs/
|
|
12
|
+
lib/
|
|
13
|
+
lib64/
|
|
14
|
+
parts/
|
|
15
|
+
sdist/
|
|
16
|
+
var/
|
|
17
|
+
wheels/
|
|
18
|
+
share/python-wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
MANIFEST
|
|
23
|
+
|
|
24
|
+
*.manifest
|
|
25
|
+
*.spec
|
|
26
|
+
api.txt
|
|
27
|
+
pip-log.txt
|
|
28
|
+
pip-delete-this-directory.txt
|
|
29
|
+
pypi api.txt
|
|
30
|
+
htmlcov/
|
|
31
|
+
.tox/
|
|
32
|
+
.nox/
|
|
33
|
+
.coverage
|
|
34
|
+
.coverage.*
|
|
35
|
+
.cache
|
|
36
|
+
nosetests.xml
|
|
37
|
+
coverage.xml
|
|
38
|
+
*.cover
|
|
39
|
+
*.py,cover
|
|
40
|
+
.hypothesis/
|
|
41
|
+
.pytest_cache/
|
|
42
|
+
cover/
|
|
43
|
+
|
|
44
|
+
*.mo
|
|
45
|
+
*.pot
|
|
46
|
+
|
|
47
|
+
.env
|
|
48
|
+
.venv
|
|
49
|
+
env/
|
|
50
|
+
venv/
|
|
51
|
+
ENV/
|
|
52
|
+
env.bak/
|
|
53
|
+
venv.bak/
|
|
54
|
+
|
|
55
|
+
.idea/
|
|
56
|
+
.vscode/
|
|
57
|
+
*.swp
|
|
58
|
+
*.swo
|
|
59
|
+
|
|
60
|
+
*.log
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: mcp-win-stdio-git
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Summary: Unified Git & GitHub Model Context Protocol (MCP) server for Windows & Claude: 26 tools combining local Git repository management and remote GitHub CLI (gh) operations with hybrid synergy workflows.
|
|
5
|
+
Author: Mohan Kumar Indala
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: actions,ai,claude,gh,git,github,issues,llm,mcp,pull-requests,version-control
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Environment :: Win32 (MS Windows)
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: mcp-win-stdio>=0.2.3
|
|
22
|
+
Requires-Dist: mcp>=1.2.0
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# mcp-win-stdio-git
|
|
26
|
+
|
|
27
|
+
Unified Git & GitHub Model Context Protocol (MCP) server for Windows & Claude Desktop: **26 tools** seamlessly unifying local Git repository management and remote GitHub CLI (`gh`) operations with hybrid synergy workflows.
|
|
28
|
+
|
|
29
|
+
Part of the **`mcp-win-stdio`** Windows-optimized suite.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## ๐ Features (26 Tools)
|
|
34
|
+
|
|
35
|
+
- **Local Git Suite (16 Tools)**:
|
|
36
|
+
- Branching (`git_branch`), staging & commits with identity checks (`git_commit`), token-safe diffs (`git_diff`), commit logs (`git_log`), stashing (`git_stash`), remote sync (`git_sync`), blame (`git_blame`), tags (`git_tag`), regex search (`git_grep`), and config (`git_config`).
|
|
37
|
+
- Safe file restoration and guarded destructive reset (`git_reset`).
|
|
38
|
+
- Isolated background workspaces via `git_worktree`.
|
|
39
|
+
- In-progress merge and rebase conflict detection & resolution (`git_conflict_resolve`).
|
|
40
|
+
- Multi-repo switching and bookmarking (`repo_overview`, `use_repo`, `list_repos`, `add_repo`).
|
|
41
|
+
- **Remote GitHub CLI Suite (8 Tools)**:
|
|
42
|
+
- Pull requests (`gh_pr_list`, `gh_pr_view`, `gh_pr_diff`).
|
|
43
|
+
- Issue tracking (`gh_issue_list`).
|
|
44
|
+
- CI/CD workflow monitoring (`gh_run_status`).
|
|
45
|
+
- Gist snippet creation (`gh_gist_create`).
|
|
46
|
+
- Multi-account awareness and switching (`gh_auth_status`, `gh_switch_account`).
|
|
47
|
+
- **Hybrid Synergy Workflows (2 Tools)**:
|
|
48
|
+
- `repo_overview`: 360-degree status combining local branch, dirty status, ahead/behind tracking, active open PR, and latest GitHub Actions workflow run.
|
|
49
|
+
- `pr_quickstart`: Stage -> commit -> push -> open GitHub PR via `gh pr create` in a single tool call.
|
|
50
|
+
- `issue_start_work`: Fetches GitHub issue details and automatically checks out a linked feature branch `feature/<id>-<slug>`.
|
|
51
|
+
- **Zero-Friction Fallback**:
|
|
52
|
+
- Works 100% locally if GitHub CLI is not installed or unauthenticated, and provides copy-pasteable `winget` commands to install.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## ๐ Prerequisites & Setup
|
|
57
|
+
|
|
58
|
+
1. **Install Git CLI** (if not installed):
|
|
59
|
+
```powershell
|
|
60
|
+
winget install --id Git.Git -e
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
2. **Install GitHub CLI** (recommended for PRs, Issues, Actions):
|
|
64
|
+
```powershell
|
|
65
|
+
winget install --id GitHub.cli -e
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
3. **Authenticate & Setup Git Credential Helper**:
|
|
69
|
+
```powershell
|
|
70
|
+
gh auth login
|
|
71
|
+
gh auth setup-git
|
|
72
|
+
```
|
|
73
|
+
> [!IMPORTANT]
|
|
74
|
+
> `gh auth setup-git` is crucial so your local git push/pull and multi-account switching (`gh_switch_account`) authenticate smoothly.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## ๐ฆ Installation
|
|
79
|
+
|
|
80
|
+
```powershell
|
|
81
|
+
pip install mcp-win-stdio-git
|
|
82
|
+
```
|
|
83
|
+
*(Installing this package automatically installs `mws` CLI orchestrator)*.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## ๐ One-Command Claude Setup
|
|
88
|
+
|
|
89
|
+
```powershell
|
|
90
|
+
mws setup git
|
|
91
|
+
# or:
|
|
92
|
+
mws add git
|
|
93
|
+
```
|
|
94
|
+
This automatically configures Claude Desktop (`claude_desktop_config.json`) and Claude Code CLI with zero manual JSON editing.
|
|
95
|
+
|
|
96
|
+
### Manual Configuration
|
|
97
|
+
```json
|
|
98
|
+
"git": {
|
|
99
|
+
"command": "python",
|
|
100
|
+
"args": ["-m", "mcp_win_stdio.git"]
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## ๐ CLI Commands & Interactive Guide
|
|
107
|
+
|
|
108
|
+
```powershell
|
|
109
|
+
mws git guide # Complete tool reference & prompt recipes
|
|
110
|
+
mws git doctor # Verify Git, GitHub CLI, and credential helper status
|
|
111
|
+
mws git setup # Configure Claude Desktop / Claude Code
|
|
112
|
+
mws git run # Launch server over stdio
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## ๐ License
|
|
118
|
+
MIT License. Copyright (c) 2026 Mohan Kumar Indala.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# mcp-win-stdio-git
|
|
2
|
+
|
|
3
|
+
Unified Git & GitHub Model Context Protocol (MCP) server for Windows & Claude Desktop: **26 tools** seamlessly unifying local Git repository management and remote GitHub CLI (`gh`) operations with hybrid synergy workflows.
|
|
4
|
+
|
|
5
|
+
Part of the **`mcp-win-stdio`** Windows-optimized suite.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ๐ Features (26 Tools)
|
|
10
|
+
|
|
11
|
+
- **Local Git Suite (16 Tools)**:
|
|
12
|
+
- Branching (`git_branch`), staging & commits with identity checks (`git_commit`), token-safe diffs (`git_diff`), commit logs (`git_log`), stashing (`git_stash`), remote sync (`git_sync`), blame (`git_blame`), tags (`git_tag`), regex search (`git_grep`), and config (`git_config`).
|
|
13
|
+
- Safe file restoration and guarded destructive reset (`git_reset`).
|
|
14
|
+
- Isolated background workspaces via `git_worktree`.
|
|
15
|
+
- In-progress merge and rebase conflict detection & resolution (`git_conflict_resolve`).
|
|
16
|
+
- Multi-repo switching and bookmarking (`repo_overview`, `use_repo`, `list_repos`, `add_repo`).
|
|
17
|
+
- **Remote GitHub CLI Suite (8 Tools)**:
|
|
18
|
+
- Pull requests (`gh_pr_list`, `gh_pr_view`, `gh_pr_diff`).
|
|
19
|
+
- Issue tracking (`gh_issue_list`).
|
|
20
|
+
- CI/CD workflow monitoring (`gh_run_status`).
|
|
21
|
+
- Gist snippet creation (`gh_gist_create`).
|
|
22
|
+
- Multi-account awareness and switching (`gh_auth_status`, `gh_switch_account`).
|
|
23
|
+
- **Hybrid Synergy Workflows (2 Tools)**:
|
|
24
|
+
- `repo_overview`: 360-degree status combining local branch, dirty status, ahead/behind tracking, active open PR, and latest GitHub Actions workflow run.
|
|
25
|
+
- `pr_quickstart`: Stage -> commit -> push -> open GitHub PR via `gh pr create` in a single tool call.
|
|
26
|
+
- `issue_start_work`: Fetches GitHub issue details and automatically checks out a linked feature branch `feature/<id>-<slug>`.
|
|
27
|
+
- **Zero-Friction Fallback**:
|
|
28
|
+
- Works 100% locally if GitHub CLI is not installed or unauthenticated, and provides copy-pasteable `winget` commands to install.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## ๐ Prerequisites & Setup
|
|
33
|
+
|
|
34
|
+
1. **Install Git CLI** (if not installed):
|
|
35
|
+
```powershell
|
|
36
|
+
winget install --id Git.Git -e
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
2. **Install GitHub CLI** (recommended for PRs, Issues, Actions):
|
|
40
|
+
```powershell
|
|
41
|
+
winget install --id GitHub.cli -e
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
3. **Authenticate & Setup Git Credential Helper**:
|
|
45
|
+
```powershell
|
|
46
|
+
gh auth login
|
|
47
|
+
gh auth setup-git
|
|
48
|
+
```
|
|
49
|
+
> [!IMPORTANT]
|
|
50
|
+
> `gh auth setup-git` is crucial so your local git push/pull and multi-account switching (`gh_switch_account`) authenticate smoothly.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## ๐ฆ Installation
|
|
55
|
+
|
|
56
|
+
```powershell
|
|
57
|
+
pip install mcp-win-stdio-git
|
|
58
|
+
```
|
|
59
|
+
*(Installing this package automatically installs `mws` CLI orchestrator)*.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## ๐ One-Command Claude Setup
|
|
64
|
+
|
|
65
|
+
```powershell
|
|
66
|
+
mws setup git
|
|
67
|
+
# or:
|
|
68
|
+
mws add git
|
|
69
|
+
```
|
|
70
|
+
This automatically configures Claude Desktop (`claude_desktop_config.json`) and Claude Code CLI with zero manual JSON editing.
|
|
71
|
+
|
|
72
|
+
### Manual Configuration
|
|
73
|
+
```json
|
|
74
|
+
"git": {
|
|
75
|
+
"command": "python",
|
|
76
|
+
"args": ["-m", "mcp_win_stdio.git"]
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## ๐ CLI Commands & Interactive Guide
|
|
83
|
+
|
|
84
|
+
```powershell
|
|
85
|
+
mws git guide # Complete tool reference & prompt recipes
|
|
86
|
+
mws git doctor # Verify Git, GitHub CLI, and credential helper status
|
|
87
|
+
mws git setup # Configure Claude Desktop / Claude Code
|
|
88
|
+
mws git run # Launch server over stdio
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## ๐ License
|
|
94
|
+
MIT License. Copyright (c) 2026 Mohan Kumar Indala.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mcp-win-stdio-git"
|
|
7
|
+
version = "0.2.3"
|
|
8
|
+
description = "Unified Git & GitHub Model Context Protocol (MCP) server for Windows & Claude: 26 tools combining local Git repository management and remote GitHub CLI (gh) operations with hybrid synergy workflows."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Mohan Kumar Indala" }
|
|
14
|
+
]
|
|
15
|
+
keywords = ["mcp", "claude", "git", "github", "gh", "version-control", "pull-requests", "issues", "actions", "ai", "llm"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Environment :: Win32 (MS Windows)",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Operating System :: Microsoft :: Windows",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Programming Language :: Python :: 3.14",
|
|
28
|
+
"Topic :: Software Development :: Version Control :: Git",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
dependencies = [
|
|
32
|
+
"mcp-win-stdio>=0.2.3",
|
|
33
|
+
"mcp>=1.2.0",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.scripts]
|
|
37
|
+
mcp-win-stdio-git = "mcp_win_stdio.git.cli:main"
|
|
38
|
+
mws-git = "mcp_win_stdio.git.cli:main"
|
|
39
|
+
|
|
40
|
+
[tool.hatch.build.targets.wheel]
|
|
41
|
+
packages = ["src/mcp_win_stdio"]
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CLI entry point for mcp-win-stdio-git.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import shutil
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
# Ensure Windows console uses UTF-8 without crashing on cp1252
|
|
13
|
+
if sys.platform == "win32":
|
|
14
|
+
try:
|
|
15
|
+
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
16
|
+
sys.stderr.reconfigure(encoding="utf-8", errors="replace")
|
|
17
|
+
except Exception:
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
from mcp_win_stdio.git import __version__
|
|
21
|
+
from mcp_win_stdio.git.server import mcp, is_git_installed, is_gh_installed
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def cmd_run(args: argparse.Namespace) -> None:
|
|
25
|
+
"""Run Git & GitHub MCP server over stdio."""
|
|
26
|
+
mcp.run()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def cmd_doctor(args: argparse.Namespace) -> None:
|
|
30
|
+
"""Run diagnostic checks on Git, GitHub CLI, author identity, and authentication."""
|
|
31
|
+
print(f"\n=== mcp-win-stdio-git Doctor Diagnostic (v{__version__}) ===\n")
|
|
32
|
+
print(f"[OK] Python Runtime: {sys.version.split()[0]} ({sys.executable})")
|
|
33
|
+
|
|
34
|
+
# 1. Git CLI Check
|
|
35
|
+
git_bin = shutil.which("git")
|
|
36
|
+
if git_bin:
|
|
37
|
+
try:
|
|
38
|
+
ver = subprocess.run(["git", "--version"], capture_output=True, text=True, check=True).stdout.strip()
|
|
39
|
+
print(f"[OK] Git CLI: {ver} ({git_bin})")
|
|
40
|
+
except Exception:
|
|
41
|
+
print(f"[OK] Git CLI: Found at {git_bin}")
|
|
42
|
+
|
|
43
|
+
# Git Config
|
|
44
|
+
name = subprocess.run(["git", "config", "user.name"], capture_output=True, text=True).stdout.strip()
|
|
45
|
+
email = subprocess.run(["git", "config", "user.email"], capture_output=True, text=True).stdout.strip()
|
|
46
|
+
if name and email:
|
|
47
|
+
print(f"[OK] Git Identity: {name} <{email}>")
|
|
48
|
+
else:
|
|
49
|
+
print(f"[WARN] Git Identity: Not configured (missing user.name or user.email)")
|
|
50
|
+
print(f" -> Run: git config --global user.name \"Your Name\"")
|
|
51
|
+
print(f" -> Run: git config --global user.email \"you@example.com\"")
|
|
52
|
+
else:
|
|
53
|
+
print(f"[FAIL] Git CLI: Not found on PATH")
|
|
54
|
+
print(f" -> Install Git: winget install --id Git.Git -e")
|
|
55
|
+
if sys.stdin.isatty():
|
|
56
|
+
install = input(" Would you like to install Git now via winget? [Y/n]: ").strip().lower()
|
|
57
|
+
if install not in ("n", "no"):
|
|
58
|
+
subprocess.run(["winget", "install", "--id", "Git.Git", "-e"])
|
|
59
|
+
|
|
60
|
+
# 2. GitHub CLI Check
|
|
61
|
+
gh_bin = shutil.which("gh")
|
|
62
|
+
if gh_bin:
|
|
63
|
+
try:
|
|
64
|
+
ver_line = subprocess.run(["gh", "--version"], capture_output=True, text=True, check=True).stdout.splitlines()[0]
|
|
65
|
+
print(f"[OK] GitHub CLI: {ver_line} ({gh_bin})")
|
|
66
|
+
except Exception:
|
|
67
|
+
print(f"[OK] GitHub CLI: Found at {gh_bin}")
|
|
68
|
+
|
|
69
|
+
# GitHub Auth status
|
|
70
|
+
auth_res = subprocess.run(["gh", "auth", "status"], capture_output=True, text=True, encoding="utf-8", errors="replace")
|
|
71
|
+
auth_out = auth_res.stderr or auth_res.stdout
|
|
72
|
+
if "Logged in to" in auth_out:
|
|
73
|
+
first_account = [ln.strip() for ln in auth_out.splitlines() if "Logged in to" in ln]
|
|
74
|
+
account_str = first_account[0] if first_account else "Active"
|
|
75
|
+
account_str = account_str.replace("โ", "").replace("รขลโ", "").strip()
|
|
76
|
+
print(f"[OK] GitHub Auth: Logged in ({account_str})")
|
|
77
|
+
|
|
78
|
+
# Check Git credential helper integration
|
|
79
|
+
helper_res = subprocess.run(["git", "config", "--get-all", "credential.helper"], capture_output=True, text=True).stdout
|
|
80
|
+
if "gh" in helper_res:
|
|
81
|
+
print(f"[OK] Git Credential Helper: Linked to gh (account switching active)")
|
|
82
|
+
else:
|
|
83
|
+
print(f"[WARN] Git Credential Helper: Not linked to GitHub CLI.")
|
|
84
|
+
print(f" -> Run: gh auth setup-git")
|
|
85
|
+
print(f" (Required for git commands & account switching to use gh authentication)")
|
|
86
|
+
else:
|
|
87
|
+
print(f"[INFO] GitHub Auth: Not logged in")
|
|
88
|
+
print(f" -> Step 1: gh auth login")
|
|
89
|
+
print(f" -> Step 2: gh auth setup-git (essential for git commands & account switching)")
|
|
90
|
+
else:
|
|
91
|
+
print(f"[INFO] GitHub CLI: Not found on PATH (enables PR, Issue, and Actions tools)")
|
|
92
|
+
print(f" -> Step 1: winget install --id GitHub.cli -e")
|
|
93
|
+
print(f" -> Step 2: gh auth login")
|
|
94
|
+
print(f" -> Step 3: gh auth setup-git (essential for git commands & account switching)")
|
|
95
|
+
if sys.stdin.isatty():
|
|
96
|
+
install = input(" Would you like to install GitHub CLI now via winget? [y/N]: ").strip().lower()
|
|
97
|
+
if install in ("y", "yes"):
|
|
98
|
+
subprocess.run(["winget", "install", "--id", "GitHub.cli", "-e"])
|
|
99
|
+
|
|
100
|
+
print("\nDiagnostic complete.\n")
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def cmd_guide(args: argparse.Namespace) -> None:
|
|
104
|
+
"""Print Git MCP guide and prompt recipes."""
|
|
105
|
+
from mcp_win_stdio.git.guide import print_git_guide
|
|
106
|
+
print_git_guide()
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def main() -> None:
|
|
110
|
+
parser = argparse.ArgumentParser(
|
|
111
|
+
prog="mcp-win-stdio-git",
|
|
112
|
+
description="Unified Git & GitHub MCP Server CLI (Local Git + Remote GitHub CLI)",
|
|
113
|
+
)
|
|
114
|
+
parser.add_argument("--version", "-v", action="version", version=f"%(prog)s {__version__}")
|
|
115
|
+
subparsers = parser.add_subparsers(dest="command", help="Command to execute")
|
|
116
|
+
|
|
117
|
+
sub_guide = subparsers.add_parser("guide", help="View usage guide, tool references, and prompts")
|
|
118
|
+
sub_guide.set_defaults(func=cmd_guide)
|
|
119
|
+
|
|
120
|
+
sub_doctor = subparsers.add_parser("doctor", help="Check Git & GitHub CLI health, identity, and auth")
|
|
121
|
+
sub_doctor.set_defaults(func=cmd_doctor)
|
|
122
|
+
|
|
123
|
+
sub_run = subparsers.add_parser("run", help="Run Git & GitHub MCP server over stdio")
|
|
124
|
+
sub_run.set_defaults(func=cmd_run)
|
|
125
|
+
|
|
126
|
+
args = parser.parse_args()
|
|
127
|
+
if hasattr(args, "func"):
|
|
128
|
+
args.func(args)
|
|
129
|
+
else:
|
|
130
|
+
cmd_run(args)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
if __name__ == "__main__":
|
|
134
|
+
main()
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Usage guide, prerequisites, and prompt recipes for Git & GitHub MCP server (mcp-win-stdio-git).
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import shutil
|
|
6
|
+
import subprocess
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
# Ensure Windows console uses UTF-8 without crashing on cp1252
|
|
10
|
+
if sys.platform == "win32":
|
|
11
|
+
try:
|
|
12
|
+
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
13
|
+
sys.stderr.reconfigure(encoding="utf-8", errors="replace")
|
|
14
|
+
except Exception:
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_git_prerequisites_status() -> dict:
|
|
19
|
+
"""Check current status of git, gh, and git credential helper."""
|
|
20
|
+
git_bin = shutil.which("git")
|
|
21
|
+
gh_bin = shutil.which("gh")
|
|
22
|
+
gh_logged_in = False
|
|
23
|
+
gh_account = None
|
|
24
|
+
cred_helper_linked = False
|
|
25
|
+
|
|
26
|
+
if gh_bin:
|
|
27
|
+
try:
|
|
28
|
+
res = subprocess.run(["gh", "auth", "status"], capture_output=True, text=True, encoding="utf-8", errors="replace")
|
|
29
|
+
out = res.stderr or res.stdout
|
|
30
|
+
if "Logged in to" in out:
|
|
31
|
+
gh_logged_in = True
|
|
32
|
+
for ln in out.splitlines():
|
|
33
|
+
if "Logged in to" in ln:
|
|
34
|
+
gh_account = ln.replace("โ", "").replace("รขลโ", "").strip()
|
|
35
|
+
break
|
|
36
|
+
except Exception:
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
if git_bin and gh_bin:
|
|
40
|
+
try:
|
|
41
|
+
helper_res = subprocess.run(["git", "config", "--get-all", "credential.helper"], capture_output=True, text=True)
|
|
42
|
+
if "gh" in helper_res.stdout:
|
|
43
|
+
cred_helper_linked = True
|
|
44
|
+
except Exception:
|
|
45
|
+
pass
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
"git_installed": bool(git_bin),
|
|
49
|
+
"gh_installed": bool(gh_bin),
|
|
50
|
+
"gh_logged_in": gh_logged_in,
|
|
51
|
+
"gh_account": gh_account,
|
|
52
|
+
"cred_helper_linked": cred_helper_linked,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def print_git_guide() -> None:
|
|
57
|
+
status = get_git_prerequisites_status()
|
|
58
|
+
|
|
59
|
+
print("=" * 80)
|
|
60
|
+
print(" Unified Git & GitHub MCP Server (mcp-win-stdio-git)")
|
|
61
|
+
print("=" * 80)
|
|
62
|
+
|
|
63
|
+
print("\nPREREQUISITES & ENVIRONMENT STATUS:")
|
|
64
|
+
print("-" * 80)
|
|
65
|
+
if status["git_installed"]:
|
|
66
|
+
print(" [OK] Git CLI: Installed")
|
|
67
|
+
else:
|
|
68
|
+
print(" [!] Git CLI: NOT FOUND")
|
|
69
|
+
print(" -> Run: winget install --id Git.Git -e")
|
|
70
|
+
|
|
71
|
+
if status["gh_installed"]:
|
|
72
|
+
print(" [OK] GitHub CLI (gh): Installed")
|
|
73
|
+
if status["gh_logged_in"]:
|
|
74
|
+
print(f" [OK] GitHub Auth: Logged in ({status['gh_account'] or 'Active'})")
|
|
75
|
+
if status["cred_helper_linked"]:
|
|
76
|
+
print(" [OK] Git Credential Helper: Linked to gh (account switching active)")
|
|
77
|
+
else:
|
|
78
|
+
print(" [!] Git Credential Helper: Not linked to gh")
|
|
79
|
+
print(" -> Run: gh auth setup-git")
|
|
80
|
+
print(" (Required so git commands & account switching use gh authentication)")
|
|
81
|
+
else:
|
|
82
|
+
print(" [!] GitHub Auth: Not logged in")
|
|
83
|
+
print(" -> Step 1: gh auth login")
|
|
84
|
+
print(" -> Step 2: gh auth setup-git (essential for git operations & account switching)")
|
|
85
|
+
else:
|
|
86
|
+
print(" [!] GitHub CLI (gh): NOT FOUND (Required for PRs, issues, gists & CI runs)")
|
|
87
|
+
print(" -> Step 1: winget install --id GitHub.cli -e")
|
|
88
|
+
print(" -> Step 2: gh auth login")
|
|
89
|
+
print(" -> Step 3: gh auth setup-git (essential for git operations & account switching)")
|
|
90
|
+
|
|
91
|
+
print("\nSETUP INSTRUCTIONS FOR NEW USERS:")
|
|
92
|
+
print("-" * 80)
|
|
93
|
+
print(" 1. If Git or gh is not installed, install them using winget:")
|
|
94
|
+
print(" winget install --id Git.Git -e")
|
|
95
|
+
print(" winget install --id GitHub.cli -e")
|
|
96
|
+
print("\n 2. Authenticate GitHub CLI:")
|
|
97
|
+
print(" gh auth login")
|
|
98
|
+
print("\n 3. Configure Git to use GitHub CLI credentials (CRUCIAL):")
|
|
99
|
+
print(" gh auth setup-git")
|
|
100
|
+
print(" * Why this is needed: Configures git credential.helper = '!gh auth git-credential'.")
|
|
101
|
+
print(" Without this, local git push/pull and multi-account switching ('gh auth switch')")
|
|
102
|
+
print(" will fail or fallback to outdated Windows credentials.")
|
|
103
|
+
print("\n 4. Register with Claude Desktop or Claude Code CLI:")
|
|
104
|
+
print(" mws add git")
|
|
105
|
+
|
|
106
|
+
print("\nAVAILABLE TOOLS (26 Tools):")
|
|
107
|
+
print("-" * 80)
|
|
108
|
+
print(" Local Git Operations:")
|
|
109
|
+
print(" * repo_overview : 360-degree repo overview: branch, dirty state, PR, latest CI")
|
|
110
|
+
print(" * use_repo : Switch active repository workspace bookmark")
|
|
111
|
+
print(" * list_repos : List registered repository workspaces")
|
|
112
|
+
print(" * add_repo : Bookmark a repository path for multi-project workflows")
|
|
113
|
+
print(" * git_status : Structured status: staged, unstaged, untracked files")
|
|
114
|
+
print(" * git_diff : Token-safe diff (unstaged, staged index, branch comparisons)")
|
|
115
|
+
print(" * git_log : Structured commit history with hash, author, date, message")
|
|
116
|
+
print(" * git_commit : Stage and commit files with clean commit messages")
|
|
117
|
+
print(" * git_branch : List, create, switch, or safely delete branches")
|
|
118
|
+
print(" * git_stash : Stash changes: save, pop, list, drop")
|
|
119
|
+
print(" * git_sync : Fetch, pull, push with upstream tracking")
|
|
120
|
+
print(" * git_blame : Token-safe file blame with line range filtering")
|
|
121
|
+
print(" * git_reset : Safe file restore or commit reset (soft or guarded hard)")
|
|
122
|
+
print(" * git_tag : List, create, or delete Git tags")
|
|
123
|
+
print(" * git_grep : Fast regex search across tracked files")
|
|
124
|
+
print(" * git_worktree : Isolated branch workspaces: list, add, remove, prune")
|
|
125
|
+
print(" * git_config : Inspect or configure git settings (user.name, user.email)")
|
|
126
|
+
print(" * git_conflict_resolve : Detect merge/rebase conflicts, abort, or continue")
|
|
127
|
+
print("\n Remote GitHub Operations (via gh CLI):")
|
|
128
|
+
print(" * gh_auth_status : Check GitHub CLI authentication status and accounts")
|
|
129
|
+
print(" * gh_switch_account : Switch active GitHub account (personal vs work)")
|
|
130
|
+
print(" * gh_pr_list : List pull requests with state filters")
|
|
131
|
+
print(" * gh_pr_view : Deep view of PR: reviews, CI checks, mergeable state")
|
|
132
|
+
print(" * gh_pr_diff : View token-capped remote PR diff")
|
|
133
|
+
print(" * gh_issue_list : List repository issues with label/state filters")
|
|
134
|
+
print(" * gh_run_status : Inspect recent GitHub Actions workflow runs")
|
|
135
|
+
print(" * gh_gist_create : Share code snippets via GitHub Gists")
|
|
136
|
+
print("\n Hybrid Synergy Workflows:")
|
|
137
|
+
print(" * pr_quickstart : Stage -> Commit -> Push -> Create PR via 'gh pr create'")
|
|
138
|
+
print(" * issue_start_work : Fetch issue from GitHub -> Checkout feature branch locally")
|
|
139
|
+
|
|
140
|
+
print("\nPROMPT RECIPES FOR CLAUDE:")
|
|
141
|
+
print("-" * 80)
|
|
142
|
+
print(" 1. 'Give me a 360-degree overview of the current repo, open PRs, and recent CI runs using repo_overview.'")
|
|
143
|
+
print(" 2. 'Pick up issue #12, check its details, and create a local branch using issue_start_work.'")
|
|
144
|
+
print(" 3. 'Stage all modified files, commit with message \"feat: new feature\", push, and open a PR with pr_quickstart.'")
|
|
145
|
+
print(" 4. 'Switch active GitHub account to my work account using gh_switch_account.'")
|
|
146
|
+
print("=" * 80 + "\n")
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
if __name__ == "__main__":
|
|
150
|
+
print_git_guide()
|