docs(install-claude): "environment variable" examples put the PAT in argv and the saved config
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- markdown
- Lĩnh vực
- documentation, security
Hướng nghiên cứu
Bắt đầu với các ví dụ lệnh trong docs/installation-guides/install-claude.md và ví dụ cấu hình token trong README.md; so sánh cách mỗi ví dụ truyền PAT cho Claude Code. Kiểm tra tài liệu về mở rộng biến môi trường của Claude Code mà issue trích dẫn để xác nhận cú pháp được hỗ trợ. Công việc hoàn tất khi tất cả ví dụ biến môi trường được liệt kê giữ lại tham chiếu biến trong cấu hình đã lưu và không còn mở rộng PAT vào các đối số lệnh.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
Several Claude Code commands in docs/installation-guides/install-claude.md (and one in README.md) expand the personal access token in the shell before Claude Code runs, so the token ends up in the process argument list, in shell history, and as a literal value in the saved MCP configuration:
install-claude.md, "With an environment variable (Linux/macOS)":"Bearer '"$GITHUB_PAT"'"closes the single quotes so the shell substitutes the token into theclaude mcp add-jsonargument.install-claude.md, "With an environment variable (Windows PowerShell)":"Bearer $env:GITHUB_PAT"inside a double-quoted string, same effect.install-claude.md, Docker "With an environment variable":-e GITHUB_PERSONAL_ACCESS_TOKEN=$(grep GITHUB_PAT .env | cut -d '=' -f2).install-claude.md, legacy format:-H "Authorization: Bearer $(grep GITHUB_PAT .env | cut -d '=' -f2)", and the PowerShell variant$pat = "YOUR_GITHUB_PAT"followed by-H "Authorization: Bearer $pat".README.md, "Reference the token in configurations":-e GITHUB_PERSONAL_ACCESS_TOKEN=$GITHUB_PAT.
The sections are labelled "With an environment variable", but the stored configuration does not reference the variable; it holds the token itself.
Suggested fix
Claude Code expands ${VAR} references in an MCP server's url, headers, env, command, and args when it connects (Claude Code MCP docs, "Environment variable expansion"). Keeping the reference in single quotes stores ${GITHUB_PAT} literally, so the token stays in the environment and never reaches argv, history, or the config file. Minimal diff, against main at 99d6d6503a7b2a133e2f8a595d6d0ba24b4086d3:
--- a/README.md
+++ b/README.md
@@ -226,8 +226,8 @@
3. **Reference the token in configurations**
```bash
- # CLI usage
- claude mcp add github -e GITHUB_PERSONAL_ACCESS_TOKEN=$GITHUB_PAT -- docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
+ # CLI usage (single quotes: Claude Code expands ${GITHUB_PAT} at start-up, so the token stays out of argv and the saved config)
+ claude mcp add github -e 'GITHUB_PERSONAL_ACCESS_TOKEN=${GITHUB_PAT}' -- docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
# In config files (where supported)
"env": {
--- a/docs/installation-guides/install-claude.md
+++ b/docs/installation-guides/install-claude.md
@@ -40,14 +40,16 @@
With an environment variable (Linux/macOS):
```bash
export GITHUB_PAT="$(grep '^GITHUB_PAT=' .env | cut -d '=' -f2-)"
-claude mcp add-json github '{"type":"http","url":"https://api.githubcopilot.com/mcp","headers":{"Authorization":"Bearer '"$GITHUB_PAT"'"}}'
+claude mcp add-json github '{"type":"http","url":"https://api.githubcopilot.com/mcp","headers":{"Authorization":"Bearer ${GITHUB_PAT}"}}'
+The single quotes keep ${GITHUB_PAT} literal. Claude Code expands it from the environment when it connects, so the token stays out of the command line, shell history, and the saved configuration. Set GITHUB_PAT in the environment Claude Code starts from.
+
With an environment variable (Windows PowerShell):
$githubPatLine = Get-Content .env | Select-String "^\s*GITHUB_PAT\s*=" | Select-Object -First 1
$env:GITHUB_PAT = ($githubPatLine.Line -split "=", 2)[1].Trim().Trim('"').Trim("'")
-claude mcp add-json github "{`"type`":`"http`",`"url`":`"https://api.githubcopilot.com/mcp`",`"headers`":{`"Authorization`":`"Bearer $env:GITHUB_PAT`"}}"
+claude mcp add-json github '{"type":"http","url":"https://api.githubcopilot.com/mcp","headers":{"Authorization":"Bearer ${GITHUB_PAT}"}}'
About the
--scopeflag (optional): Use this to specify where the configuration is stored:
@@ -80,7 +82,7 @@
With an environment variable:
-claude mcp add github -e GITHUB_PERSONAL_ACCESS_TOKEN=$(grep GITHUB_PAT .env | cut -d '=' -f2) -- docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
+claude mcp add github -e 'GITHUB_PERSONAL_ACCESS_TOKEN=${GITHUB_PAT}' -- docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
- Restart Claude Code
- Run
claude mcp listto see if the GitHub server is configured
@@ -112,7 +114,7 @@
With an environment variable:
-claude mcp add --transport http github https://api.githubcopilot.com/mcp -H "Authorization: Bearer $(grep GITHUB_PAT .env | cut -d '=' -f2)"
+claude mcp add --transport http github https://api.githubcopilot.com/mcp -H 'Authorization: Bearer ${GITHUB_PAT}'
Windows (PowerShell)
@@ -120,8 +122,7 @@
If you see missing required argument 'name', put the server name immediately after claude mcp add:
-$pat = "YOUR_GITHUB_PAT"
-claude mcp add github --transport http https://api.githubcopilot.com/mcp/ -H "Authorization: Bearer $pat"
+claude mcp add github --transport http https://api.githubcopilot.com/mcp/ -H 'Authorization: Bearer ${GITHUB_PAT}'
The placeholder variants (`YOUR_GITHUB_PAT`) are left as they are. I can open this as a pull request if that is easier to review.
- Ngôn ngữ chính
- Go
- Star
- 34.2k
- Fork
- 5.3k
- Merge trung bình
- 5 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 13
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/github-mcp-server
-
update_issue_labels is annotated destructiveHint: false but replaces (removes) existing labelsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
github/github-mcp-server#3760 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
github/github-mcp-server#3729 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
github/github-mcp-server#3722 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Insiders Feedback: PR created UI doesn't link to the PRCó thể đã có người làm @genius-0963 đã nhận 5 ngày trước. Đang mởbug insiders user-experience
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
github/github-mcp-server#3658 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Inconsistent parameter namesCó thể đã có người làm @huong8373tt-beep đã nhận 10 ngày trước. Đang mởbug tool-improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
github/github-mcp-server#3605 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của github/github-mcp-server
Issue tương tự
-
Update the mise toolsĐang mởready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
hexlet-basics/hexlet-basics#962 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
imapproxy closeForMaintenance grace timer calls clientConn.Close() before closeMaintenanceTransportCó thể đã có người làm @dejanstrbac đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Renovate health check failedĐang mởrenovate-health
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Netcracker/qubership-network-latency-exporter#267 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Network capture does not workCó thể đã có người làm @KSpaceer đã nhận hôm nay. Đang mởkind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
aquasecurity/tracee#5395 ·