Provides tools for local Git repository operations including checking status, viewing commit history, creating diffs, managing branches, staging files, and creating commits.
Enables GitHub API operations including listing pull requests, creating new pull requests, and adding comments to pull requests through GitHub's REST API.
Git Workflow MCP Server
A Model Context Protocol (MCP) server that provides Git workflow tools over HTTP. This server enables AI assistants like Cursor, Claude, and ChatGPT to interact with local Git repositories and optionally with GitHub via the API.
Features
Local Git Tools (No GitHub Token Required)
git_status- Get current Git status including branch, ahead/behind counts, and file listsgit_log- View commit history with author, date, and messagesgit_diff- Show diff for specific filesgit_list_branches- List all branches and show current branchgit_stage_files- Stage files for commitgit_commit- Create commits with messagesgit_checkout_branch- Checkout branches (with optional creation)
GitHub Tools (Requires GITHUB_TOKEN)
github_list_prs- List pull requests (open, closed, or all)github_create_pr- Create new pull requestsgithub_comment_on_pr- Add comments to pull requests
Installation
Clone or download this repository
Install dependencies:
Configuration
Environment Variables
GIT_MCP_REPO(optional): Path to the Git repository the MCP server should operate on. Defaults to the current working directory if not set.GITHUB_TOKEN(optional): GitHub personal access token. If set, enables GitHub API tools. If not set, GitHub tools will return an error indicating that GitHub integration is disabled.
Getting a GitHub Token
Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
Generate a new token with
reposcopeCopy the token and set it as an environment variable
Running the Server
Basic Usage
With Custom Host/Port
The server will be available at http://127.0.0.1:3333/mcp (or your custom host/port).
Configuring as an MCP Server
For Cursor
Add to your Cursor MCP settings (typically in ~/.cursor/mcp.json or similar):
Or if using HTTP transport directly:
For Claude Desktop
Add to your Claude Desktop configuration (typically ~/Library/Application Support/Claude/claude_desktop_config.json on macOS or similar location on other platforms):
Usage Examples
Example 1: Check Repository Status
Prompt: "Use your git tools to show me the status of my repo and summarize changes."
The AI will call git_status and provide a summary of:
Current branch
Ahead/behind counts
Staged files
Modified files
Untracked files
Example 2: Stage and Commit Changes
Prompt: "Stage all modified files, generate a good commit message, and commit."
The AI will:
Call
git_statusto see what's modifiedCall
git_stage_fileswith the list of modified filesGenerate an appropriate commit message
Call
git_commitwith the message
Example 3: View Recent Commits
Prompt: "Show me the last 5 commits with their authors and messages."
The AI will call git_log with limit=5 and format the results.
Example 4: List GitHub Pull Requests
Prompt: "List open PRs on GitHub for this repo and summarize them."
The AI will call github_list_prs with state="open" and provide a summary of all open pull requests.
Example 5: Create a Pull Request
Prompt: "Create a pull request for the current branch targeting main with title 'Add new feature'."
The AI will call github_create_pr with the appropriate parameters.
Important Notes
Local Git tools work without any GitHub token - You can use all the Git operations (status, log, diff, stage, commit, checkout) without setting
GITHUB_TOKEN.GitHub tools require - The GitHub API tools (
github_list_prs,github_create_pr,github_comment_on_pr) will only work whenGITHUB_TOKENis set. If the token is not set, these tools will return an error message indicating that GitHub integration is disabled.Repository must be a Git repository - The
GIT_MCP_REPOpath must point to a directory containing a.gitfolder. If it doesn't, Git operations will fail with a clear error message.File path validation - All file paths provided to Git tools are validated to ensure they are within the repository root for security.
Project Structure
Development
Testing Locally
Start the server:
Test the health endpoint:
Test MCP endpoint (example):
License
This project is provided as-is for use with MCP-compatible AI assistants.
Troubleshooting
"No Git repository found"
Ensure
GIT_MCP_REPOpoints to a valid Git repository (contains.gitfolder)Or run the server from within a Git repository directory
"GitHub integration is disabled"
Set the
GITHUB_TOKENenvironment variableEnsure the token has the
reposcopeVerify the repository has a GitHub remote configured (
git remote get-url origin)
"Path is outside repository root"
Ensure all file paths are relative to the repository root
Do not use absolute paths or paths with
..that escape the repository
This server cannot be installed