Skip to main content
OAuth-protected remote MCP servers now Just Work — point at the URL, approve once in your browser, and tokens are cached and refreshed automatically.
No client_id is required. When a server exposes standard authorization-server metadata (RFC 8414) and dynamic client registration (RFC 7591), PraisonAI discovers the endpoints, registers a client, runs the PKCE flow, and refreshes tokens on its own.

Status

Quick Start

1
The first call opens your browser once so you can approve access. Tokens are cached for future runs — no client_id or scopes to configure.
2
Cached tokens are re-used, and expired ones are refreshed transparently.
3

Or pre-seed from the CLI

Run this once on a workstation, then copy ~/.praisonai/mcp-auth.json to a CI runner for headless environments.

How Zero-config OAuth Works

A 401 with a WWW-Authenticate challenge triggers discovery, registration, and the PKCE flow — all automatic.

Interactive vs Headless

Interactive sessions open a browser; headless environments raise a single actionable exception.
For CI, run praisonai mcp auth <server-name> once interactively on a workstation to seed ~/.praisonai/mcp-auth.json, then copy that file to the CI runner (or mount it as a secret). The CLI runs the exact same OAuth 2.1 flow as the Python client, so it’s a valid way to satisfy the InteractiveAuthRequired prerequisite. With open_browser=False, a missing token raises InteractiveAuthRequired instead of hanging.

Configuration Schema

The oauth: block is now optional. For servers that advertise standard metadata, just supply type: remote and url.
Keep the explicit block only as an escape hatch for servers without RFC 8414 metadata or dynamic registration:

Remote Server with API Key

Python SDK

All OAuth helpers are lazy-loaded from praisonaiagents.mcp.

MCPOAuthProvider

Orchestrates discovery, registration, the PKCE flow, and refresh for one server.

Discovery and Registration Helpers

InteractiveAuthRequired

Raised by ensure_authenticated() when interactive auth is required but open_browser=False.

Auth Storage

PKCE Utilities

OAuth Callback Handler

CLI Commands

Authenticate

Runs the same OAuth 2.1 authorization-code flow (with PKCE) as the Python client. Use it to seed tokens ahead of time — for example, on a workstation before running your agent in CI.
The command:
  • Opens your browser and waits for the loopback callback.
  • Exchanges the code at the discovered token_endpoint.
  • Persists tokens (with expires_at) to ~/.praisonai/mcp-auth.json (0600 permissions).
  • Clears any legacy placeholder entry (oauth_<...>...) from a previous CLI run before starting, so a prior failed login recovers automatically — no manual cleanup.
  • Reads server.oauth.client_id/client_secret from ~/.praisonai/config.toml for servers without dynamic client registration, seeding them into storage before the flow runs.
  • Honors --timeout (default 300s).
On success, tokens are written with access_token, optional refresh_token, and expires_at. The Python client picks them up automatically on the next Agent.start(...). On failure, the command exits 1.
If you previously ran praisonai mcp auth <name> on an older release and saw the success message but the server still rejected your token, you were hit by a bug where the CLI stored a truncated authorization code instead of exchanging it for a real token. Re-running the command on the current release automatically clears the bad entry and completes a real flow — no manual cleanup of ~/.praisonai/mcp-auth.json is needed.

Logout

Removes stored OAuth credentials for a server. Use --yes to skip the confirmation prompt.

List Servers

Shows all configured servers with their type (local/remote) and status.

Token Storage

OAuth tokens are stored in ~/.praisonai/mcp-auth.json with secure file permissions (0600).

Security

  • HTTPS-only — every metadata, authorize, token, and registration URL must be HTTPS (loopback http://127.0.0.1 allowed for testing).
  • Redirect re-validation — each redirect hop is re-checked, so an HTTPS metadata document cannot smuggle a plaintext token endpoint.
  • Refresh re-check — refresh-token grants re-validate the stored token_endpoint over HTTPS (defence in depth).
  • Public client — dynamic registration uses token_endpoint_auth_method: "none" and requests grant_types: ["authorization_code", "refresh_token"].
  • PKCE — all flows use PKCE (S256) plus a random state for CSRF protection.
  • File permissions — token storage uses 0600 (owner read/write only).

Troubleshooting

Remote MCP

Connect to remote MCP servers via HTTP, SSE, or WebSocket.

MCP Authentication

Server-side OAuth 2.1, OIDC, and API-key auth for praisonai-mcp.

MCP Tools

Using MCP tools with agents.

MCP Server

Deploy PraisonAI as an MCP server.