Provides tools for checking git repository status and viewing recent commit history, enabling AI agents to understand the current state of version-controlled projects
MCP Git Status Server
A Model Context Protocol (MCP) server that provides git status and log functionality. This server allows MCP clients (like Claude Desktop, Cline, etc.) to check git repository status and view recent commit history.
Features
- Git Status Tool: Get the current status of a git repository
- Git Log Tool: View recent commit history
- Error Handling: Graceful error handling for non-git directories and other issues
- Directory Support: Optionally specify a directory path to check
Installation
- Clone or download this repository
- Install dependencies:
- Build the project:
- Test the server:
Usage
Running the Server
The server communicates via stdio (standard input/output) as per MCP protocol:
Connecting to MCP Clients
Cursor IDE
Project-specific configuration (recommended for this project):
Cursor is already configured for this project via .cursor/mcp.json
.
Global configuration (to use in all projects): The server is also configured globally. After restarting Cursor, you can ask questions like:
- "What's the git status of this repository?"
- "Show me the last 5 commits"
- "Check if there are any uncommitted changes"
Cursor will automatically use the git-status tools to answer your questions.
Manual configuration (if needed):
Create ~/.cursor/mcp.json
with:
Note: Replace the path with the actual path to your compiled server.
Claude Desktop
Add this server to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Note: Replace /path/to/your/mcp-git-status-server
with the actual path to your project directory.
A sample configuration file is included as claude-desktop-config.json
for reference.
Other MCP Clients
For other MCP clients, configure them to run this server as a subprocess with stdio transport.
Available Tools
git-status
Get the current git status of a repository.
Parameters:
directory
(optional): Directory path to check. Defaults to current directory.
Example usage in MCP client: "Check the git status of my project"
git-log
View recent git commit history.
Parameters:
directory
(optional): Directory path to check. Defaults to current directory.count
(optional): Number of recent commits to show. Defaults to 10.
Example usage in MCP client: "Show me the last 5 git commits"
Example Output
Git Status (clean repository)
Git Status (with changes)
Git Log
Error Handling
The server gracefully handles common error scenarios:
- Not a git repository: Provides clear error message
- Git not installed: Indicates git is not available
- Permission issues: Reports access problems
- Invalid directory: Handles non-existent paths
Development
Scripts
npm run build
: Compile TypeScript to JavaScriptnpm run dev
: Run in development mode with tsxnpm start
: Run the compiled servernpm test
: Build and validate the server functionality
Project Structure
Validation
The project includes a comprehensive validation script (validate-mcp.js
) that tests:
- MCP protocol initialization
- Tool discovery (tools/list)
- Git status functionality
- Git log functionality
- Error handling for invalid tools
Run validation with:
The validation script will:
- Build the project
- Start the MCP server
- Test all functionality
- Report results
- Clean up automatically
Requirements
- Node.js 18.x or higher
- Git installed and available in PATH
- TypeScript (for development)
License
MIT License
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
Troubleshooting
Server not starting:
- Check Node.js version (requires 18.x+)
- Ensure all dependencies are installed:
npm install
- Build the project:
npm run build
Git commands failing:
- Verify git is installed:
git --version
- Ensure you're in a git repository
- Check file permissions
MCP client not connecting:
- Verify the path to the server executable in client configuration
- Check that the server process can be started manually
- Review client logs for connection errors
local-only server
The server can only run on the client's local machine because it depends on local resources.
Tools
Enables checking git repository status and viewing recent commit history through natural language queries. Supports error handling for non-git directories and allows specifying custom directory paths.
Related MCP Servers
- -securityFlicense-qualityEnables interaction with GitHub through the GitHub API, supporting file operations, repository management, advanced search, and issue tracking with comprehensive error handling and automatic branch creation.Last updated -6951
- AsecurityAlicenseAqualityA Node.js implementation that enables browsing Git repositories through the Model Context Protocol, providing features like displaying directory structures, reading files, searching code, comparing branches, and viewing commit history.Last updated -2720MIT License
- AsecurityFlicenseAqualityEnables comprehensive GitHub operations through natural language including file management, repository administration, issue tracking, and advanced code searching.Last updated -4711
- -securityAlicense-qualityEnables interaction with GitHub repositories through the GitHub API, allowing file operations, repository management, issue tracking, and code search through natural language commands.Last updated -62MIT License