Skip to main content

AI-powered Git CLI using MCP + Gemini to auto-generate commit messages

Project description

agent-gitv1 🤖

AI-powered Git CLI — Uses Model Context Protocol (MCP) + Google Gemini to automatically generate professional commit messages from your diff.


How It Works

Your Code Changes
      │
      ▼
[MCP Client] ──stdio──► [mcp-server-git]
      │                        │
      │◄── git diff ───────────┘
      │
      ▼
[Gemini AI] ──► Generate commit message
      │
      ▼
[MCP Client] ──► git add . ──► git commit

Prerequisites

Tool Install
Python ≥ 3.10 python.org
uvx (uv tool runner) pip install uv
mcp-server-git Auto-fetched by uvx
Gemini API Key aistudio.google.com

Installation

# 1. Clone / navigate to the project
cd "d:\Vijay Projects\Agent_bhai"

# 2. Install in editable mode (creates the `agent` command globally)
pip install -e .

# 3. Set your Gemini API key
set GEMINI_API_KEY=your_gemini_api_key_here     # Windows CMD
$env:GEMINI_API_KEY="your_key"                  # Windows PowerShell
export GEMINI_API_KEY=your_gemini_api_key_here  # Linux / Mac

Usage

agent config — Configure LLM Provider (Start Here!)

Run this to configure OpenAI, Google Gemini, or Ollama.

agent config

What you can configure:

  • Google Gemini: Uses your API key and a model like gemini-2.0-flash.
  • OpenAI (ChatGPT): Uses your API key and a model like gpt-4o-mini.
  • Ollama (Local/Network): Provide the base URL (e.g. http://localhost:11434 or http://192.168.1.50:11434). The CLI will automatically fetch your downloaded models and let you choose one!

agent commit — Stage + AI commit message + commit

# In any git repo:
agent commit

# Specify a repo path:
agent commit --repo /path/to/repo

# Generate multiple suggestions (pick one or type your own):
agent commit --suggestions 3

# Verbose mode (shows diff preview + available MCP tools):
agent commit --verbose
agent commit -v

agent commit is now history-aware:

  • It uses recent commit messages from your repo to align tone/style.
  • It includes changed file names in the LLM prompt for better scoped messages.

agent push — Push to remote

agent push
agent push --remote origin --branch main

Help

agent --help
agent config --help
agent commit --help
agent push --help

Example Session

🗂  Repository: D:\my-project

🔌 Connecting to mcp-server-git...
✅ MCP session initialized.

📂 Fetching git diff (unstaged changes)...
   Diff captured (1240 chars).

🤖 Generating commit message with Gemini...

💬 Commit Message: feat(auth): add JWT token refresh endpoint

Proceed with git add + commit? [Y/n]: y

📦 Staging all changes (git add .)...
   Files staged.

✍️  Committing...
   [main a3f12bc] feat(auth): add JWT token refresh endpoint

🚀 Done! Changes committed successfully.

Environment Variables

Variable Required Description
GEMINI_API_KEY ✅ Yes Your Google Gemini API key

Project Structure

Agent_bhai/
├── agent.py          # Main CLI + MCP client logic
├── pyproject.toml    # Packaging + entry point config
└── README.md         # This file

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_gitv1-0.1.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_gitv1-0.1.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file agent_gitv1-0.1.1.tar.gz.

File metadata

  • Download URL: agent_gitv1-0.1.1.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for agent_gitv1-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9cb2d0364805a4ac6ef111523635357f90b5ebcb291250dc62a58c63f515b987
MD5 31d6947bde1c2f8f0445c7f4909b4c37
BLAKE2b-256 1d1630ab1a616cdf17b2b30964765b04aec5bb403ea8c581d00301b79f4fd810

See more details on using hashes here.

File details

Details for the file agent_gitv1-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: agent_gitv1-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for agent_gitv1-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cbe9441fce8bfd9f4107c03e7d1e8ce55390a695d5625fc3abd14dce4ead9638
MD5 4c20cd139c2b06551a8289166dc193d9
BLAKE2b-256 c605f7aaaa6a7921701c26a366930f358bc51c9cdaa41e5b771f802167235a12

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page