Skip to main content
The oauth command group handles authentication against MCP servers that require OAuth. Use oauth login to obtain tokens interactively, and the proxy/metadata commands to debug discovery and endpoint behavior.

Quick start

On success, the command prints credentials such as an access token, refresh token, client ID, and sometimes client secret. You can pass access tokens to other commands via --oauth-access-token or --access-token.

Commands

oauth login

Runs a full OAuth flow: discovery, registration, authorization, token exchange. Supports all three registration strategies and auth modes.
Prefer environment variables for --client-secret. Passing it inline leaks to shell history and process listings.
The --credentials-out <path> flag saves OAuth credentials to a file with 0600 permissions. Depending on the flow, the file may include an access token, refresh token, client ID, and client secret. Secret fields are redacted from stdout output. Use the saved file with --credentials-file on other commands.
The --debug-out <path> flag captures a structured debug artifact with full HTTP traces — useful for filing bug reports or handing off to another engineer.

oauth metadata

Fetch and display OAuth metadata from a URL. Useful for verifying your server’s discovery endpoints are correct.

oauth proxy

Send an arbitrary HTTP request through the OAuth proxy with hosted-mode safety checks. Useful for testing individual OAuth endpoints (registration, token, etc.) without building raw HTTP requests.

oauth debug-proxy

Same as oauth proxy but routes through the debug proxy path. Use when testing endpoints that behave differently for debug vs. production requests.

Login flags

For interactive login, a custom --redirect-url must still be an http://localhost or http://127.0.0.1 loopback URL. Custom callback paths are supported.

Using tokens from login

Credentials file (interactive & agent workflows)

For interactive or agent workflows where you login once and run multiple commands, save credentials to a file:
The credentials file includes the server URL and any reusable OAuth credentials returned by the login flow. The CLI validates that the file’s server URL matches the target and checks token expiry before use. Connected commands such as tools list, resources list, prompts list, and server doctor can use refresh-token credentials from the file when the saved access token is expired. protocol conformance and server probe only read a non-expired access token from the file; if the access token is expired, run oauth login --credentials-out again or pass a fresh token directly.
--credentials-file cannot be combined with --access-token, --oauth-access-token, --refresh-token, --client-id, or --client-secret. The CLI rejects conflicting auth sources upfront.

Direct token passing (CI/CD & M2M)

When you already have a token from an environment variable, a secret store, or a client_credentials flow, pass it directly:
You can also use --refresh-token with --client-id (and optionally --client-secret) for commands that support automatic token refresh.