Cover image
Try Now
2025-03-09

Biblioteca de integración de herramientas GIT para el Protocolo de contexto del modelo (MCP).

3 years

Works with Finder

1

Github Watches

1

Github Forks

2

Github Stars

MCP Git Tools

Git tool integration library for the Model Context Protocol (MCP).

中文文档

Features

This library provides a set of Git operations that can be called through the Model Context Protocol:

  • git_status - Get the status of a repository
  • git_branches - List branch information
  • git_log - Get commit history
  • git_time_filtered_log - Get commits within a specific time range
  • git_commit - Create a new commit
  • git_pull - Pull changes from remote
  • git_push - Push changes to remote
  • git_diff - View file differences
  • git_add - Add file contents to the staging area
  • git_reset - Reset the staging area or working tree to a specified state

Installation

# Clone the repository
git clone https://github.com/lileeei/mcp-git-tools.git

# Navigate to the directory
cd mcp-git-tools

# Build
cargo build

Usage

Run as a standalone server

cargo run --bin mcp-git-server

This starts an MCP server that interacts with clients through standard input/output.

Use in an MCP client

use mcp_client::{
    client::{ClientCapabilities, ClientInfo, McpClient},
    StdioTransport, Transport, McpService,
};
use std::collections::HashMap;
use std::time::Duration;

// Create a connection to the Git tools server
let transport = StdioTransport::new(
    "path/to/mcp-git-server", 
    vec![], 
    HashMap::new()
);

// Start the transport
let handle = transport.start().await?;
let service = McpService::with_timeout(handle, Duration::from_secs(10));
let mut client = McpClient::new(service);

// Initialize the client
client.initialize(
    ClientInfo {
        name: "my-client".into(),
        version: "1.0.0".into(),
    },
    ClientCapabilities::default(),
).await?;

// Call the git_status tool
let status = client
    .call_tool("git_status", serde_json::json!({ "repo_path": "/path/to/repo" }))
    .await?;

println!("Git status: {:?}", status);

Integrate into your own MCP server

use mcp_git_tools::register_git_tools;
use mcp_server::McpServerBuilder;

// Create a server
let mut builder = McpServerBuilder::new("my-server", "1.0.0");

// Register Git tools
register_git_tools(&mut builder);

// Add other tools...

// Build the server
let server = builder.build();

Tool Details

git_status

Get the status of a repository.

Parameters:

  • repo_path - Path to the Git repository

Returns:

{
  "status": ["M file1.txt", "?? file2.txt"],
  "is_clean": false
}

git_branches

List all branches.

Parameters:

  • repo_path - Path to the Git repository

Returns:

{
  "branches": ["* main", "develop", "feature/new-feature"],
  "current": "main"
}

git_log

Get commit history.

Parameters:

  • repo_path - Path to the Git repository
  • max_count - (optional) Maximum number of commits to return
  • branch - (optional) Branch name

Returns:

{
  "commits": [
    {
      "hash": "abcd1234",
      "author": "User Name",
      "date": "Mon Aug 1 10:00:00 2023 +0800",
      "message": "Initial commit"
    }
  ]
}

git_time_filtered_log

Get commits within a specified time range, optionally filtered by author and branch.

Parameters:

  • repo_path - Path to the Git repository
  • since - Start date (e.g., "2023-01-01", "1 week ago", "yesterday")
  • until - (optional) End date (e.g., "2023-01-31", "today")
  • author - (optional) Filter by specific author
  • branch - (optional) Branch name

Returns:

{
  "commits": [
    {
      "hash": "abcd1234",
      "author": "User Name",
      "date": "Mon Aug 1 10:00:00 2023 +0800",
      "message": "Initial commit"
    }
  ],
  "filters": {
    "since": "1 week ago",
    "until": "today",
    "author": "User Name",
    "branch": "main"
  }
}

git_commit

Create a new commit.

Parameters:

  • repo_path - Path to the Git repository
  • message - Commit message
  • all - (optional) Whether to automatically stage modified files

Returns:

{
  "success": true,
  "hash": "abcd1234",
  "message": "feat: Add new feature",
  "output": "[main abcd1234] feat: Add new feature\n 1 file changed, 10 insertions(+), 2 deletions(-)"
}

git_pull

Pull changes from remote.

Parameters:

  • repo_path - Path to the Git repository
  • remote - (optional) Remote name, defaults to "origin"
  • branch - (optional) Branch name

Returns:

{
  "success": true,
  "remote": "origin",
  "output": "Updating abcd1234..efgh5678\nFast-forward\n file1.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)"
}

git_push

Push changes to remote.

Parameters:

  • repo_path - Path to the Git repository
  • remote - (optional) Remote name, defaults to "origin"
  • branch - (optional) Branch name
  • force - (optional) Whether to force push

Returns:

{
  "success": true,
  "remote": "origin",
  "output": "To github.com:user/repo.git\n   abcd1234..efgh5678  main -> main"
}

git_diff

View file differences.

Parameters:

  • repo_path - Path to the Git repository
  • path - (optional) Path to file or directory
  • staged - (optional) Whether to show staged changes
  • commit - (optional) Commit to compare against

Returns:

{
  "diff": "diff --git a/file.txt b/file.txt\nindex 1234567..abcdefg 100644\n--- a/file.txt\n+++ b/file.txt\n@@ -1,3 +1,4 @@\n Line 1\n Line 2\n+New line\n Line 3"
}

git_add

Add file contents to the staging area.

Parameters:

  • repo_path - Path to the Git repository
  • path - Path(s) to add, or patterns to match. Use '.' for all files.
  • update - (optional) Whether to update, rather than add
  • all - (optional) Whether to add all changes, including untracked files

Returns:

{
  "success": true,
  "message": "Files staged successfully",
  "status": ["M file1.txt", "A file2.txt"]
}

git_reset

Reset the staging area or working tree to a specified state.

Parameters:

  • repo_path - Path to the Git repository
  • path - Path(s) to reset, or patterns to match. Use '.' for all files.
  • hard - (optional) Whether to perform a hard reset (WARNING: discards all local changes)
  • target - (optional) The commit or branch to reset to (defaults to HEAD)

Returns:

{
  "success": true,
  "message": "Files unstaged successfully",
  "status": ["?? file1.txt", "?? file2.txt"]
}

License

MIT License

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Beniyam Berhanu
  • Therapist adept at identifying core issues and offering practical advice with images.

  • ANGEL LEON
  • A world class elite tech co-founder entrepreneur, expert in software development, entrepreneurship, marketing, coaching style leadership and aligned with ambition for excellence, global market penetration and worldy perspectives.

  • https://tovuti.be
  • Oede knorrepot die vasthoudt an de goeie ouwe tied van 't boerenleven

  • apappascs
  • Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.

  • ShrimpingIt
  • Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx

  • OffchainLabs
  • Implementación de la prueba de estaca Ethereum

  • huahuayu
  • Una puerta de enlace de API unificada para integrar múltiples API de explorador de blockchain similar a Esterscan con soporte de protocolo de contexto modelo (MCP) para asistentes de IA.

  • deemkeen
  • Controle su MBOT2 con un combo de potencia: MQTT+MCP+LLM

  • zhaoyunxing92
  • 本项目是一个钉钉 MCP (Protocolo del conector de mensajes )服务 , 提供了与钉钉企业应用交互的 API 接口。项目基于 Go 语言开发 支持员工信息查询和消息发送等功能。 支持员工信息查询和消息发送等功能。

  • pontusab
  • La comunidad de cursor y windsurf, encontrar reglas y MCP

    Reviews

    1 (1)
    Avatar
    user_icFCqIgl
    2025-04-15

    I've been using Powerdrill from Powerdrillai, and I must say it's an incredible tool! It's user-friendly and has significantly improved my workflow. The intuitive interface and powerful features make complex tasks much simpler. I highly recommend it to anyone looking to boost their productivity. Check it out at https://mcp.so/server/powerdrill/powerdrillai!