Skip to main content
Glama
appare45

github-token-mcp

by appare45

github-token-mcp

spec.md 的实现。一个专用的主机端 MCP 服务器,用于按需为 devcontainer 内的代理颁发 GitHub App 安装访问令牌。

技术构成

  • MCP server: 使用 @modelcontextprotocol/server v2(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配信)

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables 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.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Mints short-lived, scoped GitHub App installation tokens on demand for AI agents to access git repositories or the GitHub API.
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    Provides GitHub App authentication for Git and API operations, enabling temporary token generation for private repository access.
    -