Skip to main content
Glama
MCP Pre-commit Manager

MCP Pre-commit Manager

by ars-system

MCP Pre-commit Manager

A Model Context Protocol (MCP) tool server that helps LLM agents manage git repositories and pre-commit hooks automatically.

Features

This MCP server provides tools to:

  • πŸ” Detect project type (Python, JavaScript, or TypeScript)

  • πŸ“¦ Check if a directory is a git repository

  • πŸͺ Verify if pre-commit hooks are installed

  • πŸš€ Initialize git repositories automatically

  • βš™οΈ Set up pre-commit hooks based on project type

Related MCP server: git-mcp

Prerequisites

  • Node.js 18 or higher

  • Git installed on your system

  • pre-commit installed (for hook installation)

    • For macOS: brew install pre-commit

    • For Python users: pip install pre-commit

Installation

npm install -g mcp-pre-commit

From Source

  1. Clone or download this repository

  2. Install dependencies:

npm install
  1. Build the TypeScript code:

npm run build

Usage

Running the Server

Start the MCP server:

npm start

Or run in development mode with auto-rebuild:

npm run watch

Configuring with MCP Clients

Add this server to your MCP client configuration.

For Global npm Installation:

macOS/Linux: ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "pre-commit-manager": {
      "command": "mcp-pre-commit"
    }
  }
}

Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "pre-commit-manager": {
      "command": "mcp-pre-commit"
    }
  }
}

For Source Installation:

{
  "mcpServers": {
    "pre-commit-manager": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-pre-commit/dist/index.js"]
    }
  }
}

For Other MCP Clients:

Refer to your MCP client's documentation for configuration instructions. The command is mcp-pre-commit (for npm installation) or node /path/to/dist/index.js (for source installation).

Available Tools

1. check_project_setup

Analyzes a repository and returns its setup status.

Parameters:

  • repo_path (optional): Path to the repository (defaults to current directory)

Returns:

{
  "repository_path": "/path/to/repo",
  "project_type": "python",
  "is_git_repository": true,
  "has_precommit_hooks": false,
  "status": "⚠️ Git repository exists but pre-commit hooks are not installed"
}

Example usage in LLM conversation:

Check the project setup for /Users/john/my-project

2. setup_git_and_precommit

Initializes git repository and sets up pre-commit hooks based on detected project type.

Parameters:

  • repo_path (optional): Path to the repository (defaults to current directory)

  • force_project_type (optional): Force specific project type (python, javascript, or typescript)

Returns: Status messages about git initialization and pre-commit hook setup.

Example usage in LLM conversation:

Set up git and pre-commit hooks for /Users/john/my-project

Pre-commit Hook Configurations

Python Projects

  • Trailing whitespace removal

  • End-of-file fixer

  • YAML, JSON, TOML checkers

  • Black code formatter

  • Flake8 linter

  • isort import sorter

JavaScript/TypeScript Projects

  • Trailing whitespace removal

  • End-of-file fixer

  • YAML, JSON checkers

  • ESLint with TypeScript support

  • Prettier code formatter

Unknown/Other Projects

  • Basic pre-commit hooks (whitespace, file fixes, YAML/JSON validation)

Development

Project Structure

mcp-pre-commit/
β”œβ”€β”€ src/
β”‚   └── index.ts          # Main server implementation
β”œβ”€β”€ dist/                 # Compiled JavaScript (generated)
β”œβ”€β”€ package.json          # Dependencies and scripts
β”œβ”€β”€ tsconfig.json         # TypeScript configuration
└── README.md            # This file

Build Commands

  • npm run build - Compile TypeScript to JavaScript

  • npm run dev - Build and run once

  • npm run watch - Watch mode for development

How It Works

  1. Project Type Detection: Scans for common configuration files:

    • Python: setup.py, pyproject.toml, requirements.txt, etc.

    • TypeScript: tsconfig.json

    • JavaScript: package.json

  2. Git Repository Check: Uses git rev-parse --is-inside-work-tree to verify git status

  3. Pre-commit Hook Detection: Checks for:

    • .pre-commit-config.yaml configuration file

    • Actual hook file in .git/hooks/pre-commit

  4. Automatic Setup:

    • Initializes git if needed (git init)

    • Creates appropriate .pre-commit-config.yaml based on project type

    • Runs pre-commit install to activate hooks

Error Handling

The server provides clear error messages for common issues:

  • Missing pre-commit installation

  • Permission errors

  • Invalid repository paths

  • Undetectable project types (use force_project_type parameter)

Badges

npm version License: MIT Node.js Version

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details on:

  • Reporting bugs

  • Suggesting enhancements

  • Submitting pull requests

  • Code style guidelines

Feel free to extend this server with additional features:

  • Support for more project types (Go, Rust, etc.)

  • Custom hook configurations

  • Additional git operations

  • Pre-commit hook testing

Changelog

See CHANGELOG.md for a list of changes in each version.

Support

If you encounter any issues or have questions:

  • Open an issue on GitHub Issues

  • Check existing issues for solutions

  • Review the FAQ section

License

MIT - see LICENSE file for details

Available Tools

2 tools
check_project_setupA

Use this tool when the user asks about git or pre-commit status of a repository, or when you need to verify project setup before making changes. This tool performs a comprehensive check of: 1) Project type detection (Python/JavaScript/TypeScript based on config files), 2) Git repository status (initialized, current branch, commits, remotes), 3) Pre-commit hooks installation status (config file and hook scripts). Returns detailed information including recommendations for next steps. Call this tool whenever a user mentions 'check', 'status', 'git', 'pre-commit', or 'setup' in the context of repository configuration.

Inputs: repo_path.

setup_git_and_precommitA

Use this tool to automatically set up git and pre-commit hooks for a project. This tool will: 1) Initialize a git repository if one doesn't exist (runs 'git init'), 2) Detect the project type automatically (Python/JS/TS), 3) Create a .pre-commit-config.yaml file with appropriate hooks for the project type, 4) Install the pre-commit hooks (runs 'pre-commit install'). For Python projects: Sets up pre-commit framework with Black, Flake8, isort, and common hooks. For JS/TS projects: Sets up Husky + lint-staged with ESLint and Prettier. Call this tool when the user wants to 'set up', 'initialize', 'install', or 'configure' git or pre-commit hooks.

Inputs: repo_path, force_project_type.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 2 tools

    Disambiguation4/5

    The two tools have a clear read-vs-write split: check_project_setup inspects state, setup_git_and_precommit mutates it. The only minor overlap is that 'setup' arguably implies a subsequent check, but descriptions make the boundary explicit.

    Naming Consistency4/5

    Both names are snake_case and verb-led (check_..., setup_...), matching a predictable pattern. Minor deviation: 'setup' is a noun used as a verb while 'check' is a clean verb, and one name is quite long, but overall consistent.

    Tool Count3/5

    Two tools is borderline thin for a server framed as a 'pre-commit manager' β€” it covers setup and status but nothing else. Both tools earn their place, but the surface feels minimal for the stated scope.

    Completeness3/5

    Core lifecycle of initialize-and-verify is covered, but there are notable gaps: no way to update/extend an existing .pre-commit-config.yaml without overwriting, no tool to run hooks, and no uninstall/removal operation. Agents can partially work around these by editing files directly.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Enables Git repository interaction and automation via LLMs, providing tools to read, search, and manipulate Git repositories.
      15
      72 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to perform full Git operations including branching, committing, pushing, stashing, rebasing, and more, with safety features and support for advanced workflows like Git Flow and LFS.
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to analyze local Git repositories with commit logs, diffs, blame, statistics, and branch analysis using native git commands without requiring a GitHub API.
      MIT