Skip to content

docs: keep PAT references literal in environment-variable install examples - #3788

Open
shhhhhhjokerist wants to merge 1 commit into
github:mainfrom
shhhhhhjokerist:docs/pat-reference-expansion
Open

shhhhhhjokerist wants to merge 1 commit into
github:mainfrom
shhhhhhjokerist:docs/pat-reference-expansion

Conversation

@shhhhhhjokerist

@shhhhhhjokerist shhhhhhjokerist commented Nov 10, 2026 •

Copy link
Copy Markdown

Summary

Docs-only change: the "environment variable" install examples expand the PAT in the shell instead of storing a ${GITHUB_PAT} reference, so the token ends up in the process arguments and the saved MCP configuration.

Why

Fixes #3758. Claude Code expands ${VAR} references in url, headers, env, command and args when it connects, so quoting the reference keeps the token in the environment only.

What changed

  • README.md — "Handling PATs Securely": the CLI and config-file examples now use a single-quoted ${GITHUB_PAT} reference, and a short note explains why.
  • docs/installation-guides/install-claude.md — the Linux/macOS, PowerShell, Docker and legacy "with an environment variable" examples keep the reference literal:
    • Linux/macOS and PowerShell add-json examples no longer splice the shell-expanded token into the JSON argument; PowerShell now uses single quotes.
    • The Docker and legacy add examples export GITHUB_PAT from .env first and pass -e 'GITHUB_PERSONAL_ACCESS_TOKEN=${GITHUB_PAT}' / -H 'Authorization: Bearer ${GITHUB_PAT}'.
    • The legacy PowerShell example sets $env:GITHUB_PAT and quotes the header, instead of interpolating $pat.

MCP impact

  • No tool or API changes

Prompts tested (tool changes only)

Not applicable — docs only.

Security / limits

  • Auth / permissions considered

The token is no longer written to argv or the stored configuration: it stays in the host environment and is expanded at connect time.

Tool renaming

  • I am not renaming tools as part of this PR

@shhhhhhjokerist
shhhhhhjokerist requested a review from a team as a code owner November 10, 2026 02:31
Copilot AI dynamic review requested due to automatic review settings November 10, 2026 02:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The warnings in README.md and the Claude installation guide incorrectly imply that expanding $GITHUB_PAT exposes the token in Bash history, rather than only in process arguments and saved configuration.

1 open issue
What changed in this PR

This docs-only PR addresses #3758 by keeping personal access token references literal in Claude Code installation commands, allowing expansion at connection time rather than during registration.

Changes:

  • Uses single-quoted ${GITHUB_PAT} references in Bash and PowerShell examples.
  • Loads GITHUB_PAT before Docker and legacy registration commands.
  • Clarifies environment-variable expansion in configuration examples; no tools or APIs change.
File Description
README.md Updates secure PAT guidance and literal environment-variable references.
docs/​installation-guides/​install-claude.md Updates HTTP, Docker, and legacy installation examples to defer token expansion.

Review effort: Balanced (auto)

Comment thread README.md Outdated

3. **Reference the token in configurations**

Quote the value when you add the server so the host expands `${GITHUB_PAT}` when it connects. Letting the shell expand it instead writes the token into the command line, the shell history, and the saved configuration:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - fixed in 3bbcdb9. Bash keeps the command as typed, so the notes now say the token reaches process arguments and the saved configuration; the same correction is in docs/installation-guides/install-claude.md:45, and the PR body no longer claims shell history either.

The "With an environment variable" examples in the Claude Code installation guide
and the README expanded GITHUB_PAT in the shell before passing it to the client:

    claude mcp add github -- docker run -i --rm \
      -e GITHUB_PERSONAL_ACCESS_TOKEN=$GITHUB_PAT ...

That puts the token value in the process arguments and in whatever configuration
the client saves, which is exactly what the installation guide is trying to avoid.

Both hosts expand ${VAR} themselves in command, args, env, url and headers when
they connect, so pass the reference through unexpanded instead:

- Linux/macOS and Docker examples export GITHUB_PAT first and then use single
  quotes: -e 'GITHUB_PERSONAL_ACCESS_TOKEN=${GITHUB_PAT}' and
  -H 'Authorization: Bearer ${GITHUB_PAT}'.
- The PowerShell example quotes each argument with '...' and uses
  $env:GITHUB_PAT, which the shell does not expand either.

The remaining examples (Windows legacy cmd, the plain docker -e form, and the
"paste the token" alternatives) are unchanged because they either cannot
reference an environment variable at all or intentionally inline the value.

Bash keeps a command in history exactly as typed, so the surrounding notes now
say that shell expansion exposes the token in process arguments and saved
configuration, not in shell history.
@shhhhhhjokerist
shhhhhhjokerist force-pushed the docs/pat-reference-expansion branch from ea87692 to 3bbcdb9 Compare November 10, 2026 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(install-claude): "environment variable" examples put the PAT in argv and the saved config

2 participants