http mode: support static token auth (env) for single-tenant self-hosted deployments
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 68/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- go
- 领域
- api, authentication, backend
调研方向
从 pkg/http/middleware/token.go 和 cmd/github-mcp-server/main.go 开始,然后比较 stdio 命令如何读取 GITHUB_PERSONAL_ACCESS_TOKEN 和 GITHUB_ACCESS_TOKEN。当显式选择启用 HTTP 模式后,在 Authorization 缺失时可以使用已配置的环境令牌,同时每个请求的令牌仍优先,并且两者都没有的请求仍保持未授权状态时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Describe the feature or problem you’d like to solve
github-mcp-server http requires a per-request Authorization header and never reads GITHUB_PERSONAL_ACCESS_TOKEN from the environment - token extraction happens only in pkg/http/middleware/token.go (ExtractUserToken), and httpCmd's ServerConfig has no token field (cmd/github-mcp-server/main.go). The env var is consulted only by the stdio command.
That fits the multi-tenant/centralized use case http mode was built for (#471, #997). But it leaves a gap for single-tenant self-hosted deployments: an org running one server instance with one service credential, fronted by a gateway/tunnel that cannot inject custom headers (in our case, Anthropic's MCP tunnels; the same applies to any transport that forwards requests as-is). The server starts cleanly with the env var set, then 401s every request - a confusing failure, since the README's env-var examples don't mention they're stdio-only.
Proposed solution
In http mode, when no Authorization header is present on a request, fall back to a statically configured token (GITHUB_PERSONAL_ACCESS_TOKEN / GITHUB_ACCESS_TOKEN), opt-in via a flag, e.g.:
github-mcp-server http --static-auth # or --token-from-env
Per-request tokens would still take precedence, preserving the multi-tenant behavior. Notably, the 2026-01-28 GitHub changelog announcing HTTP mode described exactly this fallback ("falls back GITHUB_PERSONAL_ACCESS_TOKEN if no header is provided"), but the shipped behavior doesn't include it.
- 主要语言
- Go
- 星标
- 33.1k
- 派生
- 5k
- 平均合并
- 2 天 15 小时
- 30 天内合并 PR
- 27
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/github-mcp-server 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
github/github-mcp-server#3235 ·
-
enhancement
难度 1/5 1 小时以内 新手友好度 88/100
github/github-mcp-server#3042 · 2 条评论 ·
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
github/github-mcp-server#3032 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 74/100
github/github-mcp-server#2803 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
github/github-mcp-server#2740 ·
查看 github/github-mcp-server 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 78/100
modelcontextprotocol/registry#1654 ·
-
Type/Bug
难度 2/5 1-3 小时 新手友好度 78/100
OpenNSW/nsw-srilanka#497 ·
-
难度 1/5 1 小时以内 新手友好度 92/100
milvus-io/birdwatcher#545 ·
-
kind/bug
难度 2/5 1-3 小时 新手友好度 88/100
kubernetes-sigs/prow#953 · 1 条评论 ·