Get the FREE Ultimate OpenClaw Setup Guide →

gh

GitHub context server for AI models. Fetch files, structure, filter, and more.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio shanksxz-gh-mcp-server node dist/server.js \
  --env GITHUB_TOKEN="Optional: GitHub personal access token to increase API rate limits"

How to use

This MCP server enables AI models to access GitHub repository contents as context by providing tools to fetch repository-wide contents, specific file contents, and repository structures. The available tools let you fetch an entire repository's files (with filtering by extensions, exclusions, and a cap on the number of files), retrieve the content of a single file, and obtain a navigable structure listing of a repository. To use it, run the server locally or in your environment, ensure any required authentication token is available via GITHUB_TOKEN to increase API rate limits, and then interact with the MCP protocol to invoke get-repo-context, get-file-content, or get-repo-structure as needed for your AI workflow.

How to install

Prerequisites:

  • Git
  • Node.js (and npm) installed on your system
  • Access to the internet to fetch dependencies

Installation steps:

  1. Clone the repository: git clone https://github.com/shanksxz/github-mcp.git
  2. Navigate into the project directory: cd github-mcp
  3. Install dependencies: npm install
  4. Build the project (produces the server artifact): npm run build
  5. Run the MCP server (example):

    ensure you have a valid GitHub token if needed

    export GITHUB_TOKEN=your_github_token_if_available node dist/server.js

Notes:

  • The server communicates via the MCP protocol over stdin/stdout.
  • Public repositories work without authentication, but authenticated requests help with rate limits.

Additional notes

Environment variable tips:

  • GITHUB_TOKEN: Set this to a GitHub Personal Access Token if you plan to access many private or rate-limited resources. Without a token, GitHub's unauthenticated rate limit applies.

Usage tips:

  • Use get-repo-context to pull a curated set of files from a repository, applying maxFiles, fileExtensions, and excludePaths to tailor the content.
  • Use get-file-content for precise file retrieval without pulling the entire repository.
  • Use get-repo-structure to understand the repository layout before selecting files for context.

Common issues:

  • If the MCP server fails to respond, ensure the built artifact exists at dist/server.js and that the server process has permissions to read environment variables.
  • If rate limits are hit, confirm GITHUB_TOKEN is valid and has appropriate scopes.

Related MCP Servers

Sponsor this space

Reach thousands of developers