Skip to content

Conversation

@thecoderpanda
Copy link

@thecoderpanda thecoderpanda commented Nov 6, 2025

  • Implement git_push function with support for:
    • Pushing to custom remotes (default: origin)
    • Pushing specific branches
    • Force push capability
    • Setting upstream branch (-u flag)
  • Add GitPush model with comprehensive field descriptions
  • Register git_push as a new tool in the MCP server
  • Add test coverage for push functionality
  • Update README with git_push tool documentation
    Resolves Feature Request: Add push to git mcp #618

Description

This PR implements the git_push tool for the Git MCP server, enabling users to push branches to remote repositories. This addresses issue #618 where users need the ability to push branches remotely to support integration with other MCPs that create pull requests.

Server Details

  • Server: git
  • Changes to: tools, README documentation

Motivation and Context

Users working with multiple MCPs need the ability to push branches to remote repositories before creating pull requests through other tools. The Git MCP server previously lacked this functionality, limiting its utility in CI/CD and automation workflows. This feature enables seamless integration with other MCPs that depend on remote branch existence.

How Has This Been Tested?

  • Added test_git_push_no_remote() unit test to verify error handling when pushing to a non-existent remote
  • Verified syntax and imports compile correctly with Python 3.10
  • Tested with actual GitPython library to ensure proper argument composition

Breaking Changes

No breaking changes. This is a new tool addition that does not affect existing functionality.

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with unit tests
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all parameters and configuration options

Additional context

The implementation uses GitPython's repo.git.push() method with dynamic argument construction to support:

  • Optional branch specification (defaults to current branch)
  • Custom remote targets (defaults to 'origin')
  • Force push for overwriting remote history
  • Upstream tracking with the -u flag

All parameters are optional with sensible defaults, making the tool flexible for various use cases.


Built with Zencoder

- Implement git_push function with support for:
  - Pushing to custom remotes (default: origin)
  - Pushing specific branches
  - Force push capability
  - Setting upstream branch (-u flag)
- Add GitPush model with comprehensive field descriptions
- Register git_push as a new tool in the MCP server
- Add test coverage for push functionality
- Update README with git_push tool documentation

Resolves modelcontextprotocol#618
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add push to git mcp

2 participants