Skip to content

Add PE RBAC Token - #8

Open
psreed wants to merge 4 commits into
mainfrom
rbac-token
Open

Add PE RBAC Token#8
psreed wants to merge 4 commits into
mainfrom
rbac-token

Conversation

@psreed

@psreed psreed commented Aug 6, 2026

Copy link
Copy Markdown
  • Add PE_RBAC_TOKEN variable and forward as X-Authentication HTTP header to MCP server.
  • Accept MCP URL with or without trailing slashes
  • Add some error handling/logging around 401 errors if missing a token (better user experience)

paul.reed@perforce.com and others added 4 commits August 6, 2026 15:07
The MCP endpoint is fronted by nginx, which authenticates against PE
RBAC, but proxy.py built its client with no auth at all. Every request
came back 401 and the initialize handshake died with an opaque
"Session terminated" that gave no hint a token was involved.

Read PE_RBAC_TOKEN and send it as the X-Authentication header via
StreamableHttpTransport. An empty or unset token is valid -- not every
deployment gates on RBAC -- so omit the header entirely rather than
send an empty one, which some proxies reject outright.

Also normalize PE_MCP_URL. PE serves the endpoint at /mcp; a trailing
slash is rewritten upstream to /infra-assistant/mcp/ and 404s *after*
the RBAC check passes, so the caller sees the same opaque handshake
failure. Both forms get typed, so accept either.

A 401 now writes an actionable diagnostic to stderr through an httpx
response hook, naming the missing token and how to generate one.
Supplying an httpx_client_factory makes fastmcp ignore the transport's
verify, so the CA cert is applied inside the factory instead -- without
that, TLS silently falls back to system CAs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
setup wrote only PE_MCP_URL into config.env, so the container path had
no way to supply a token even once the client could use one. It also
prompted for the URL with a trailing slash, which is the form that 404s.

setup now prompts for the token without echoing it and stores it in
/config/rbac-token at mode 0600 -- deliberately outside config.env,
since it is a credential rather than configuration. Leaving the prompt
blank is supported for deployments that do not gate on RBAC, and clears
any previously stored token so blank reliably means blank.

load_config exports the token when it is not already set, so an
explicit -e PE_RBAC_TOKEN still wins, and re-normalizes PE_MCP_URL so
a URL passed straight through -e gets the same treatment as one entered
in setup. The placeholder comparison is normalized to match.

The token is not required by validate or serve: an unauthenticated PE
MCP is a valid target, and selftest.py explains a 401 if one was in
fact needed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Adds build/, *.egg-info/ and uv.lock, which local builds and uv runs
leave in the working tree.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
gavindidrichsen added a commit that referenced this pull request Aug 7, 2026
Adds a "Which PE MCP target am I connecting to?" section, a walkthrough
for connecting to the legacy pe-infra-assistant MCP with PE_RBAC_TOKEN,
updated Troubleshooting entries for PR #8's actual diagnostics, and a
new CHEATSHEET.md with copy-paste validate commands for both targets.

Proposed documentation pending Gavin's review -- not yet pushed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@gavindidrichsen gavindidrichsen changed the title Additions for accepting and using a PE RBAC Token Add PE RBAC Token Aug 7, 2026
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