GitHub Repository MCP server

Provides a bridge between AI and GitHub repositories, enabling access to repository contents for code analysis and reference during conversations.
Back to servers
Provider
Ryan Chan
Release date
Apr 25, 2025
Language
TypeScript
Package
Stats
228 downloads
3 stars

This MCP server allows you to browse GitHub repositories, navigate through directories, and view file contents directly through AI assistants. It works with various MCP clients including Cursor, Windsurf, and Claude Desktop.

Installation

Prerequisites

Before installing, ensure you have:

  • Node.js 18+
  • npm or yarn

Installing the Server

You can install and run GitHub Repo MCP using several methods:

On macOS

npx github-repo-mcp

On Windows via NPX

cmd /c npx -y github-repo-mcp

On Windows via .cursor/mcp.json

{
  "mcpServers": {
    "github-repo-mcp": {
      "command": "wsl",
      "args": [
        "bash",
        "-c",
        "cmd /c npx -y github-repo-mcp"
      ],
      "enabled": true
    }
  }
}

If Windows PATH is not set correctly

First, find the full path to npx:

which npx

Then use that path in your configuration:

{
  "mcpServers": {
    "github-repo-mcp": {
      "command": "wsl",
      "args": [
        "bash",
        "-c",
        "'/home/[username]/.nvm/versions/node/v20.18.0/bin/npx github-repo-mcp'"
      ],
      "enabled": true
    }
  }
}

Using Smithery (for Claude Desktop)

npx -y @smithery/cli install @Ryan0204/github-repo-mcp --client claude

Wait a few seconds or click the refresh button if the server doesn't register immediately.

Configuration

GitHub Token (Optional but Recommended)

To avoid rate limiting, you can configure a GitHub personal access token:

  1. Create a token at https://github.com/settings/tokens
  2. Add it to your mcp.json configuration:
{
  "mcpServers": {
    "github-repo-mcp": {
      "command": "...",
      "args": [...],
      "env": {
        "GITHUB_TOKEN": "Your_Github_Token"
      },
      "enabled": true
    }
  }
}

Using the Server

The server provides three main tools for interacting with GitHub repositories:

Available Tools

1. getRepoAllDirectories

Lists all files and directories at the root of a GitHub repository.

Parameters:

  • repoUrl: The URL of the GitHub repository (e.g., "https://github.com/owner/repo")

2. getRepoDirectories

Lists contents of a specific directory in a GitHub repository.

Parameters:

  • repoUrl: The URL of the GitHub repository
  • path: The directory path to fetch (e.g., "src")

3. getRepoFile

Retrieves and displays the content of a specific file from a GitHub repository.

Parameters:

  • repoUrl: The URL of the GitHub repository
  • path: The file path to fetch (e.g., "src/index.js")

Example Usage Scenarios

  1. Browsing a repository root:
    Ask your AI assistant to "Show me the contents of the repository at https://github.com/Ryan0204/github-repo-mcp"

  2. Exploring a specific directory:
    Ask "What files are in the src directory of https://github.com/Ryan0204/github-repo-mcp?"

  3. Viewing a file:
    Ask "Show me the README.md file from https://github.com/Ryan0204/github-repo-mcp"

Troubleshooting

Common issues and solutions:

  • Rate limit exceeded: Configure a GitHub token as described above
  • Command not found: Verify the package is installed correctly
  • Connection errors: Check your internet connection and GitHub API status

Limitations

  • Without authentication, GitHub API limits you to 60 requests per hour
  • Only public repositories are accessible unless a token with appropriate permissions is provided
  • Binary files cannot be displayed
  • GitHub API has limitations on the size of files that can be retrieved

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later