github-token-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
gh-token-server
devcontainer内のエージェントへ、GitHub App installation access token を都度発行するホスト専用HTTPサーバー。GitHub Appの秘密鍵はホスト側にのみ存在し、devcontainer側には一切渡さない。
セットアップ(ホスト側でサーバーを起動)
npm install
cp .env.example .env # 値を埋めるGITHUB_APP_ID/GITHUB_APP_INSTALLATION_ID: 対象のGitHub App / インストールGITHUB_APP_PRIVATE_KEY_OP_REF: 秘密鍵の1Password secret reference (op://vault/item/field)OP_ACCOUNT_NAME: 1Password desktop app サイドバーに表示されるアカウント名(DesktopAuth用)BEARER_TOKEN: devcontainer側がAuthorization: Bearer <token>で提示する共有シークレットALLOWED_HOSTS(任意): 受け付けるHostヘッダのカンマ区切りリスト(DNS rebinding対策)。未設定時はlocalhost,127.0.0.1,host.docker.internalTOKEN_REQUEST_HOOK_PATH(任意): トークンリクエスト受信時(1Passwordプロンプトより前)に実行するスクリプトのパス。TOKEN_REQUEST_REPOS(カンマ区切り)/TOKEN_REQUEST_PERMISSIONS(JSON文字列)を環境変数として渡す。fire-and-forgetで実行され、失敗してもトークン発行はブロックしない。macOS通知を出すサンプルがhooks/notify-macos.sh
1Password desktop app側で Settings > Developer > Integrate with other apps を有効化しておくこと。
npm run dev # tsx watch で起動
npm run build && npm startRelated MCP server: Git Repo Auth MCP
devcontainerでの使い方
サーバーをホストで起動しておけば、devcontainer側は GITHUB_TOKEN/GH_TOKEN がシェル全体に設定された状態で gh や git をそのまま使える。都度MCPツールを呼ぶ必要はない。
利用するリポジトリの
.devcontainer/devcontainer.jsonに、対象リポジトリと共有シークレットを渡す設定を追加する:{ "containerEnv": { "GITHUB_REPO": "<owner>/<repo>" }, "remoteEnv": { "BEARER_TOKEN": "${localEnv:BEARER_TOKEN}" } }BEARER_TOKENはdevcontainer upを実行するホスト側シェルで export しておく(.envはサーバープロセス自身が読むだけで、${localEnv:...}は別途OSのシェル環境変数を見る)。Linuxホストでは
host.docker.internalが既定で解決されないため、runArgs: ["--add-host=host.docker.internal:host-gateway"]を追加する。Claude Codeの設定(
~/.claude/settings.json。devcontainer間で共有するclaude-code-configvolumeに置けば全プロジェクト共通で効く)に、セッション開始時にトークンを取得して$CLAUDE_ENV_FILEへ書き出すSessionStartフックを登録する:{ "hooks": { "SessionStart": [ { "matcher": "", "hooks": [ { "type": "command", "command": "$CLAUDE_CONFIG_DIR/hooks/fetch-github-token.sh >> \"$CLAUDE_ENV_FILE\"" } ] } ] } }fetch-github-token.shは$GITHUB_REPO/$BEARER_TOKENを使ってこのサーバーからトークンを取得し、export GITHUB_TOKEN=... GH_TOKEN=...を出力するだけのスクリプト。GITHUB_REPO/BEARER_TOKENが未設定のプロジェクトでは何もせず終了するため、他プロジェクトに影響しない。#!/bin/sh set -e if [ -z "$GITHUB_REPO" ] || [ -z "$BEARER_TOKEN" ]; then exit 0 fi token=$(curl -fsS "http://host.docker.internal:3000/${GITHUB_REPO}" \ -H "Authorization: Bearer ${BEARER_TOKEN}") || exit 0 GH_TOKEN="$token" gh auth setup-git >/dev/null 2>&1 || true echo "export GITHUB_TOKEN=${token} GH_TOKEN=${token}"gh auth setup-gitはgitのcredential helperをghに向ける設定で、ghは呼び出し時点のGH_TOKENを見て認証するため、これでghCLIだけでなくgit push/git cloneなどHTTPS経由のgit操作もそのまま通るようになる。
これでコンテナ内のClaude Codeセッションは起動時にトークンを取得済みの状態になり、gh auth login なしで gh/git が使える。installation tokenの有効期限は約1時間なので、それを超える長時間セッションでは新しいセッションを開始して再取得する。
API
GET /:owner/:repo
指定リポジトリに対する installation access token を発行する。
認証: Authorization: Bearer <BEARER_TOKEN>
クエリパラメータ(任意): GitHub App permissionsのキーをそのままクエリパラメータ名として指定する(例: ?contents=read&issues=write)。省略時は次のデフォルト権限が使われる。
contents: write
issues: write
pull_requests: writeレスポンス: 成功時はトークン文字列を text/plain で返す。失敗時はエラーメッセージを text/plain で返し、ステータスコードで種別を示す。
ステータス | エラー種別 |
400 |
|
401 | Bearer認証失敗 |
403 | Hostヘッダ不許可 |
422 |
|
502 |
|
503 |
|
リクエスト例(devcontainer側から、ホストの host.docker.internal:3000 へ)
curl -sS "http://host.docker.internal:3000/appare45/gh-token-server" \
-H "Authorization: Bearer ${BEARER_TOKEN}"デフォルト権限を絞り込みたい場合はクエリパラメータで指定する:
curl -sS "http://host.docker.internal:3000/appare45/gh-token-server?contents=read" \
-H "Authorization: Bearer ${BEARER_TOKEN}"This server cannot be deployed
Maintenance
Related MCP Connectors
Operate GitHub from your AI assistant: repos, PRs, issues, Actions. Previews and read-only mode.
Access the GitHub API, enabling file operations, repository management, search functionality, and…
Manage repositories, users, releases, and automate GitHub workflows
Issue, rotate and revoke scoped API-key passes for 25+ providers — the agent never sees a real key
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables access to GitHub repositories and data through the GitHub API. Supports retrieving repositories, issues, pull requests, and searching code across GitHub with authentication via personal access tokens.-
- FlicenseNot gradedqualityDmaintenanceMints short-lived, scoped GitHub App installation tokens on demand for AI agents to access git repositories or the GitHub API.-
- FlicenseNot gradedqualityCmaintenanceProvides GitHub App authentication for Git and API operations, enabling temporary token generation for private repository access.-
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to access private GitHub repositories, organizations, issues, pull requests, and file contents via OAuth authentication.391 npmMIT