This document describes OAuth support for MCP HTTP in uxc.
OAuth tokens are stored in a credential (credentials.json). Runtime selection can use
--auth <credential_id> or endpoint binding auto-match (auth_bindings.json).
Implemented in MVP:
- OAuth login via
device_code,authorization_code(PKCE), andclient_credentials - Token persistence in
~/.uxc/credentials.json - Auto refresh before expiry (60s skew)
- One-time refresh + retry on
401 Unauthorized - Structured error codes for OAuth failures
Login with Device Code:
uxc auth oauth login <credential_id> \
--endpoint <mcp_url> \
--flow device_code \
--client-id <client_id> \
--scope "openid profile"Login with Client Credentials:
uxc auth oauth login <credential_id> \
--endpoint <mcp_url> \
--flow client_credentials \
--client-id <client_id> \
--client-secret <client_secret> \
--scope "tools.read"Login with Authorization Code + PKCE:
uxc auth oauth login <credential_id> \
--endpoint <mcp_url> \
--flow authorization_code \
--redirect-uri <redirect_uri> \
--scope "openid profile"Use --authorization-code to provide the code directly, or run interactively and paste the
authorization code / callback URL when prompted.
Agent-friendly two-step Authorization Code + PKCE:
uxc auth oauth start <credential_id> \
--endpoint <mcp_url> \
--redirect-uri <redirect_uri> \
--client-id <client_id> \
--scope "openid profile"uxc auth oauth complete <credential_id> \
--session-id <session_id> \
--authorization-response "http://127.0.0.1:11111/callback?code=..."Notes:
--client-idis optional forauthorization_code.- When omitted,
uxcwill attempt OAuth Dynamic Client Registration via providerregistration_endpoint(RFC 7591). - If provider does not expose registration, pass
--client-idexplicitly. uxc auth oauth login ... --flow authorization_coderemains available for single-process interactive use.uxc auth oauth start/completeis intended for agents or any workflow where authorization must span multiple CLI invocations.
Refresh token manually:
uxc auth oauth refresh <credential_id>Inspect OAuth credential:
uxc auth oauth info <credential_id>Logout (clear OAuth token data in the credential):
uxc auth oauth logout <credential_id>When calling MCP HTTP with an OAuth credential:
- If token is near expiry,
uxcrefreshes first. - If server returns
401,uxcrefreshes once and retries once. - If refresh cannot continue, command returns structured OAuth errors.
OAUTH_REQUIREDOAUTH_DISCOVERY_FAILEDOAUTH_TOKEN_EXCHANGE_FAILEDOAUTH_REFRESH_FAILEDOAUTH_SCOPE_INSUFFICIENT
- UXC supports mixed credential sources in the same store:
literal,env, andop. - For external sources (
env,op), resolved secret values are used at runtime and are not written back as plaintext credential values.