GitHub: repo, token & MCP server
Give Claude Code a home for the code. Create the repo, mint a careful least-privilege access token, wire up the GitHub MCP server, and drive a full issue → pull request → merge loop.
Jira gives us work. GitHub gives us a home for the code — and a way to review changes as pull requests. Now we connect Claude Code to GitHub the same way we connected Jira: through an MCP server. Along the way you will learn a security habit worth its weight in gold: fine-grained, least-privilege access tokens.
01Create the repository
On github.com, press New to create a repository. We build everything from
scratch, so make your own rather than cloning someone else's.
Name & describe1 min
Name it pre-legal; description: “A platform for drafting common legal agreements.”
Keep it private (for now)30 sec
Private while you build; you can make it public later so others can clone it.
Add a licence & README30 sec
Add the MIT licence (permissive and friendly) and a generic README so the repo is not empty. Press Create repository.
02Create a fine-grained access token
We are about to give Claude Code the ability to act on our repo. That power must be scoped carefully. GitHub's fine-grained personal access tokens let us grant the minimum needed, on one repo, with an expiry. Finding the screen is fiddly — here is the path:
Your avatar menu → Settings → scroll all the way down to Developer settings → Personal access tokens → Fine-grained tokens → Generate new token. (You may be asked for your password or a two-factor code — that is the point; this is powerful.)
Now configure it with the principle of least privilege: start small, open up only if you must.
| Setting | Choose | Why |
|---|---|---|
| Name | for MCP server | So you remember what it is for. |
| Expiration | 30 days | A short life limits damage if it ever leaks. |
| Repository access | Only pre-legal | The token can touch nothing else you own. |
| Contents | Read | See the files in the repo. |
| Issues | Read & write | Read and raise GitHub Issues (in case you use them instead of Jira). |
| Pull requests | Read & write | Open and update PRs — the heart of the workflow. |
Press Generate token, review the summary, and generate. The next screen shows the token once. Copy it and keep it somewhere safe.
Word (and other rich editors) “helpfully” turn straight quotes into curly quotes and can mangle the string — and a mangled token silently fails. Keep it in a plain text place, or just leave the GitHub tab open to one side so you can copy it again in a moment. Treat a token like a password: never commit it, never share it.
03Clone the repo locally
Back on your repo, press Code and copy the HTTPS URL. In a terminal, go to your projects folder and clone it:
cd ~/projects git clone https://github.com/<you>/pre-legal.git cd pre-legal ls # you should see LICENSE and README
Open the folder in VS Code (File → Open, trust the authors). This is the home of our new project.
04Add the GitHub MCP server
Now connect Claude Code to GitHub with another remote MCP server — this time authenticating with the token you just created. You pass it in a request header:
# replace <YOUR_TOKEN> with the fine-grained token you copied
claude mcp add --transport http github https://api.githubcopilot.com/mcp \
--header "Authorization: Bearer <YOUR_TOKEN>"Yes! And normally you would. We are wiring Jira and GitHub as raw MCP servers for two reasons: they are two of the most famous, powerful, widely-used servers in the community, and they use these very particular authorisation techniques — which are cleanest to do straight through the MCP server. (There is even an official GitHub plugin; it works much the same, just with a different auth setup.)
Start claude, run /context, and you will see a whole set of
GitHub tools now available.
05Take it for a spin: issue → PR → merge
Let us prove the whole loop works, in three plain-English asks.
Raise an issue1 min
“Please write an issue to GitHub that the README needs to be updated.” Claude uses the create issue tool; approve it. Check GitHub — under Issues, there it is: Update README.
Change code and open a PR2 min
“Please update the README to reflect that the project is in progress and will be completed in one week. Then raise a PR for this to be merged.” Claude edits the file, runs local git commands to commit and push (these are plain shell, not MCP), then uses the GitHub tool to open a pull request.
Review and merge1 min
Open the PR on GitHub. Note the tidy summary and the “Generated with Claude Code” attribution it adds. Press Merge pull request → Confirm merge. The README on main now shows the update.
After a merge you may be sitting on the PR's branch locally. Run git status to check, then
git checkout main to return to the main branch. If Git workflow is new to you, do not worry
— it is standard team stuff, and Claude Code can handle most of it for you.
✓ Key takeaways
- Create a dedicated repo (pre-legal) with an MIT licence and a README to start from.
- Use a fine-grained token: least privilege, one repo, a 30-day expiry — contents (read), issues and PRs (read/write).
- Never paste a token into Word (curly quotes corrupt it); treat it like a password.
- Connect GitHub with
claude mcp add … --header "Authorization: Bearer <token>". - We use raw MCP for Jira/GitHub because they are famous, powerful, and use specific auth flows — and the whole issue → PR → merge loop now works from plain English.