GitHub Repository Browser MCP server

Integrates with the GitHub API to provide file browsing, content retrieval, and directory navigation capabilities for analyzing and accessing repository contents.
Back to servers
Setup instructions
Provider
LogLM
Release date
Dec 06, 2024
Language
TypeScript
Stats
5 stars

This MCP server provides access to GitHub repository contents, enabling AI assistants to browse and read files from specified repositories. It allows for navigation through directories and accessing file contents through a standardized protocol.

Installation & Setup

Prerequisites

  • Node.js environment
  • GitHub Personal Access Token
  • Access to Claude Desktop configuration

Environment Configuration

The server requires these environment variables:

GITHUB_PERSONAL_ACCESS_TOKEN=your_github_token
GITHUB_OWNER=repository_owner
GITHUB_REPO=repository_name
GITHUB_BRANCH=branch_name  # Optional

Claude Desktop Integration

To use with Claude Desktop, modify the configuration file:

For MacOS:

~/Library/Application Support/Claude/claude_desktop_config.json

For Windows:

%APPDATA%/Claude/claude_desktop_config.json

Add the server configuration:

{
  "mcpServers": {
    "mcp-server-github-repo": {
      "command": "/path/to/mcp-server-github-repo/build/index.js"
    }
  }
}

Usage

Resource Access

The server provides access to GitHub repository contents through these URI patterns:

  • Base URL format: https://api.github.com/repos/{owner}/{repo}/contents/{path}
  • Files are served with text/plain MIME type
  • Directories are served with application/x-directory MIME type

Available Operations

The server implements these MCP endpoints:

  1. ListResources - Browse directories in the repository
  2. ReadResource - Get contents of specific files

Authentication

The server uses your GitHub Personal Access Token for authentication. Ensure your token has appropriate permissions to access the repository contents you need.

Troubleshooting

Common Issues

  • Authentication Errors: Verify your GitHub token has correct permissions
  • Access Denied: Check that you have access to the specified repository
  • Path Not Found: Ensure the file path exists in the repository
  • Branch Issues: Specify the correct branch name if not using the default branch

Debugging

Since MCP servers communicate over stdio, you can use the MCP Inspector for debugging:

npm run inspector

This provides a browser-based interface for debugging communication with the server.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "mcp-server-github-repo" '{"command":"/path/to/mcp-server-github-repo/build/index.js"}'

See the official Claude Code MCP documentation for more details.

For 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 > Tools & Integrations and click "New MCP Server".

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

{
    "mcpServers": {
        "mcp-server-github-repo": {
            "command": "/path/to/mcp-server-github-repo/build/index.js"
        }
    }
}

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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "mcp-server-github-repo": {
            "command": "/path/to/mcp-server-github-repo/build/index.js"
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

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