#!/usr/bin/env bash # Add GitHub's official MCP server to Claude Code as a read-only remote server. # Run in your terminal (not inside a Claude Code session), from your project root. # # Before running: create a GitHub token and export it under this exact name, # export GITHUB_MCP_PAT=... # The single quotes below matter. They keep ${GITHUB_MCP_PAT} as text, so # Claude Code stores the reference and reads the variable when it connects. # The token itself is never written into the config file. set -euo pipefail claude mcp add-json github '{ "type": "http", "url": "https://api.githubcopilot.com/mcp/", "headers": { "Authorization": "Bearer ${GITHUB_MCP_PAT}", "X-MCP-Toolsets": "context,repos,issues,pull_requests", "X-MCP-Readonly": "true" } }' claude mcp get github