MCP Pre-commit Manager
Checks whether a directory is a Git repository and initializes Git repositories automatically when needed.
Detects existing pre-commit hook installations, generates project-type-specific .pre-commit-config.yaml files, and installs pre-commit hooks.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Pre-commit Manager Set up git and pre-commit hooks for my project"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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-commitinstalled (for hook installation)For macOS:
brew install pre-commitFor Python users:
pip install pre-commit
Installation
Via npm (Recommended)
npm install -g mcp-pre-commitFrom Source
Clone or download this repository
Install dependencies:
npm installBuild the TypeScript code:
npm run buildUsage
Running the Server
Start the MCP server:
npm startOr run in development mode with auto-rebuild:
npm run watchConfiguring 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-project2. 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, ortypescript)
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-projectPre-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 fileBuild Commands
npm run build- Compile TypeScript to JavaScriptnpm run dev- Build and run oncenpm run watch- Watch mode for development
How It Works
Project Type Detection: Scans for common configuration files:
Python:
setup.py,pyproject.toml,requirements.txt, etc.TypeScript:
tsconfig.jsonJavaScript:
package.json
Git Repository Check: Uses
git rev-parse --is-inside-work-treeto verify git statusPre-commit Hook Detection: Checks for:
.pre-commit-config.yamlconfiguration fileActual hook file in
.git/hooks/pre-commit
Automatic Setup:
Initializes git if needed (
git init)Creates appropriate
.pre-commit-config.yamlbased on project typeRuns
pre-commit installto activate hooks
Error Handling
The server provides clear error messages for common issues:
Missing
pre-commitinstallationPermission errors
Invalid repository paths
Undetectable project types (use
force_project_typeparameter)
Badges
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 toolscheck_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
Scored across 2 tools
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.
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.
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.
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
Related MCP Connectors
Git-backed platform for skills, tools, and context for AI agents
Plain-English git for agents: 22 tools to branch, commit, push and tag. Free tier.
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Operate GitHub from your AI assistant: repos, PRs, issues, Actions. Previews and read-only mode.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables Git repository interaction and automation via LLMs, providing tools to read, search, and manipulate Git repositories.1572 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables 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.1MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to inspect Git repositories for changes across committed, staged, unstaged, and untracked scopes, and run allowlisted validation commands with structured results.-
- AlicenseNot gradedqualityDmaintenanceEnables 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