Integrating GitHub MCP with Claude Code: Complete Setup and Usage Guide

Claude Code integrates with GitHub via the Model Context Protocol (MCP) by launching a local stdio server that exposes GitHub tools through slash commands like /mcp__github__list_prs, enabling direct repository interaction without leaving the terminal.

The luongnv89/claude-howto repository provides working configurations and detailed documentation for connecting Claude Code to GitHub's API through MCP. This integration allows developers to query pull requests, manage issues, and automate workflows using natural language commands that translate directly to GitHub API calls.

How the GitHub MCP Integration Works

MCP Server Definition

The integration begins with a JSON configuration file that declares how Claude should launch and communicate with the GitHub MCP server. In 05-mcp/github-mcp.json, the configuration specifies the command (npx), arguments (@modelcontextprotocol/server-github), and the environment variable (GITHUB_TOKEN) required for authentication【/cache/repos/github.com/luongnv89/claude-howto/main/05-mcp/github-mcp.json】. This file follows the Model Context Protocol schema, defining the server metadata and transport settings.

Transport and Authentication

Claude Code uses stdio transport to communicate with the MCP server. When Claude starts, it spawns the server process locally using npx @modelcontextprotocol/server-github, passing the GitHub personal access token via the GITHUB_TOKEN environment variable. The server runs as a child process, listening for JSON-RPC requests on standard input and returning responses via standard output.

Tool Discovery and Naming

Upon connection, the GitHub MCP server advertises its available tool schema to Claude, including operations like list_prs, get_issue, create_issue, and add_comment. Claude dynamically adds these tools to its runtime environment, making them accessible through a strict naming convention: mcp__github__<tool_name>. This namespace prevents collisions with built-in commands and clearly indicates the external service being invoked.

Execution Flow

When you type a slash command such as /mcp__github__list_prs, Claude parses the input, maps it to the corresponding tool schema, and constructs a JSON-RPC request. The request travels through the stdio channel to the MCP server, which executes the actual GitHub REST API call using the pre-configured token. The server returns structured data, which Claude formats and injects into the conversation context.

Configuring GitHub MCP in Claude Code

Install the GitHub MCP Server

First, install the official GitHub MCP server package globally using npm:

npm install -g @modelcontextprotocol/server-github

This makes the server-github command available for Claude to spawn via npx.

Register the Server with Claude

Add the GitHub MCP server to your Claude Code configuration using the CLI:

claude mcp add --transport stdio github -- npx @modelcontextprotocol/server-github

This command registers the server under the name "github" and configures Claude to launch it with stdio transport. Ensure your GITHUB_TOKEN environment variable is exported in your shell before starting Claude Code, as the server reads this token to authenticate with the GitHub API.

Practical Usage Examples

Listing Pull Requests

To fetch recently merged pull requests, use the list_prs tool with filter parameters:

/mcp__github__list_prs completed:true last:7days

Claude forwards this request to the MCP server, which queries the GitHub Search API and returns a formatted list of pull requests merged within the last week.

Creating Issues

Create new issues directly from chat using the create_issue tool:

/mcp__github__create_issue "Bug in login flow" "When the user enters an invalid password the UI freezes."

Claude constructs the API payload, the MCP server sends a POST request to /repos/:owner/:repo/issues, and returns the newly created issue URL for confirmation.

Multi-Step Workflows

Combine multiple tools for complex workflows. First, fetch an issue to review its details:

/mcp__github__get_issue 42

After reviewing the output, add a comment without switching contexts:

/mcp__github__add_comment 42 "I've reproduced this locally; will investigate."

Both calls utilize the same server process instance, maintaining the authentication state in memory and eliminating repeated token validation overhead.

Repository Structure and Key Files

The luongnv89/claude-howto repository organizes MCP resources in the 05-mcp/ directory, with supplementary documentation explaining integration patterns:

  • 05-mcp/github-mcp.json – Minimal server definition containing command, args, and env configuration that pulls GITHUB_TOKEN from the shell environment【/cache/repos/github.com/luongnv89/claude-howto/main/05-mcp/github-mcp.json】.

  • 05-mcp/README.md – Comprehensive guide covering MCP architecture diagrams, transport layer options, OAuth token handling, and the complete inventory of available GitHub tools【/cache/repos/github.com/luongnv89/claude-howto/main/05-mcp/README.md】.

  • 01-slash-commands/README.md – Reference documentation explaining how MCP prompts translate into slash commands (/mcp__github__<tool>), including permission patterns and security considerations.

  • README.md (project root) – High-level example workflows demonstrating how to combine slash commands, sub-agents, memory systems, and the GitHub MCP for automated code review pipelines.

Summary

  • MCP Configuration: Define the GitHub server in 05-mcp/github-mcp.json with npx @modelcontextprotocol/server-github as the entry point and GITHUB_TOKEN for authentication.
  • Transport Layer: Claude uses stdio transport to spawn the server locally and communicate via JSON-RPC over standard input/output streams.
  • Tool Invocation: Access GitHub functionality through the /mcp__github__<tool> slash command convention, where tools like list_prs, get_issue, and create_issue map directly to GitHub API endpoints.
  • Repository Resources: The luongnv89/claude-howto repository provides working configurations, architecture diagrams, and multi-step workflow examples for production-ready integration.

Frequently Asked Questions

What is the Model Context Protocol (MCP)?

The Model Context Protocol is an open standard that enables AI agents to connect with external data sources and services through a standardized interface. In the context of Claude Code, MCP allows the agent to spawn local server processes that expose tools (functions) Claude can call to interact with APIs like GitHub, maintaining stateful connections over stdio or HTTP transports.

How do I authenticate the GitHub MCP server?

Authentication requires a GitHub personal access token exported as GITHUB_TOKEN in your shell environment. The 05-mcp/github-mcp.json configuration file specifies that Claude should pass this environment variable to the MCP server process on startup. The server uses this token for all subsequent GitHub API calls, ensuring secure, token-based authentication without storing credentials in chat history.

What GitHub tools are available through MCP?

The GitHub MCP server exposes tools including list_prs for searching pull requests, get_issue for fetching issue details, create_issue for reporting bugs, and add_comment for responding to existing issues. According to the 05-mcp/README.md, the server advertises its full tool schema on connection, allowing Claude to discover available operations dynamically without manual configuration updates.

Where are the MCP configuration files stored?

Configuration files reside in the 05-mcp/ directory of the luongnv89/claude-howto repository. The primary file, github-mcp.json, contains the minimal server definition, while README.md in the same directory provides architectural diagrams, transport options, and usage examples. You can copy these files to your local .mcp.json or use the claude mcp add command to register them globally.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →