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.0.tar.gz (8.9 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.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agent_gitv1-0.1.0.tar.gz
  • Upload date:
  • Size: 8.9 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.0.tar.gz
Algorithm Hash digest
SHA256 80d394cd870412e64310491cb1d809fc1304af25c70011c64125e4012ef81c65
MD5 2a4e3899e4ffdd79365d47c49aa39e57
BLAKE2b-256 51150f36bc7e7bcedd4a060e98429f778c9b39c865b853bdb48f5c1a86f53ff7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agent_gitv1-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0691b4927ee74c785f3e595d25551fa8ae858558ebf004b04a88f7810dd90119
MD5 a395d1e35a397d90bc12aa7fc89f1e1b
BLAKE2b-256 b5b45d3f9ba5ab888a58f581ee540b8caee23303c5214a380255dbf2a406704d

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