mcp git repo browser

Local 2025-08-31 23:20:54 0

A Node.js server that allows browsing Git repositories through MCP, providing tools to view directory structures and read important files from repositories.


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

Configuration

Add this to your MCP settings configuration file:

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

Features

The server provides two main tools:

  1. git_directory_structure: Returns a tree-like representation of a repository's directory structure
  2. Input: Repository URL
  3. Output: ASCII tree representation of the repository structure

  4. git_read_important_files: Reads and returns the contents of specified files in a repository

  5. Input: Repository URL and list of file paths
  6. Output: Dictionary mapping file paths to their contents

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

Requirements

  • Node.js 14.x or higher
  • Git installed on the system

Installation

git clone <repository-url>
cd mcp-git-repo-browser
npm install

Usage

Start the server:

node src/index.js

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

License

MIT License - see the LICENSE file for details.

[
  {
    "description": "Clone a Git repository and return its directory structure in a tree format.",
    "inputSchema": {
      "properties": {
        "repo_url": {
          "description": "The URL of the Git repository",
          "type": "string"
        }
      },
      "required": [
        "repo_url"
      ],
      "type": "object"
    },
    "name": "git_directory_structure"
  },
  {
    "description": "Read the contents of specified files in a given git repository.",
    "inputSchema": {
      "properties": {
        "file_paths": {
          "description": "List of file paths to read (relative to repository root)",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "repo_url": {
          "description": "The URL of the Git repository",
          "type": "string"
        }
      },
      "required": [
        "repo_url",
        "file_paths"
      ],
      "type": "object"
    },
    "name": "git_read_important_files"
  }
]