Skip to content

Commit 4166430

Browse files
authored
Merge pull request #17 from yumeminami/feature/add-version-support-issue-15
Add version checking support for CLI tools
2 parents 553e479 + 5f867cc commit 4166430

File tree

15 files changed

+611
-25
lines changed

15 files changed

+611
-25
lines changed

CLAUDE.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ uv tool install --from . git_mcp_server --force
1919

2020
# Run linting and security checks
2121
uv run ruff check git_mcp/
22+
uv run ruff format git_mcp/
2223
uv run bandit -r git_mcp/
24+
uv run mypy git_mcp/ --ignore-missing-imports --no-strict-optional
2325

24-
# Run pre-commit hooks manually
26+
# Run pre-commit hooks manually (includes ruff, bandit, mypy, yaml/json checks)
2527
uv run pre-commit run --all-files
2628

2729
# Run tests (when implemented - uses placeholder test currently)
@@ -30,6 +32,9 @@ uv run pytest
3032
# Test CLI entry points
3133
uv run git-mcp --help
3234
uv run git-mcp-server --help
35+
36+
# Test MCP server directly
37+
echo '{"jsonrpc": "2.0", "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "test", "version": "1.0.0"}}, "id": 1}' | git-mcp-server
3338
```
3439

3540
### Installation & Setup
@@ -136,6 +141,8 @@ When working on this codebase:
136141

137142
## Dependencies
138143

144+
**Python Version**: Requires Python >=3.13
145+
139146
Core dependencies (from pyproject.toml):
140147
- `python-gitlab>=4.4.0` - GitLab API client
141148
- `PyGithub>=2.1.0` - GitHub API client
@@ -148,15 +155,47 @@ Core dependencies (from pyproject.toml):
148155
- `gitpython>=3.1.0` - Git repository interaction
149156
- `pyyaml>=6.0.0` - YAML configuration parsing
150157
- `tool>=0.8.0` - Tool utilities
158+
- `pre-commit>=4.2.0` - Git hooks for code quality
151159

152160
Development tools:
153161
- `ruff>=0.1.0` - Linting and code formatting
154162
- `bandit[toml]>=1.7.0` - Security vulnerability scanning
155163
- `pytest>=8.0.0` - Testing framework (configured, tests not yet implemented)
156164
- `pytest-asyncio>=0.23.0` - Async testing support
157-
- `pre-commit>=4.2.0` - Git hooks for code quality (also core dependency)
158165
- `pip-audit>=2.0.0` - Security vulnerability scanning
159166

167+
## API Documentation
168+
169+
**Platform API References:**
170+
171+
### GitHub API (PyGithub)
172+
- **Examples & Usage Patterns**: https://pygithub.readthedocs.io/en/stable/examples.html
173+
- Comprehensive examples for common GitHub operations
174+
- Authentication methods and best practices
175+
- Rate limiting and pagination handling
176+
- **API Reference**: https://pygithub.readthedocs.io/en/stable/github_objects.html
177+
- Complete class and method documentation
178+
- Object relationships and property details
179+
180+
### GitLab API (python-gitlab)
181+
- **API Objects Reference**: https://python-gitlab.readthedocs.io/en/stable/api-objects.html
182+
- Complete list of available API objects and methods
183+
- CRUD operations for issues, merge requests, projects
184+
- Advanced features like pipelines, deployments, and wiki management
185+
- **Usage Guide**: https://python-gitlab.readthedocs.io/en/stable/gl_objects/
186+
- Object-specific documentation with examples
187+
- Authentication and connection management
188+
189+
**When to Use These Resources:**
190+
- **Customizing platform adapters** (`git_mcp/platforms/`) - Reference API objects and methods
191+
- **Debugging API interactions** - Understand response structures and error handling
192+
- **Extending MCP tools** (`git_mcp/mcp_server.py`) - Add new platform operations
193+
- **Developing slash commands** - Integrate additional API functionality
194+
195+
**Additional Resources:**
196+
- **GitHub REST API Docs**: https://docs.github.com/en/rest
197+
- **GitLab REST API Docs**: https://docs.gitlab.com/ee/api/
198+
160199
## Security Notes
161200

162201
- All access tokens are stored securely in system keyring, never in config files

git_mcp/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,17 @@
33
A unified command-line tool for managing Git repositories across GitHub and GitLab platforms.
44
"""
55

6-
__version__ = "0.1.0"
6+
import importlib.metadata
7+
8+
try:
9+
__version__ = importlib.metadata.version("git_mcp_server")
10+
except importlib.metadata.PackageNotFoundError:
11+
# Fallback for development/source installations
12+
__version__ = "0.1.8"
13+
714
__author__ = "Git MCP Team"
15+
16+
17+
def get_version() -> str:
18+
"""Get the package version dynamically."""
19+
return __version__

git_mcp/claude_commands/implement.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ Please implement the planned functionality thoroughly and in great detail, consi
4343

4444
Use `get_project_details()` to understand codebase structure and `list_merge_requests()` to review implementation patterns in recent changes.
4545

46+
## Platform API Resources
47+
48+
**When implementing platform-specific features**, refer to the API documentation in CLAUDE.md:
49+
50+
**For GitLab integrations** (`git_mcp/platforms/gitlab.py`):
51+
- **API Objects Reference**: https://python-gitlab.readthedocs.io/en/stable/api-objects.html
52+
- **Usage Examples**: https://python-gitlab.readthedocs.io/en/stable/gl_objects/
53+
54+
**For GitHub integrations** (`git_mcp/platforms/github.py`):
55+
- **Examples & Patterns**: https://pygithub.readthedocs.io/en/stable/examples.html
56+
- **API Reference**: https://pygithub.readthedocs.io/en/stable/github_objects.html
57+
58+
**Common use cases requiring API docs:**
59+
- Extending platform adapter methods
60+
- Adding new MCP tools for platform operations
61+
- Implementing custom issue/PR workflows
62+
- Debugging API response handling
63+
4664
**After implementation, update the issue documentation with progress and file changes.**
4765

4866
Use `/test` after implementation to generate comprehensive tests.

git_mcp/claude_commands/plan.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ Create a comprehensive development plan including:
3535

3636
Use `get_project_details()` to understand project structure and `list_merge_requests()` to review existing workflow patterns.
3737

38+
## Platform API Planning
39+
40+
**When planning platform integrations**, consult the API documentation in CLAUDE.md:
41+
42+
**GitLab API Resources:**
43+
- API Objects: https://python-gitlab.readthedocs.io/en/stable/api-objects.html
44+
- Usage Patterns: https://python-gitlab.readthedocs.io/en/stable/gl_objects/
45+
46+
**GitHub API Resources:**
47+
- Examples: https://pygithub.readthedocs.io/en/stable/examples.html
48+
- API Reference: https://pygithub.readthedocs.io/en/stable/github_objects.html
49+
50+
**Consider API limitations and capabilities when planning:**
51+
- Rate limiting requirements
52+
- Authentication scopes needed
53+
- Available operations and data structures
54+
- Error handling patterns
55+
3856
## Repository Context
3957

4058
Analyze current repository structure:

git_mcp/claude_commands/pr.md

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,65 @@ Analyze the changes made thoroughly and consider multiple ways to present them c
3232
!git status
3333
!git commit -m "Implement feature for issue #$ARGUMENTS"
3434

35-
2. **Push to Remote**
35+
2. **Fork Detection and Repository Analysis**
36+
- Use `get_fork_info()` to check if current repository is a fork
37+
- If it's a fork, identify the upstream repository for PR creation
38+
- Determine the correct target repository (fork vs upstream)
39+
40+
3. **Push to Remote**
3641
!git push -u origin HEAD
3742

38-
3. **Create Pull/Merge Request**
39-
Use `create_merge_request()` to create the PR/MR with:
43+
4. **Create Pull/Merge Request with Fork Support**
44+
Use `create_merge_request()` to create the PR/MR with enhanced fork support:
45+
46+
**For Fork-to-Upstream PRs:**
47+
- Source branch: `username:branch-name` format (automatically detected)
48+
- Target repository: Upstream repository (parent)
49+
- Target branch: Usually `main` or `master`
50+
51+
**For Same-Repository PRs:**
52+
- Source branch: `branch-name` format (current behavior)
53+
- Target repository: Current repository
54+
- Target branch: As specified or default
55+
56+
**PR Parameters:**
4057
- Craft a descriptive title linking to issue
4158
- Create comprehensive description that clearly explains the solution
4259
- **IMPORTANT**: In the description, use the full issue URL from `.claude/issue-$ARGUMENTS-*.md` instead of just `#$ARGUMENTS`
4360
- Extract the URL using: `grep "URL:" .claude/issue-$ARGUMENTS-*.md | head -1 | cut -d' ' -f2`
4461
- Consider appropriate labels and reviewers
4562

46-
4. **PR Description Template**
63+
5. **Fork Workflow Examples**
64+
65+
**Example 1: Fork-to-Upstream PR**
66+
```
67+
# Check if current repo is a fork
68+
get_fork_info("github", "myuser/upstream-project")
69+
70+
# If it's a fork, create PR to upstream
71+
create_merge_request(
72+
platform="github",
73+
project_id="upstream-owner/upstream-project", # Target upstream repo
74+
source_branch="myuser:feature-branch", # Fork branch reference
75+
target_branch="main", # Upstream main branch
76+
title="Fix issue #123: Add new feature",
77+
description="Implements feature as requested in issue..."
78+
)
79+
```
80+
81+
**Example 2: Same-Repository PR (existing behavior)**
82+
```
83+
create_merge_request(
84+
platform="github",
85+
project_id="myuser/my-project",
86+
source_branch="feature-branch", # Simple branch name
87+
target_branch="main",
88+
title="Fix issue #123: Add new feature",
89+
description="Implements feature as requested in issue..."
90+
)
91+
```
92+
93+
6. **PR Description Template**
4794
```
4895
## Summary
4996
Implements [feature description] as requested in issue #$ARGUMENTS
@@ -60,13 +107,24 @@ Analyze the changes made thoroughly and consider multiple ways to present them c
60107
Closes #$ARGUMENTS
61108
```
62109

