github-token-mcp
github-token-mcp
spec.md 的实现。一个专用的主机端 MCP 服务器,用于按需为 devcontainer 内的代理颁发 GitHub App 安装访问令牌。
技术构成
MCP server: 使用
@modelcontextprotocol/serverv2(createMcpHandler+McpServer)通过 Streamable HTTP 提供服务GitHub App 认证: 使用
@octokit/auth-app的createAppAuth(不自行实现 JWT 生成和令牌交换)私钥获取: 使用
@1password/sdk的DesktopAuth— 每次请求时通过 1Password 桌面应用触发生物认证/系统认证提示,而非 CLI 子进程调用Bearer 认证: 使用
@modelcontextprotocol/express的requireBearerAuth。devcontainer 端使用固定的共享令牌进行认证
Related MCP server: Git Repo Auth MCP
设置
npm install
cp .env.example .env # 値を埋めるGITHUB_APP_ID/GITHUB_APP_INSTALLATION_ID: 目标 GitHub App / 安装GITHUB_APP_PRIVATE_KEY_OP_REF: 私钥的 1Password 密钥引用(op://vault/item/field)OP_ACCOUNT_NAME: 1Password 桌面应用侧边栏中显示的账户名(用于DesktopAuth)MCP_BEARER_TOKEN: devcontainer 端通过Authorization: Bearer <token>提供的共享密钥
需要在 1Password 桌面应用端启用 Settings > Developer > Integrate with other apps。
npm run dev # tsx watch で起動
npm run build && npm start实现状态(概要)
get_installation_token工具的类型定义与输入验证仓库覆盖范围验证 →
repo_not_installed权限子集验证 →
permission_escalation_denied通过 1Password 获取私钥 →
key_unavailable将令牌颁发委托给
@octokit/auth-app→github_api_error通过 Streamable HTTP + Bearer 认证提供服务
针对真实 GitHub App / 1Password 保管库的集成测试(需要人工准备认证信息)
devcontainer 端的使用模式(spec.md 中明确推迟处理)
目录结构
src/
config.ts 環境変数ロード
errors.ts spec.md の4種類のエラーコードに対応するTokenError
op-secret.ts 1Password DesktopAuth 経由の秘密鍵取得
github-auth.ts installation repos/permissions 検証 + createAppAuth 呼び出し
tools/get-installation-token.ts get_installation_token ツール本体
server.ts McpServer ファクトリ(ツール登録)
index.ts HTTPエントリポイント(bearer認証 + createMcpHandler配信)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