- Home
- MCP servers
- Git PR
Git PR
- python
2
GitHub Stars
python
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"peterj-git-pr-mcp": {
"command": "uv",
"args": [
"run",
"python",
"-m",
"src.git_pr_mcp.server"
],
"env": {
"FASTMCP_HOST": "0.0.0.0",
"FASTMCP_PORT": "9999",
"GITHUB_TOKEN": "YOUR_TOKEN"
}
}
}
}This MCP server provides a focused set of tools to manage Git repositories and Pull Request workflows through a Model Context Protocol interface. It automates common Git operations and PR tasks, enabling you to clone repositories, manipulate branches and files, commit and push changes, and create GitHub PRs from a centralized, scriptable endpoint.
How to use
You interact with the MCP server using a client that understands MCP endpoints. Start by pointing your client to the server, then invoke the available tools to perform repository operations. You can manage an active repository, execute core Git commands, and drive automated PR workflows all from the MCP interface.
Core operations let you inspect and modify a repository located at a specified path, while the automated PR workflow operates on an internally managed active repository. Typical workflows include cloning a GitHub repository to begin work, creating branches, writing files, committing and pushing changes, and optionally creating a GitHub PR when you have a token. The server maintains a record of the currently active repository so you can continue work across requests and sessions.
How to install
Prerequisites you need before installing and running the MCP server:
Python (3.8+), and the Ultraviolet runtime (uv) for running Python MCP servers.
Source code access is required to install and run the server locally.
# Step 1: Clone the project
git clone <repository-url>
cd git-pr-mcp
# Step 2: Install dependencies and prepare the environment
uv sync
Create and populate a dot-env file with your runtime configuration. You will need to set the host, port, and your GitHub access token for PR creation.
FASTMCP_HOST=0.0.0.0
FASTMCP_PORT=9999
GITHUB_TOKEN=your_github_token
Step to start the MCP server using the recommended run method. You have two common options shown here.
# Run with defaults (0.0.0.0:8000)
uv run python main.py
# Or run the server module directly
uv run python -m src.git_pr_mcp.server
Additional sections
Configuration and runtime notes including environment variables and state management are important for reliable operation.
State management keeps track of the currently active cloned repository. The server stores this state in an active_repo_state.json file, which helps preserve context across restarts while the temporary clone directory itself is managed by the operating system.
Environment variables you should be aware of when running the server:
FASTMCP_HOST - Host interface the server binds to (e.g., 0.0.0.0)
FASTMCP_PORT - Port the server listens on (e.g., 9999)
GITHUB_TOKEN - Token used to authenticate to GitHub for PR creation
Available tools
get_git_status
Return the current status of the repository, including staged changes, untracked files, and the overall clean/dirty state.
list_branches
List all branches in the repository, with an option to include remote-tracking branches.
create_pr_summary
Generate a summary for a pull request based on the git diff between commits or branches.
get_commit_history
Fetch the commit history for a specified branch, with optional limits and filters.
get_git_diff
Produce diff information between two commits, between a commit and a branch, or between the working directory and a reference.
clone_repository
Clone a GitHub repository into an internally managed temporary directory and set it as the active repository, cleaning up any previously active clone.
create_git_branch
Create a new branch in the active repository.
write_file_in_repo
Create or overwrite files within the active repository.
git_commit_changes
Stage all changes and commit them in the active repository.
git_push_branch
Push a specified branch from the active repository to its remote origin.
create_github_pr
Create a GitHub pull request for the active repository using the GitHub token via the PyGithub library.