MCP MGit Server

MCP MGit Server

Enables executing mgit push operations to manage and synchronize multiple Git repositories with batch commit and push capabilities. Supports multiple instances with repository isolation and operation logging.

Category
访问服务器

README

MCP MGit Server

A MCP server for executing mgit push operations with multiple instance support.

Prerequisites

⚠️ Important: This MCP server requires the MGit tool to be installed and configured on your system.

MGit is a command-line tool for managing multiple Git projects. It helps you efficiently manage, synchronize, and update multiple Git repositories.

MGit Installation and Setup

Before using this MCP server, please:

  1. Install MGit: Download and install MGit from https://github.com/liliangshan/mgit/releases
  2. Initialize MGit: Follow the MGit setup instructions in the MGit README
  3. Configure Projects: Use mgit init to add your Git repositories to MGit
  4. Verify Setup: Use mgit list to view available repository names

For detailed MGit usage instructions, features, and configuration, please refer to the MGit README.

Key MGit Features

  • Multi-project Management: Manage multiple Git projects with one click
  • Multi-language Support: Supports multiple languages including Chinese (Simplified/Traditional), English, Japanese, Korean, French
  • Remote Database Sync: Supports project configuration synchronization across multiple devices
  • Smart Branch Management: Automatically detects and switches branches to avoid conflicts
  • Batch Operations: Supports pulling/pushing changes for multiple projects simultaneously

Features

  • ✅ Execute mgit push command for repositories
  • ✅ Configurable mgit command (default: mgit)
  • ✅ Multiple instance support with repository name isolation
  • ✅ Operation logging
  • ✅ Error handling and recovery

Installation

Global Installation (Recommended)

npm install -g @liangshanli/mcp-server-mgit

Local Installation

npm install @liangshanli/mcp-server-mgit

From Source

git clone https://github.com/liliangshan/mcp-server-mgit.git
cd mcp-server-mgit
npm install

Configuration

Set environment variables:

# Required: Repository name (use 'mgit list' to view available repository names)
export REPO_NAME="my-repo"

# Optional: MGit command (default: mgit)
export MGIT_CMD="mgit"

# Optional: Language setting (default: en)
# Supported values: en (English), zh (Chinese), zh-CN (Simplified Chinese), zh-TW (Traditional Chinese)
export LANGUAGE="en"

# Optional: Enable/disable push history check (default: true)
# Set to false to skip history check requirement
export CHECK_PUSH_HISTORY="true"

# Optional: Project branding
export PROJECT_NAME="MyProject"

Usage

1. Direct Run (Global Installation)

mcp-server-mgit

2. Using npx (Recommended)

npx @liangshanli/mcp-server-mgit

3. Direct Start (Source Installation)

npm start

4. Managed Start (Recommended for Production)

npm run start-managed

Managed start provides:

  • Auto-restart (up to 10 times)
  • Error recovery
  • Process management
  • Logging

5. Development Mode

npm run dev

Editor Integration

Cursor Editor Configuration

  1. Create .cursor/mcp.json file in your project root:
{
  "mcpServers": {
    "mgit": {
      "command": "npx",
      "args": ["@liangshanli/mcp-server-mgit"],
      "env": {
        "REPO_NAME": "my-repo",
        "MGIT_CMD": "mgit",
        "LANGUAGE": "en",
        "PROJECT_NAME": "MyProject"
      }
    }
  }
}

VS Code Configuration

  1. Install the MCP extension for VS Code
  2. Create .vscode/settings.json file:
{
  "mcp.servers": {
    "mgit": {
      "command": "npx",
      "args": ["@liangshanli/mcp-server-mgit"],
      "env": {
        "REPO_NAME": "my-repo",
        "MGIT_CMD": "mgit",
        "LANGUAGE": "en",
        "PROJECT_NAME": "MyProject"
      }
    }
  }
}

Multiple MGit Server Instances Support

You can configure multiple MGit server instances with different REPO_NAME and PROJECT_NAME to isolate tools and configurations. Each instance must have a unique REPO_NAME (required). This is useful when you need to push to different repositories or manage different project groups. Use mgit list (or ${MGIT_CMD} list) to view available repository names.

Example: Cursor Editor Configuration

Create .cursor/mcp.json file:

{
  "mcpServers": {
    "mgit-local": {
      "disabled": false,
      "timeout": 60,
      "command": "npx",
      "args": ["@liangshanli/mcp-server-mgit"],
      "env": {
        "REPO_NAME": "local-repo",
        "MGIT_CMD": "mgit",
        "PROJECT_NAME": "local-mgit"
      }
    },
    "mgit-custom": {
      "disabled": false,
      "timeout": 60,
      "command": "npx",
      "args": ["@liangshanli/mcp-server-mgit"],
      "env": {
        "REPO_NAME": "custom-repo",
        "MGIT_CMD": "/path/to/custom-mgit",
        "PROJECT_NAME": "custom-mgit"
      }
    }
  }
}

Benefits of Multiple Instances:

  • Tool Isolation: Each instance has its own tool names (e.g., local_mgit_push, custom_mgit_push)
  • Config Isolation: Logs are stored in separate directories (e.g., ./.setting.local/, ./.setting.custom/)
  • Different Commands: Configure different mgit commands for each instance
  • Project Branding: Each instance can have its own project name for better identification

Note: When using multiple instances, tools will be prefixed with REPO_NAME. For example:

  • local-repo_mgit_push - uses local mgit command for local-repo
  • custom-repo_mgit_push - uses custom mgit command for custom-repo

As MCP Server

The server communicates with MCP clients via stdin/stdout after startup:

{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-06-18"}}

Available Tools

  1. mgit_push: Execute mgit push command for the repository configured via REPO_NAME environment variable

    {
      "jsonrpc": "2.0",
      "id": 2,
      "method": "tools/call",
      "params": {
        "name": "mgit_push",
        "arguments": {
          "message": "Update project files"
        }
      }
    }
    
  2. get_operation_logs: Get operation logs

    {
      "jsonrpc": "2.0",
      "id": 3,
      "method": "tools/call",
      "params": {
        "name": "get_operation_logs",
        "arguments": {
          "limit": 50,
          "offset": 0
        }
      }
    }
    

Logging

General Logs

Log file location: ./.setting/mcp-mgit.log (or ./.setting.<REPO_NAME>/mcp-mgit.log if REPO_NAME is set)

Logged content:

  • All requests and responses
  • MGit operation records
  • Error messages
  • Server status changes

Error Handling

  • Individual request errors don't affect the entire server
  • Process exceptions are automatically restarted (managed mode)
  • Detailed error messages in logs

Environment Variables

Variable Default Description
REPO_NAME Required repository name for push operations. Use mgit list (or ${MGIT_CMD} list) to view available repository names. Example: export REPO_NAME="my-repo"
MGIT_CMD mgit Optional mgit command to execute (can be full path)
LANGUAGE en Optional language setting for commit messages. Supported values: en (English), zh or zh-CN (Simplified Chinese), zh-TW (Traditional Chinese). The tool will prompt users to provide commit messages in the configured language.
CHECK_PUSH_HISTORY true Optional flag to enable/disable push history check before pushing. Set to false to skip the history check requirement. When true (default), you must call get_push_history tool before using mgit_push. When false, you can push directly without checking history. Note: If you encounter the error Encountered error in step execution: error executing cascade step: CORTEX_STEP_TYPE_MCP_TOOL: calling "tools/call": EOF, please set CHECK_PUSH_HISTORY="false" to disable push history check.
PROJECT_NAME Optional project branding for tool descriptions
MCP_LOG_DIR ./.setting (or ./.setting.<REPO_NAME> if REPO_NAME is set) Log directory
MCP_LOG_FILE mcp-mgit.log Log filename

Development

Project Structure

mcp-server-mgit/
├── src/
│   └── server-final.js    # Main server file
├── bin/
│   └── cli.js              # CLI entry point
├── start-server.js         # Managed startup script
├── package.json
└── README.md

Testing

npm test

Quick Start

1. Install Package

npm install -g @liangshanli/mcp-server-mgit

2. Configure Environment Variables

# Required: Repository name
export REPO_NAME="my-repo"

# Optional: MGit command (default: mgit)
export MGIT_CMD="mgit"

# Optional: Language setting (default: en)
export LANGUAGE="en"

# Optional: Enable/disable push history check (default: true)
# Set to false to skip history check requirement
export CHECK_PUSH_HISTORY="true"

# Optional: Project branding
export PROJECT_NAME="MyProject"

3. Run Server

mcp-server-mgit

Usage Example

Using the mgit_push tool

The mgit_push tool executes the command: ${MGIT_CMD} push ${REPO_NAME} "<message>"

Note: The repository name is configured via the REPO_NAME environment variable (required). Use mgit list (or ${MGIT_CMD} list) to view available repository names.

Parameters:

  • message (required): The commit message for the push operation

Example:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "mgit_push",
    "arguments": {
      "message": "Update documentation"
    }
  }
}

If REPO_NAME="my-project" and MGIT_CMD="mgit", this will execute: mgit push my-project "Update documentation"

Troubleshooting

Error: Encountered error in step execution: error executing cascade step: CORTEX_STEP_TYPE_MCP_TOOL: calling "tools/call": EOF

If you encounter this error when trying to push code, it may be caused by the push history check feature. To resolve this issue, disable the push history check by setting the environment variable:

export CHECK_PUSH_HISTORY="false"

After setting this variable, restart the MCP server and try pushing again. This will allow you to push directly without checking push history first.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选