63-
5. **Final Steps**
110+
7. **Available Fork MCP Tools**
111+
112+
**New Tools for Fork Management:**
113+
- `create_fork(platform, project_id, **kwargs)` - Create a fork of a repository
114+
- `get_fork_info(platform, project_id)` - Check fork status and get parent info
115+
- `list_forks(platform, project_id)` - List forks of a repository (basic implementation)
116+
117+
**Enhanced Existing Tools:**
118+
- `create_merge_request()` - Now supports cross-repository PRs with `owner:branch` format
119+
- All existing MCP tools work seamlessly with fork workflows
120+
121+
8. **Final Steps**
64122
- Link PR to original issue (use `update_issue()` to close issue if needed)
65123
- Request code review via `get_merge_request_details()` for tracking
66124
- Monitor CI/CD pipeline
67125
- Address review feedback
68126

69-
6. **Complete Issue Documentation**
127+
9. **Complete Issue Documentation**
70128
- Save final PR details to `.claude/issue-$ARGUMENTS-*.md`
71129
- Mark workflow as completed in the documentation
72130
- Issue document now serves as complete project history for this feature

git_mcp/cli.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .core.config import get_config
1010
from .core.exceptions import GitMCPError
1111
from .utils.output import OutputFormatter
12+
from . import get_version
1213

1314

1415
# Global context for CLI
@@ -25,7 +26,7 @@ def get_formatter(self) -> OutputFormatter:
2526
return self.formatter
2627

2728

28-
@click.group()
29+
@click.group(invoke_without_command=True)
2930
@click.option(
3031
"--format",
3132
"output_format",
@@ -35,9 +36,23 @@ def get_formatter(self) -> OutputFormatter:
3536
)
3637
@click.option("--platform", help="Default platform to use")
3738
@click.option("--config-dir", type=click.Path(), help="Configuration directory path")
39+
@click.option(
40+
"--version",
41+
is_flag=True,
42+
help="Show version and exit",
43+
)
3844
@click.pass_context
39-
def cli(ctx, output_format, platform, config_dir):
45+
def cli(ctx, output_format, platform, config_dir, version):
4046
"""Git MCP Server - Unified management for GitHub and GitLab."""
47+
if version:
48+
click.echo(f"git-mcp {get_version()}")
49+
ctx.exit()
50+
51+
# If no subcommand is provided, show help
52+
if ctx.invoked_subcommand is None:
53+
click.echo(ctx.get_help())
54+
ctx.exit()
55+
4156
ctx.ensure_object(CLIContext)
4257

4358
if config_dir:

git_mcp/gemini_commands/implement.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,23 @@ Please implement the planned functionality thoroughly and in great detail, consi
2424
2525
Use `get_project_details()` to understand codebase structure and `list_merge_requests()` to review implementation patterns in recent changes.
2626
27+
## Platform API Resources
28+
29+
**When implementing platform-specific features**, refer to the API documentation in CLAUDE.md:
30+
31+
**For GitLab integrations** (`git_mcp/platforms/gitlab.py`):
32+
- API Objects Reference: https://python-gitlab.readthedocs.io/en/stable/api-objects.html
33+
- Usage Examples: https://python-gitlab.readthedocs.io/en/stable/gl_objects/
34+
35+
**For GitHub integrations** (`git_mcp/platforms/github.py`):
36+
- Examples & Patterns: https://pygithub.readthedocs.io/en/stable/examples.html
37+
- API Reference: https://pygithub.readthedocs.io/en/stable/github_objects.html
38+
39+
**Common use cases requiring API docs:**
40+
- Extending platform adapter methods
41+
- Adding new MCP tools for platform operations
42+
- Implementing custom issue/PR workflows
43+
- Debugging API response handling
44+
2745
Use `/test` after implementation to generate comprehensive tests.
2846
'''

git_mcp/gemini_commands/plan.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ Create a comprehensive development plan including:
1818
1919
Use `get_project_details()` to understand project structure and `list_merge_requests()` to review existing workflow patterns.
2020
21+
## Platform API Planning
22+
23+
**When planning platform integrations**, consult the API documentation in CLAUDE.md:
24+
25+
**GitLab API Resources:**
26+
- API Objects: https://python-gitlab.readthedocs.io/en/stable/api-objects.html
27+
- Usage Patterns: https://python-gitlab.readthedocs.io/en/stable/gl_objects/
28+
29+
**GitHub API Resources:**
30+
- Examples: https://pygithub.readthedocs.io/en/stable/examples.html
31+
- API Reference: https://pygithub.readthedocs.io/en/stable/github_objects.html
32+
33+
**Consider API limitations and capabilities when planning:**
34+
- Rate limiting requirements
35+
- Authentication scopes needed
36+
- Available operations and data structures
37+
- Error handling patterns
38+
2139
## Repository Context
2240
2341
Analyze current repository structure by running:

git_mcp/gemini_commands/pr.toml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,40 @@ Analyze the changes made thoroughly and consider multiple ways to present them c
1111
1. **Prepare Branch**
1212
Run git commands to add, check status, and commit changes
1313
14-
2. **Push to Remote**
14+
2. **Fork Detection and Repository Analysis**
15+
- Use `get_fork_info()` to check if current repository is a fork
16+
- If it's a fork, identify the upstream repository for PR creation
17+
- Determine the correct target repository (fork vs upstream)
18+
19+
3. **Push to Remote**
1520
Push the current branch to remote repository
1621
17-
3. **Create Pull/Merge Request**
18-
Use `create_merge_request()` to create the PR/MR with:
22+
4. **Create Pull/Merge Request with Fork Support**
23+
Use `create_merge_request()` with enhanced fork support:
24+
25+
**For Fork-to-Upstream PRs:**
26+
- Source branch: `username:branch-name` format (automatically detected)
27+
- Target repository: Upstream repository (parent)
28+
- Target branch: Usually `main` or `master`
29+
30+
**For Same-Repository PRs:**
31+
- Source branch: `branch-name` format (current behavior)
32+
- Target repository: Current repository
33+
- Target branch: As specified or default
34+
35+
**PR Parameters:**
1936
- Craft a descriptive title linking to issue
2037
- Create comprehensive description that clearly explains the solution
2138
- Closes #[issue-id] in description
2239
- Consider appropriate labels and reviewers
2340
24-
4. **PR Description Template**
41+
5. **Available Fork MCP Tools**
42+
- `create_fork(platform, project_id, **kwargs)` - Create a fork
43+
- `get_fork_info(platform, project_id)` - Check fork status
44+
- `list_forks(platform, project_id)` - List repository forks
45+
- `create_merge_request()` - Enhanced with cross-repo support
46+
47+
6. **PR Description Template**
2548
```
2649
## Summary
2750
Implements [feature description] as requested in issue #[issue-id]
@@ -38,7 +61,7 @@ Analyze the changes made thoroughly and consider multiple ways to present them c
3861
Closes #[issue-id]
3962
```
4063
41-
5. **Final Steps**
64+
7. **Final Steps**
4265
- Link PR to original issue (use `update_issue()` to close issue if needed)
4366
- Request code review via `get_merge_request_details()` for tracking
4467
- Monitor CI/CD pipeline

0 commit comments

Comments
 (0)