Claude/Code/How To/Set Up Github MCP with 1Password GH token and mise
How to set up a single-repository MCP with fine-grained permissions for a single repository
Impetus
- From a security perspective, it's a good idea to maintain some discipline when integrating MCP Servers:
- InvariantLabsAI/Blog/25/05/GitHub MCP Exploited: Accessing private repositories via MCP here describes an attack that depends on mixing write-access to protected and unprotected repositories with GitHub Fine-Grained Personal Access Tokens. Instead, github PAT security token hygiene dictates that each project should have its own fine-grained personal access token.
- As described in GitHub/MCP/How To/Set up in Cursor with 1Password GH token, it's better to use a Secrets Manager with Biometric authentication at the CLI, using op/run to wrap the GitHub MCP server in a 1Password/Dev/CLI command which extracts the project token from the secrets manager after prompting for biometric authentication.
- From a security perspective, it's a good idea to maintain some discipline when integrating MCP Servers:
This guide describes how to define mise/tasks which
- 1 - will launch claude code in project-specific way similar to, but not identical to Anthropic/App/Claude Code/How To/Bootstrap Claude Code with Mise + UV-Powered Okta Role Assumption.
- 2 - launch a GitHub/MCP server in a way that wraps it in op/run, referencing the 1Password Secret Reference pointing to the GitHub Fine-Grained Personal Access Token for that repository.
Prerequisites
- 1 - a GitHub/Repo has already been created and has some content in it. It does not matter if it is public or private, but it should be owned by you.
- 2 - A GitHub Fine-Grained Personal Access Token has already been created that grants several repository permissions to just the project repository, such as the ability to read and write issues. The token has been stored in 1Password, as well as 1Password/Dev/CLI having been installed properly and available in PATH.
- 3 - a home directory mise/Config/mise.toml has been created with a run configuration this in it (see also Anthropic/App/Claude Code/How To/Bootstrap Claude Code with Mise + UV-Powered Okta Role Assumption for context)
Procedure
1 Add a private env file
2 Define the GitHub/MCP mise/Task task mise/Config/mise.toml along with a task to run MCP/Inspector to test it, using 1Password/Dev/op/run to load a GitHub Fine-Grained PAT 1Password Secret Reference from an EnvVar/.env file
- toml
[tasks.gh-mcp] # see also [Anthropic/App/Claude Code/How To/Set Up Github MCP with 1Password GH token and mise](https://codekiln.github.io/logseq-encode-garden/#/page/anthropic%2Fapp%2Fclaude%20code%2Fhow%20to%2Fset%20up%20github%20mcp%20with%201password%20gh%20token%20and%20mise) description = "Start GitHub MCP server (using github-mcp.env) and 1Password CLI" alias = "mcp" run = ''' #!/usr/bin/env bash set -euo pipefail op run --env-file=github-mcp.env -- \ docker run -i --rm \ -e GITHUB_PERSONAL_ACCESS_TOKEN \ ghcr.io/github/github-mcp-server ''' [tasks.gh-mcp-inspect] description = "Launch MCP Inspector UI against gh-mcp" alias = "inspect" run = ''' #!/usr/bin/env bash set -euo pipefail # Pass "mise run gh-mcp" so Inspector starts the server itself # you will then need to npx -y @modelcontextprotocol/inspector mise run gh-mcp '''
3 Test the connection to the GitHub MCP Server with MCP/Inspector
- 1 - run
mise run gh-mcp-inspect - 2 - (in browser) - click Connect
- 3 - test out the connection by using one of the tools that are enabled for the GitHub Fine-Grained Access Token you supplied in
github-mcp.env, for example,get_issue - Once the connection is successful, proceed. If the connection is not successful, debug here before continuing.
- 1 - run
4 Create a project-scoped
.mcp.jsonand run Claude/Code to test- 1 - Either enter
mise run claude mcp add gh -s project mise run gh-mcp, which will create this file in the repository root: - 2 -
mise run claudeto open claude code, which should read the file above - 3 - the first time, you will need to give permission to claude to use this MCP server
- 4 - use
/mcpcommand to check out mcp connection inside of claude - 4 - ask Claude to execute the same tool you used to test the GitHub MCP Server. For example, if you endowed the PAT with the permission to read issues, try
Let's test your MCP connection - can you find the first github issue?
> Let's test your MCP connection - can you find the first github issue? ⏺ I'll use the GitHub API to search for the first issue in this repository. ⏺ gh:list_issues (MCP)(owner: "boingo", repo: "langgraph-assistant-migrator", state: "all", sort: "created", direction: "asc") ⎿ Error: MCP error -32603: failed to list issues: GET https://api.github.com/repos/boingo/langgraph-assistant-migrator/issues?direction=asc&sort=created&state=all: 404 Not Found [] ⎿ Interrupted by user > you have tried `boingo` instead of using git to inspect this repository's owner - why? ⏺ You're right, I made an assumption without checking the repository owner. Let me check the git configuration to find the correct owner. ⏺ Bash(git config --get remote.origin.url) ⎿ git@github.com:codekiln/langgraph-assistant-migrator.git ⏺ Now I'll try again with the correct owner: ⏺ gh:list_issues (MCP)(owner: "codekiln", repo: "langgraph-assistant-migrator", state: "all", sort: "created", direction: "asc") ⎿ [ { "id": 3121550442, "number": 1, … +49 lines (ctrl+r to expand) ⏺ Found it. Issue #1 is titled "test issue" with description "test issue description", created by codekiln.- It should succeed. If it does not, debug, comparing to the output of MCP Inspector.
- 1 - Either enter
Troubleshooting
References