Skip to main content
Glama
MikeyBeez

MCP Git Server

by MikeyBeez

MCP Git Server

A Model Context Protocol (MCP) server that provides Git version control operations for Claude.

Features

  • ๐Ÿ“Š Repository Status: Check git status and working tree state

  • ๐Ÿ” View Changes: Show diffs for staged and unstaged changes

  • โž• Stage Files: Add files to the staging area

  • ๐Ÿ’พ Commit Changes: Create commits with messages

  • ๐ŸŒฟ Branch Operations: List, create, switch, and delete branches

  • ๐Ÿ“œ View History: Show commit logs

  • โฌ†๏ธ Push Changes: Push commits to remote repositories

  • โฌ‡๏ธ Pull Changes: Pull updates from remote repositories

  • ๐Ÿ“ฆ Clone Repositories: Clone remote repositories

  • ๐Ÿš€ Initialize Repos: Create new git repositories

Installation

  1. Prerequisites:

    • Node.js 18+ installed

    • Git installed and configured

  2. Install the MCP server:

    cd /Users/bard/Code/mcp-git npm install
  3. Add to Claude Desktop config: Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

    { "mcpServers": { "git": { "command": "node", "args": ["/Users/bard/Code/mcp-git/src/index.js"] } } }
  4. Restart Claude Desktop

Usage

Check Repository Status

git_status({ path: "/path/to/repo" }) git_status({ short: true }) // Short format

View Changes

git_diff() // Unstaged changes git_diff({ staged: true }) // Staged changes git_diff({ file: "README.md" }) // Specific file

Stage Files

git_add({ files: ["README.md", "src/index.js"] }) git_add({ files: ["."] }) // Stage all changes

Commit Changes

git_commit({ message: "Add new feature" })

Branch Operations

git_branch() // List branches git_branch({ action: "create", name: "feature/new-feature" }) git_branch({ action: "switch", name: "main" }) git_branch({ action: "delete", name: "old-branch" })

View Commit History

git_log() // Last 10 commits, one-line format git_log({ limit: 20, oneline: false }) // Detailed format

Push and Pull

git_push() // Push current branch to origin git_push({ branch: "main", force: true }) // Force push specific branch git_pull() // Pull current branch from origin git_pull({ remote: "upstream", branch: "main" })

Clone Repository

git_clone({ url: "https://github.com/user/repo.git" }) git_clone({ url: "git@github.com:user/repo.git", path: "my-repo" })

Initialize Repository

git_init({ path: "/path/to/new/repo" }) git_init({ bare: true }) // Create bare repository

Tool Reference

Tool

Description

Required Args

git_status

Show repository status

None

git_diff

Show changes

None

git_add

Stage files

files

git_commit

Create commit

message

git_branch

Manage branches

None

git_log

Show commit history

None

git_push

Push to remote

None

git_pull

Pull from remote

None

git_clone

Clone repository

url

git_init

Initialize repository

None

Error Handling

The server provides detailed error messages for common issues:

  • Repository not found

  • Uncommitted changes

  • Merge conflicts

  • Authentication failures

  • Network issues

Development

Testing the server:

# Run directly node src/index.js # Test with sample commands echo '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}' | node src/index.js

Common Issues

  1. "Not a git repository": Ensure you're in a git repository or provide the path parameter

  2. Authentication errors: Configure git credentials or SSH keys

  3. Push/pull failures: Check network connection and remote repository access

License

MIT

-
security - not tested
F
license - not found
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MikeyBeez/mcp-git'

If you have feedback or need assistance with the MCP directory API, please join our Discord server