Skip to content

Read HTTP auth from environment variables - #28

Merged
ShmueLior merged 3 commits into
mainfrom
feat/auth-env
Dec 4, 2026
Merged

ShmueLior merged 3 commits into
mainfrom
feat/auth-env

Conversation

@ShmueLior

Copy link
Copy Markdown
Owner

Read HTTP auth from environment variables

Right now the only way to authenticate an HTTP server is --header "Authorization: Bearer $TOKEN". That puts the token on the command line, so it can end up in shell history or CI logs.

This adds two flags that take the name of an environment variable instead of the token:

  • --bearer-env <VAR> sends Authorization: Bearer <value>, where <value> comes from VAR. If the value already starts with Bearer , it isn't added twice.
  • --header-env 'Name: VAR' sends any header with the value of VAR. Repeatable.

Both only work with --http. If the same header is set more than once, the order is --header, then --header-env, then --bearer-env, and the last one wins. A missing or empty variable is a usage error (exit 2) that names the variable, never the value.

A 401 now says The credentials were rejected. instead of The credentials in --header were rejected., and the hint for a missing token also mentions --bearer-env.

The GitHub Action gets bearer-env and header-env inputs, and the Azure Pipelines template gets bearerEnv and headerEnv. They pass the variable names to the CLI. Put the token in the step's env from a secret:

- uses: ShmueLior/mcpprobe@v0.5
  with:
    http: https://example.test/mcp
    bearer-env: MCP_TOKEN
  env:
    MCP_TOKEN: ${{ secrets.MCP_TOKEN }}

These inputs need a CLI that has the new flags. The wrapper fails fast if the installed CLI doesn't.

No OAuth flow in this PR.

…variables

Tokens passed with --header end up on the command line. The new flags take
the name of an environment variable instead, and the CLI reads the value
from the environment. Later sources win for the same header name: --header,
then --header-env, then --bearer-env. A missing or empty variable is a usage
error that names the variable, not the value. The GitHub Action and the
Azure Pipelines template get matching inputs that pass the variable names.
Move the 401 wording change into Changed. Document the Action workflow that
passes only a variable name, the matching Azure Pipelines parameters, and
that variable names follow the operating system's case rules. Tests now
assert exit 2 and no leaked values for an empty or missing variable, keep
tokens out of stdout, and cover --header-env overriding a typed --header.
# Conflicts:
#	CHANGELOG.md
#	README.md
@ShmueLior
ShmueLior merged commit 75d5862 into main Dec 4, 2026
3 checks passed
@ShmueLior
ShmueLior deleted the feat/auth-env branch December 4, 2026 07:33
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.

1 participant