Okta login toolkit with an interactive CLI and MCP session reuse
Project description
okta-auth
Alpha — this project is under active development and iterating quickly. APIs, tool signatures, and session formats may change between releases.
Okta login toolkit with two entry points:
okta: interactive CLI for humans to log in and save a session locallyokta-auth: MCP server for AI agents that reuse those sessions
CLI Usage
Run okta with no arguments to start an interactive login flow:
okta
You can also pass values directly:
okta https://portal.company.com --username you@company.com
The login flow is headless by default. Pass --headed if you want to see the browser window.
Available commands:
okta [url]: log in and save a sessionokta check <url>: verify a saved sessionokta list: list saved sessionsokta delete <url>: delete a saved sessionokta cookies <url>: inspect stored cookies
MCP Tools
| Tool | Description |
|---|---|
okta_login |
Authenticate to a target URL and store session state |
okta_check_session |
Verify whether a stored session is still valid |
okta_list_sessions |
List saved sessions and metadata |
okta_delete_session |
Remove a stored session |
okta_get_cookies |
Retrieve cookies from stored session (sensitive) |
Sessions are stored under ~/.okta-auth/sessions/. Existing sessions under
~/.okta-auth-mcp/sessions/ are migrated automatically.
Security Model
- This project is intended for local trusted execution.
- Session files and cookies are sensitive credentials; protect the host account.
- Prefer private/internal usage unless security controls are reviewed.
- Never pass credentials as tool arguments — use environment variables so that AI agents never see your username, password, or TOTP secret in their context.
Credentials Setup
Environment Variables
Set credentials in your shell profile so they are inherited by the CLI or MCP server process.
# Add to ~/.zshrc or ~/.zprofile (zsh) / ~/.bashrc (bash)
export OKTA_USERNAME="you@company.com"
export OKTA_PASSWORD="your-okta-password"
export OKTA_TOTP_SECRET="JBSWY3DPEHPK3PXP" # only if MFA is enabled
After editing, reload your shell or open a new terminal, then restart the AI Agent.
The AI agent can then log in with just the URL:
okta_login(url="https://portal.company.com")
Explicit arguments still override environment variables if needed.
1Password CLI
op run injects secrets at process launch time. No plaintext credentials appear in shell profiles, config files, or environment variables — they live only in 1Password.
1. Store credentials in 1Password (one-time setup):
op item create --category login --title "Okta MCP" \
username="you@company.com" \
password="your-okta-password" \
totp_secret="JBSWY3DPEHPK3PXP"
2. Create a secrets reference file at ~/.okta-auth/.env (contains paths, not values):
OKTA_USERNAME=op://Personal/Okta MCP/username
OKTA_PASSWORD=op://Personal/Okta MCP/password
OKTA_TOTP_SECRET=op://Personal/Okta MCP/totp_secret
3. Update your MCP client config to wrap the server with op run:
Claude Code:
claude mcp add okta-auth -- op run --env-file=$HOME/.okta-auth/.env -- uvx --from okta-auth-cli okta-auth
Claude Desktop / Cursor / Windsurf:
{
"mcpServers": {
"okta-auth": {
"command": "op",
"args": ["run", "--env-file=/Users/yourname/.okta-auth/.env", "--", "uvx", "--from", "okta-auth-cli", "okta-auth"]
}
}
}
op run prompts for biometric/Touch ID once per session. Install 1Password CLI via brew install 1password-cli.
macOS Keychain
A built-in alternative that requires no extra tools. Credentials are stored in the system Keychain and fetched on each shell startup.
Store (one-time, run in terminal):
security add-generic-password -a okta-mcp -s OKTA_USERNAME -w "you@company.com"
security add-generic-password -a okta-mcp -s OKTA_PASSWORD -w "your-okta-password"
security add-generic-password -a okta-mcp -s OKTA_TOTP_SECRET -w "JBSWY3DPEHPK3PXP"
Load in ~/.zshrc or ~/.zprofile:
export OKTA_USERNAME=$(security find-generic-password -a okta-mcp -s OKTA_USERNAME -w 2>/dev/null)
export OKTA_PASSWORD=$(security find-generic-password -a okta-mcp -s OKTA_PASSWORD -w 2>/dev/null)
export OKTA_TOTP_SECRET=$(security find-generic-password -a okta-mcp -s OKTA_TOTP_SECRET -w 2>/dev/null)
macOS may prompt for Keychain access on the first load after a reboot.
How to Get Your TOTP Secret Key
The TOTP secret is the Base32 key (16–32 uppercase letters and digits) that backs your authenticator app. You need to obtain it during the initial MFA enrollment — it cannot be retrieved from an already-configured authenticator app.
During Okta MFA setup
- In Okta, go to Settings → Security Methods (or follow your admin's enrollment link).
- Choose Google Authenticator as the factor type.
- The QR code screen also shows a "Can't scan?" link — click it.
- Copy the displayed text key (e.g.
JBSWY3DPEHPK3PXP). This is yourOKTA_TOTP_SECRET. - Finish enrollment by entering the 6-digit code from your authenticator app to confirm.
This project does not currently support portals that use only the Okta Verify app for MFA.
Already enrolled and lost the secret?
You must re-enroll the authenticator factor to obtain a new secret:
- Go to Okta → Settings → Security Methods.
- Remove the existing authenticator entry.
- Re-add it and follow the steps above to capture the secret before scanning the QR code.
Installation
With uv tool
uv tool install okta-auth-cli
okta
With pipx
pipx install okta-auth-cli
okta
With pip
pip install okta-auth-cli
okta
Browser setup
The server uses Playwright for browser automation. It automatically detects and prefers your system Chrome/Edge — no extra download required if you already have one installed.
If no system browser is found, install the Playwright-bundled Chromium as fallback:
playwright install chromium
MCP Client Configuration
Claude Code
claude mcp add okta-auth -- uvx --from okta-auth-cli okta-auth
Claude Desktop / Cursor / Windsurf
{
"mcpServers": {
"okta-auth": {
"command": "uvx",
"args": ["--from", "okta-auth-cli", "okta-auth"]
}
}
}
Use okta for the interactive CLI. Use okta-auth only when wiring the package into an MCP client.
Development
uv venv && source .venv/bin/activate
uv pip install -e '.[dev]'
playwright install chromium
Run checks locally:
ruff format --check .
ruff check .
pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file okta_auth_cli-0.1.1.tar.gz.
File metadata
- Download URL: okta_auth_cli-0.1.1.tar.gz
- Upload date:
- Size: 78.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ad83140edfd861388302c2212b7f57f64c5bf44bf315ceb3b7a67e9adb3d6f9
|
|
| MD5 |
505bb1ba487d34a89427369b55c30e0c
|
|
| BLAKE2b-256 |
4ecc11f73342745064f40797881869b8e4aa7d1cda7ade28a7e10a020f907f25
|
Provenance
The following attestation bundles were made for okta_auth_cli-0.1.1.tar.gz:
Publisher:
release.yml on bunizao/okta-auth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
okta_auth_cli-0.1.1.tar.gz -
Subject digest:
7ad83140edfd861388302c2212b7f57f64c5bf44bf315ceb3b7a67e9adb3d6f9 - Sigstore transparency entry: 1084160663
- Sigstore integration time:
-
Permalink:
bunizao/okta-auth@310ac5bbf0abb754738d52afd4a362a1c3dd2973 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/bunizao
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@310ac5bbf0abb754738d52afd4a362a1c3dd2973 -
Trigger Event:
push
-
Statement type:
File details
Details for the file okta_auth_cli-0.1.1-py3-none-any.whl.
File metadata
- Download URL: okta_auth_cli-0.1.1-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5da0068f4895152406d3d55e660db5b7b382c4c58cbeea808b50f9db7da1a0f
|
|
| MD5 |
0870c7c705ad2a44c86bd9f468e207e4
|
|
| BLAKE2b-256 |
ef1ea7ec23cb091c36d7c20727676b0af1c9e0bbc7b63f66cc0010643f083565
|
Provenance
The following attestation bundles were made for okta_auth_cli-0.1.1-py3-none-any.whl:
Publisher:
release.yml on bunizao/okta-auth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
okta_auth_cli-0.1.1-py3-none-any.whl -
Subject digest:
d5da0068f4895152406d3d55e660db5b7b382c4c58cbeea808b50f9db7da1a0f - Sigstore transparency entry: 1084160777
- Sigstore integration time:
-
Permalink:
bunizao/okta-auth@310ac5bbf0abb754738d52afd4a362a1c3dd2973 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/bunizao
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@310ac5bbf0abb754738d52afd4a362a1c3dd2973 -
Trigger Event:
push
-
Statement type: