diff options
Diffstat (limited to 'cmd/git/README.md')
| -rw-r--r-- | cmd/git/README.md | 215 |
1 files changed, 0 insertions, 215 deletions
diff --git a/cmd/git/README.md b/cmd/git/README.md deleted file mode 100644 index 8bb7445..0000000 --- a/cmd/git/README.md +++ /dev/null @@ -1,215 +0,0 @@ -# Git MCP Server - -A Model Context Protocol (MCP) server that provides comprehensive Git repository operations and browsing capabilities. - -## Overview - -The Git MCP server enables AI assistants to interact with Git repositories through a standardized protocol. It provides tools for Git operations (status, diff, commit, branch management) and resources for browsing repository contents. - -## Installation - -### From Source -```bash -# Build the binary -make git - -# Install system-wide (requires sudo) -sudo make install -``` - -### Direct Build -```bash -go build -o mcp-git ./cmd/git -``` - -## Usage - -### Command Line Arguments - -```bash -mcp-git --repository <path> -``` - -**Required Arguments:** -- `--repository <path>`: Path to the Git repository to manage - -### Examples - -#### Basic Testing -```bash -# Test server initialization -echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": {"name": "test", "version": "1.0.0"}}}' | timeout 5s mcp-git --repository . - -# List available tools -echo '{"jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": {}}' | timeout 5s mcp-git --repository . - -# List repository resources -echo '{"jsonrpc": "2.0", "id": 3, "method": "resources/list", "params": {}}' | timeout 5s mcp-git --repository . - -# Check Git status -echo '{"jsonrpc": "2.0", "id": 4, "method": "tools/call", "params": {"name": "git_status", "arguments": {}}}' | timeout 5s mcp-git --repository . -``` - -#### Interactive Session -```bash -# Start the server (in another terminal or script) -mcp-git --repository /path/to/your/repo - -# Then send JSON-RPC requests via stdin -``` - -## Available Tools - -### Repository Status & Information -- **`git_status`**: Get current repository status -- **`git_log`**: View commit history with filtering options -- **`git_show`**: Show details of a specific commit - -### Diff Operations -- **`git_diff`**: Show differences between commits/branches -- **`git_diff_staged`**: Show staged changes -- **`git_diff_unstaged`**: Show unstaged changes - -### Branch Management -- **`git_create_branch`**: Create a new branch -- **`git_checkout`**: Switch branches or checkout commits -- **`git_list_branches`**: List all local and remote branches - -### File Operations -- **`git_add`**: Stage files for commit -- **`git_commit`**: Create commits with messages -- **`git_reset`**: Reset changes (soft, mixed, hard) - -### Repository Initialization -- **`git_init`**: Initialize a new Git repository - -## Resources - -The server provides `git://` resources for: - -### File Resources -- **URI Format**: `git://<repo_path>/<branch>/<file_path>` -- **Example**: `git:///home/user/project/main/src/main.go` -- **Description**: Access to tracked files in the repository - -### Branch Resources -- **URI Format**: `git://<repo_path>/branches/<branch_name>` -- **Example**: `git:///home/user/project/branches/feature-branch` -- **Description**: Information about repository branches - -### Commit Resources -- **URI Format**: `git://<repo_path>/commits/<commit_hash>` -- **Example**: `git:///home/user/project/commits/abc123def456` -- **Description**: Detailed commit information - -## Configuration Examples - -### Claude Desktop Integration -Add to your `~/.claude.json`: - -```json -{ - "mcpServers": { - "git": { - "command": "/usr/local/bin/mcp-git", - "args": ["--repository", "/path/to/your/repository"] - } - } -} -``` - -### Multiple Repositories -```json -{ - "mcpServers": { - "git-project1": { - "command": "/usr/local/bin/mcp-git", - "args": ["--repository", "/home/user/project1"] - }, - "git-project2": { - "command": "/usr/local/bin/mcp-git", - "args": ["--repository", "/home/user/project2"] - } - } -} -``` - -## Example Workflows - -### Check Repository Status -```bash -echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "git_status", "arguments": {}}}' | mcp-git --repository . -``` - -### Create and Switch to New Branch -```bash -# Create branch -echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "git_create_branch", "arguments": {"branch_name": "feature-new"}}}' | mcp-git --repository . - -# Switch to branch -echo '{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "git_checkout", "arguments": {"target": "feature-new"}}}' | mcp-git --repository . -``` - -### View Recent Commits -```bash -echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "git_log", "arguments": {"max_count": 5}}}' | mcp-git --repository . -``` - -### Stage and Commit Changes -```bash -# Stage files -echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "git_add", "arguments": {"files": ["src/main.go", "README.md"]}}}' | mcp-git --repository . - -# Commit changes -echo '{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "git_commit", "arguments": {"message": "Add new feature implementation"}}}' | mcp-git --repository . -``` - -## Security Considerations - -- The server only operates within the specified repository directory -- No access to files outside the repository -- Git operations respect repository permissions -- No network operations (clone, push, pull) for security - -## Performance - -- **Startup Time**: ~2-3ms for typical repositories -- **Resource Limit**: Maximum 500 files loaded for resource discovery -- **Memory Usage**: <10MB for most repositories -- **Lazy Loading**: Resources discovered on-demand - -## Troubleshooting - -### Common Issues - -1. **"Repository not found"** - ```bash - # Ensure the path exists and is a Git repository - git status # Test if directory is a valid Git repo - ``` - -2. **"Permission denied"** - ```bash - # Check file permissions - ls -la /path/to/repository - ``` - -3. **"Invalid repository path"** - ```bash - # Use absolute paths for reliability - mcp-git --repository "$(pwd)" - ``` - -### Debug Mode -```bash -# Enable verbose logging (if implemented) -RUST_LOG=debug mcp-git --repository . -``` - -## Contributing - -See the main project README for contribution guidelines. - -## License - -This project is licensed under the same terms as the parent MCP project.
\ No newline at end of file |
