MCP Authentication
How authentication works — OAuth 2.0 for interactive MCP clients, API keys for automation, and auth.md agent registration.
Three ways to authenticate
| Method | Use it for | What the user does |
|---|---|---|
| OAuth 2.0 (default) | Claude Code, Claude, ChatGPT, Cursor, Copilot Studio, any OAuth-capable MCP client | Adds the MCP URL, approves a LiveFolio sign-in |
| Workspace API key | CI, scripts, webhooks, older clients without OAuth | Generates a key in Settings → API Key |
| auth.md agent registration | Autonomous agents that must register on a user's behalf | Agent starts a claim; user approves by email or OTP |
OAuth 2.0 (interactive clients)
The MCP endpoint is a protected resource. An unauthenticated request receives:
HTTP 401
WWW-Authenticate: Bearer resource_metadata="https://livefolio.cloud/.well-known/oauth-protected-resource"
An OAuth-capable client then discovers:
- Protected resource metadata —
/.well-known/oauth-protected-resourceresource:https://livefolio.cloud/api/mcpauthorization_servers:["https://livefolio.cloud"]
- Authorization server metadata —
/.well-known/oauth-authorization-serverauthorization_endpoint:/api/oauth/authorizetoken_endpoint:/api/oauth/tokenregistration_endpoint:/api/oauth/register(dynamic client registration)- PKCE
S256; public clients (token_endpoint_auth_method: none)
The flow is the standard authorization-code + PKCE flow. The user sees a LiveFolio sign-in/consent screen; the client receives an access token and uses it as Authorization: Bearer <token> on /api/mcp.
No API key is involved. A client that does not support OAuth should use the key fallback below.
Workspace API key (automation)
Get a key
- Go to Settings → API Key in the dashboard.
- Click Generate Workspace API Key.
- Copy it now, or reveal/copy it again later from Settings → API Key. The format is
lf_live_followed by 48 hex characters.
One key per workspace. Generating a new key rotates the old one immediately; revoking leaves the workspace with no active key until you generate another.
Use it
{
"mcpServers": {
"livefolio": {
"type": "http",
"url": "https://livefolio.cloud/api/mcp",
"headers": {
"Authorization": "Bearer lf_live_xxxxxxxxxxxx"
}
}
}
}
If a client cannot set headers, the legacy query-parameter form still works:
https://livefolio.cloud/api/mcp?key=lf_live_xxxxxxxxxxxx
Keys are for automation. Do not put one in a shared folio, a public repo, or a client config you commit.
Agent-native registration (auth.md)
LiveFolio implements the open auth.md protocol. An autonomous agent can register an account and obtain a credential without the user opening the dashboard.
Discovery
GET https://livefolio.cloud/.well-known/oauth-protected-resource
The agent_auth object lists the agent endpoints.
User-claimed flow (one-click or OTP)
-
Register — create an anonymous session:
POST /api/agent/auth { "type": "anonymous" }The response includes a
registration_session_idand a short-livedlf_preclaim_…polling token. The polling token is not valid on/api/mcp. -
Claim — send the user's email:
POST /api/agent/auth/claim { "registration_session_id": "…", "email": "user@example.com" }The user receives a one-click authorize link (with a 6-digit OTP fallback).
-
Poll / complete — poll
GET /api/agent/auth/sessionwith the preclaim token, or complete with the OTP:POST /api/agent/auth/claim/complete { "registration_session_id": "…", "code": "123456" }On completion the agent receives a persistent
lf_live_…key.
The full protocol is served at /auth.md:
curl https://livefolio.cloud/auth.md
Key management
- Name keys descriptively — "Claude Code (MacBook)" not "key1".
- One key per workspace — the workspace holds a single integration key.
- Rotate regularly — generate a new key and revoke the old one.
- Revoke instantly — a revoked key stops all clients using it.
Troubleshooting
"Unauthorized" / 401
- OAuth client: run the client's authentication action again (Claude Code:
/mcp → livefolio → Authenticate). The sign-in may have expired or been revoked. - API key: check the key exists in Settings → API Key, then check the header:
Authorization: Bearer lf_live_…. - Make sure the client is pointed at
/api/mcp, not the site root.
The sign-in never opens
- Check that the client supports OAuth for remote MCP servers.
- In Claude Code, the server must be added with
--transport http; without it, the URL is treated as a stdio command. - If the client cannot do OAuth, use the workspace API key fallback.
Agent can't discover auth endpoints
/.well-known/oauth-protected-resource and /.well-known/oauth-authorization-server are public. If they are unreachable, check the instance URL and any proxy in front of it.
Self-hosted auth
Self-hosted instances allow local MCP clients without a key when no master key is configured. If LIVEFOLIO_API_KEY or settings.json mcpKey is set, clients must send it as Authorization: Bearer <key> (or ?key=). Remote/tunnel access always requires the key. If you expose the instance through the public tunnel, review Self-Hosting: Configuration.