github-token-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@github-token-mcpget a GitHub installation token for my repo"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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: onepassword-mcp-server
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 installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
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
Connect AI assistants to your GitHub-hosted Obsidian vault to seamlessly access, search, and analy…
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceEnables 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.
- FlicenseBqualityDmaintenanceEnables secure retrieval of credentials from 1Password vaults for use by AI agents, supporting integration with browser automation for automated login.1
- FlicenseNot gradedqualityDmaintenanceMints short-lived, scoped GitHub App installation tokens on demand for AI agents to access git repositories or the GitHub API.
- FlicenseNot gradedqualityDmaintenanceProvides GitHub App authentication for Git and API operations, enabling temporary token generation for private repository access.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/appare45/gh-token-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server