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:
[]
= "0.1"
Usage
As a Library
use ;
async
As an MCP Server
The binary runs an HTTP server exposing all Git tools via MCP:
The server typically runs on port 30450 and is managed by the kodegend daemon.
Using MCP Tools
Connect via MCP client:
use tools;
use json;
// Call git_commit tool
let result = client.call_tool.await?;
Examples
See the examples/ directory for comprehensive demonstrations:
# Run the full Git demo (20+ operations)
# Run direct API usage example
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.await??;
let repo_clone = repo.clone; // Cheap! Shares underlying data
This enables safe concurrent operations while maintaining the performance benefits of gix.
Development
Build
Test
# Run all tests
# Run specific test
# Run with output
Lint
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