Skip to main content
Glama
Git Repo Browser MCP

Git Repo Browser MCP

by bsreeram08

MCP Git Repo Browser (Node.js)

A Node.js implementation of a Git repository browser using the Model Context Protocol (MCP).

GitHub Repository npm package

Installation

npm install -g git-commands-mcp

Manual Installation

git clone https://github.com/bsreeram08/git-commands-mcp.git
cd git-commands-mcp
npm install

Related MCP server: MCP Git Repo Browser

Configuration

Add this to your MCP settings configuration file:

{
  "mcpServers": {
    "git-commands-mcp": {
      "command": "git-commands-mcp"
    }
  }
}

For manual installation, use:

{
  "mcpServers": {
    "git-commands-mcp": {
      "command": "node",
      "args": ["/path/to/git-commands-mcp/src/index.js"]
    }
  }
}

Features

The server provides the following tools:

Basic Repository Operations

  1. git_directory_structure: Returns a tree-like representation of a repository's directory structure

    • Input: Repository URL

    • Output: ASCII tree representation of the repository structure

  2. git_read_files: Reads and returns the contents of specified files in a repository

    • Input: Repository URL and list of file paths

    • Output: Dictionary mapping file paths to their contents

  3. git_search_code: Searches for patterns in repository code

    • Input: Repository URL, search pattern, optional file patterns, case sensitivity, and context lines

    • Output: JSON with search results including matching lines and context

Branch Operations

  1. git_branch_diff: Compare two branches and show files changed between them

    • Input: Repository URL, source branch, target branch, and optional show_patch flag

    • Output: JSON with commit count and diff summary

Commit Operations

  1. git_commit_history: Get commit history for a branch with optional filtering

    • Input: Repository URL, branch name, max count, author filter, since date, until date, and message grep

    • Output: JSON with commit details

  2. git_commits_details: Get detailed information about commits including full messages and diffs

    • Input: Repository URL, branch name, max count, include_diff flag, author filter, since date, until date, and message grep

    • Output: JSON with detailed commit information

  3. git_local_changes: Get uncommitted changes in the working directory

    • Input: Local repository path

    • Output: JSON with status information and diffs

Project Structure

git-commands-mcp/
├── src/
│   ├── index.js         # Entry point
│   ├── server.js        # Main server implementation
│   ├── handlers/        # Tool handlers
│   │   └── index.js     # Tool implementation functions
│   └── utils/           # Utility functions
│       └── git.js       # Git-related helper functions
├── package.json
└── readme.md

Implementation Details

  • Uses Node.js native modules (crypto, path, os) for core functionality

  • Leverages fs-extra for enhanced file operations

  • Uses simple-git for Git repository operations

  • Implements clean error handling and resource cleanup

  • Creates deterministic temporary directories based on repository URL hashes

  • Reuses cloned repositories when possible for efficiency

  • Modular code structure for better maintainability

Requirements

  • Node.js 14.x or higher

  • Git installed on the system

Usage

If installed globally via npm:

git-commands-mcp

If installed manually:

node src/index.js

The server runs on stdio, making it compatible with MCP clients.

CI/CD

This project uses GitHub Actions for continuous integration and deployment:

Automatic NPM Publishing

The repository is configured with a GitHub Actions workflow that automatically publishes the package to npm when changes are pushed to the master branch.

Setting up NPM_AUTOMATION_TOKEN

To enable automatic publishing, you need to add an npm Automation token as a GitHub secret (this works even with accounts that have 2FA enabled):

  1. Generate an npm Automation token:

    • Log in to your npm account on npmjs.com

    • Go to your profile settings

    • Select "Access Tokens"

    • Click "Generate New Token"

    • Select "Automation" token type

    • Set the appropriate permissions (needs "Read and write" for packages)

    • Copy the generated token

  2. Add the token to your GitHub repository:

    • Go to your GitHub repository

    • Navigate to "Settings" > "Secrets and variables" > "Actions"

    • Click "New repository secret"

    • Name: NPM_AUTOMATION_TOKEN

    • Value: Paste your npm Automation token

    • Click "Add secret"

Once configured, any push to the master branch will trigger the workflow to publish the package to npm.

License

MIT License - see the LICENSE file for details.

Available Tools

27 tools
git_archiveC

Create a git archive (zip or tar).

Inputs: repo_path (required), output_path (required), format, prefix, +1 more.

git_attributesC

Manage git attributes for files.

Inputs: repo_path (required), action (required), pattern, attribute.

