Run GitHub From Claude Code prompt
Set up GitHub's official MCP server in my Claude Code so you (Claude Code) can run my GitHub
directly - open and merge pull requests, push commits, create branches, and read issues -
without me leaving the terminal to click around the GitHub website. This uses GitHub's free,
hosted MCP server (no Docker, no local install). Work in the order below and change nothing
until STEP 1.
Safety first: check whether it is already configured - run `claude mcp list` and look for a
"github" server pointing at api.githubcopilot.com. If one already exists, tell me, change
nothing, and skip to VERIFY. Never overwrite my existing config. This adds the server at USER
scope so my token stays out of any project file - never write my token into a committed
.mcp.json.
(If a bare `claude ...` command is blocked inside this session, re-run just that command with
CLAUDECODE cleared: `CLAUDECODE= claude ...` on macOS/Linux, or `$env:CLAUDECODE=''; claude ...`
in PowerShell.)
STEP 0 - I need a GitHub personal access token first; do not run anything yet. Tell me to:
1. Open https://github.com/settings/personal-access-tokens/new and create a FINE-GRAINED token.
2. Give it access to the repositories you want me to manage, with Read and Write on "Contents",
"Pull requests", and "Issues" (add more only if I ask).
3. Copy the token (it starts with github_pat_) and paste it back to me here.
Wait for me to paste the token before STEP 1. Treat it as a secret - never print it back in full,
and never write it to a file I might commit.
STEP 1 - Add GitHub's hosted MCP server at USER scope, with my token as the auth header. Replace
YOUR_GITHUB_PAT with the token I gave you and run this exactly:
claude mcp add --transport http github https://api.githubcopilot.com/mcp/ --header "Authorization: Bearer YOUR_GITHUB_PAT" --scope user
If my Claude Code is version 2.1.1 or newer and that command errors, use the newer JSON form
instead (same server, same token):
claude mcp add-json github '{"type":"http","url":"https://api.githubcopilot.com/mcp/","headers":{"Authorization":"Bearer YOUR_GITHUB_PAT"}}' --scope user
That is the whole install - the server is hosted by GitHub, so there is nothing to download and
no API key beyond my token.
STEP 2 - Restart so it loads. MCP servers only load at startup, so tell me to fully quit and
reopen Claude Code now (and approve "github" if it asks). Until I restart, the new tools are not
available to you - so hand this back to me and wait.
VERIFY (after I restart) - prove it works against my real GitHub. Run `claude mcp list` and
confirm "github" shows as connected. Then, using the GitHub MCP tools (NOT the website): list the
open pull requests on one of my repos (ask me which repo if you do not know), and read the details
of one. Tell me what you found. Do not open, merge, or push anything during verify - read only -
unless I ask you to.
Finally, summarize where it stands: whether the github server is connected, that you can now open
and merge pull requests, push commits, and create branches on my behalf from the terminal, and
remind me that the token is stored at user scope (not in any project file) and that I can revoke it
anytime from GitHub settings. Note that "working in parallel with git worktrees" is a local git
feature, separate from this server - the server handles the GitHub side (branches, commits, PRs,
merges).You run Claude Code in the terminal, but the moment you need to actually touch GitHub, you leave. Open a pull request on the website. Click merge. Switch tabs to see what PRs are open. Push a branch by hand. Every one of those is a context switch out of the place you were working, and it adds up across a day.
GitHub ships an official, free, hosted MCP server that closes that gap. Wire it into Claude Code once and Claude talks to GitHub directly: it can open and merge pull requests, push commits, create branches, and read your issues and PRs, all from the same terminal session and all on your behalf. There is no Docker and no local server to run - the server is hosted by GitHub, and you connect to it with a GitHub personal access token.
The prompt below installs it in about 30 seconds at user scope, so it works in every project and your token stays out of any file you might commit. It checks what you already have before changing anything, walks you through creating a fine-grained token, adds the server, and after a restart proves it works by reading your real pull requests - read-only until you ask for more. One honest note it will give you: git worktrees (parallel branches on your own machine) are a local git feature, separate from this server - the server owns the GitHub side (branches, commits, PRs, merges). It is the free, open piece of the kind of setup ClockedCode curates for you.