9 releases
Uses new Rust 2024
| new 0.6.1 | Dec 4, 2025 |
|---|---|
| 0.5.4 | Dec 3, 2025 |
| 0.5.0 | Nov 29, 2025 |
#746 in Development tools
35 downloads per month
Used in 5 crates
(3 directly)
4.5MB
10K
SLoC
kodegen_tools_git
Memory-efficient, blazing-fast Git operations for AI code generation agents via Model Context Protocol (MCP).
Part of the KODEGEN.ai ecosystem.
Features
- 🚀 High Performance: Built on gix (Gitoxide), a fast Rust Git implementation
- ⚡ Async-First: Fully asynchronous API with tokio integration
- 🔧 MCP Native: 20+ tools implementing the Model Context Protocol for AI agents
- 💡 Ergonomic API: Builder patterns and strongly-typed interfaces
- 🔒 Type Safe: Comprehensive error handling with domain-specific error types
- 📦 Zero-Config: Stateless tools with minimal setup required
Available Git Tools
Repository Operations
git_init- Initialize new repositoriesgit_open- Open existing repositoriesgit_clone- Clone remote repositoriesgit_discover- Discover repository from any path
Branch Management
git_branch_create- Create new branchesgit_branch_delete- Delete branchesgit_branch_list- List all branchesgit_branch_rename- Rename branches
Core Operations
git_add- Stage files for commitgit_commit- Create commits with full metadatagit_checkout- Switch branches or restore filesgit_log- View commit history with streaming support
Remote Operations
git_fetch- Fetch from remotesgit_merge- Merge branches
Worktree Management
git_worktree_add- Create linked worktreesgit_worktree_remove- Remove worktreesgit_worktree_list- List all worktreesgit_worktree_lock- Lock worktreesgit_worktree_unlock- Unlock worktreesgit_worktree_prune- Prune stale worktrees
Installation
Add to your Cargo.toml:
[dependencies]
kodegen_tools_git = "0.1"
Usage
As a Library
use kodegen_tools_git::{open_repo, CommitOpts, Signature};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Open a repository
let repo = open_repo("/path/to/repo").await??;
// Create a commit with builder pattern
let commit_id = kodegen_tools_git::commit(
repo,
CommitOpts::message("feat: add new feature")
.all(true)
.author(Signature::new("Your Name", "you@example.com"))
).await?;
println!("Created commit: {}", commit_id);
Ok(())
}
As an MCP Server
The binary runs an HTTP server exposing all Git tools via MCP:
cargo run --bin kodegen-git
The server typically runs on port 30450 and is managed by the kodegend daemon.
Using MCP Tools
Connect via MCP client:
use kodegen_mcp_client::tools;
use serde_json::json;
// Call git_commit tool
let result = client.call_tool(
tools::GIT_COMMIT,
json!({
"path": "/path/to/repo",
"message": "feat: add feature",
"all": true
})
).await?;
Examples
See the examples/ directory for comprehensive demonstrations:
# Run the full Git demo (20+ operations)
cargo run --example git_demo
# Run direct API usage example
cargo run --example direct_comprehensive
Architecture
Three-Layer Design
-
Operations Layer (
src/operations/)- Pure Git logic using
gix - Builder patterns for ergonomic configuration
- Async functions wrapping blocking operations
- Pure Git logic using
-
Tools Layer (
src/tools/)- MCP tool wrappers
- JSON schema validation
- Protocol bridging
-
Runtime Layer (
src/runtime/)- Async task execution
- Streaming results
- Progress reporting
RepoHandle
The RepoHandle type provides cheap cloning for thread-safe repository access:
let repo = open_repo("/path/to/repo").await??;
let repo_clone = repo.clone(); // Cheap! Shares underlying data
This enables safe concurrent operations while maintaining the performance benefits of gix.
Development
Build
cargo build
Test
# Run all tests
cargo test
# Run specific test
cargo test test_name
# Run with output
cargo test -- --nocapture
Lint
cargo clippy --no-deps
Performance
Built on gix (Gitoxide), this library provides:
- Fast object access: Efficient ODB operations
- Minimal allocations: Zero-copy where possible
- Concurrent operations: Cheap repository cloning enables parallelism
- Streaming logs: Memory-efficient commit history traversal
Contributing
Contributions are welcome! Please ensure:
- Tests pass:
cargo test - Code is formatted:
cargo fmt - Clippy is happy:
cargo clippy
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Links
- KODEGEN.ai - Homepage
- GitHub Repository
- Gitoxide - The underlying Git implementation
- MCP Specification - Model Context Protocol
Built with ❤️ by KODEGEN.ai
Dependencies
~55–93MB
~1.5M SLoC