git_blameC

Get blame information for a file.

Inputs: repo_path (required), file_path (required), rev.

git_branch_diffC

Compare two branches and show files changed between them.

Inputs: repo_url (required), source_branch (required), target_branch (required), show_patch.

git_checkout_branchC

Create and/or checkout a branch.

Inputs: repo_path (required), branch_name (required), start_point, create.

git_cleanC

Perform git clean operations.

Inputs: repo_path (required), directories, force, dry_run.

git_commitC

Create a commit with the specified message.

Inputs: repo_path (required), message (required).

git_commit_historyB

Get commit history for a branch with optional filtering.

Inputs: repo_url (required), branch, max_count, author, +3 more.

git_commits_detailsC

Get detailed information about commits including full messages and diffs.

Inputs: repo_url (required), branch, max_count, include_diff, +4 more.

git_configC

Configure git settings for the repository.

Inputs: repo_path (required), key (required), value (required), scope.

git_create_tagC

Create a tag.

Inputs: repo_path (required), tag_name (required), message, annotated.

git_delete_branchC

Delete a branch from the repository.

Inputs: repo_path (required), branch_name (required), force.

git_directory_structureC

Clone a Git repository and return its directory structure in a tree format.

Inputs: repo_url (required).

git_hooksC

Manage git hooks in the repository.

Inputs: repo_path (required), action (required), hook_name, script.

git_lfsC

Manage Git LFS (Large File Storage).

Inputs: repo_path (required), action (required), patterns.

git_lfs_fetchC

Fetch LFS objects from the remote repository.

Inputs: repo_path (required), dry_run, pointers.

git_local_changesC

Get uncommitted changes in the working directory.

Inputs: repo_path (required).

git_merge_branchC

Merge a source branch into the current or target branch.

Inputs: repo_path (required), source_branch (required), target_branch, no_fast_forward.

git_pullC

Pull changes from a remote repository.

Inputs: repo_path (required), remote, branch, rebase.

git_pushC

Push changes to a remote repository.

Inputs: repo_path (required), remote, branch, force.

git_read_filesC

Read the contents of specified files in a given git repository.

Inputs: repo_url (required), file_paths (required).

git_rebaseC

Rebase the current branch onto another branch or commit.

Inputs: repo_path (required), onto (required), interactive.

git_resetC

Reset repository to specified commit or state.

Inputs: repo_path (required), mode, to.

git_revertC

Revert the current branch to a commit or state.

Inputs: repo_path (required), commit, no_commit.

git_search_codeC

Search for patterns in repository code.

Inputs: repo_url (required), pattern (required), file_patterns, case_sensitive, +1 more.

git_stashC

Create or apply a stash.

Inputs: repo_path (required), action, message, index.

git_trackC

Track (stage) specific files or all files.

Inputs: repo_path (required), files.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 27 tools

    Disambiguation4/5

    Most tools have distinct purposes targeting specific Git operations, but some overlap exists. For example, git_commit_history and git_commits_details both handle commit information retrieval, and git_clean and git_reset both involve repository state management, which could cause minor confusion. However, descriptions clarify their specific focuses, keeping ambiguity manageable.

    Naming Consistency5/5

    All tool names follow a consistent snake_case pattern with a 'git_' prefix and descriptive verb_noun combinations. Examples include git_checkout_branch, git_merge_branch, and git_search_code. This uniformity makes the tool set predictable and easy to navigate for an agent.

    Tool Count2/5

    With 27 tools, the count is excessive for a Git repository browser. Many tools cover niche or low-level operations that could be consolidated, such as git_lfs and git_lfs_fetch, or git_attributes and git_hooks. This bloated set may overwhelm agents and complicate task selection.

    Completeness5/5

    The tool set provides comprehensive coverage of Git operations, including cloning, branching, committing, merging, searching, and configuration. It supports full CRUD and lifecycle management for repositories, with no obvious gaps. Agents can perform end-to-end workflows without dead ends.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      B
      maintenance
      A Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.
      14
      90,074 PyPI
      91,952
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      A Model Context Protocol server that enables Large Language Models to interact with Git repositories through a robust API, supporting operations like repository initialization, cloning, file staging, committing, and branch management.
      28
      4,360 npm
      245
      Apache 2.0
    • A
      license
      C
      quality
      C
      maintenance
      Node.js server implementing Model Context Protocol for git operations, enabling AI assistants to manage git repositories through natural language commands.
      11
      147 npm
      MIT