OAuth
Kheish has one daemon auth store for provider account auth, MCP OAuth accounts, connector secrets, and route secrets. Operators connect accounts into that store; runs and child agents receive only brokered, scoped leases. OAuth in Kheish is not the control-plane bearer token. The HTTP daemon API still uses its own admin/read-only auth model.Provider account auth
OpenAI Codex account auth and Anthropic Claude account auth are imported into normal auth slots. Use these when you want a route to resolve account-backed material instead of a static API key.auth_ref and the account token is already expired when work is submitted, the daemon attempts one slot refresh before rejecting the run as route_not_ready. The run only proceeds if the refreshed slot makes the route readiness recover.
Google, OpenRouter, and xAI are API-key-only at this layer until a real account-auth backend is added for them.
MCP OAuth accounts
MCP OAuth is for HTTP MCP servers that implement the MCP Authorization model with protected resource metadata, authorization server metadata or OIDC discovery, authorization-code flow, PKCE S256,resource, and bearer tokens.
Kheish supports the account layer and operator login flow:
- local loopback callback
- PKCE S256
stateverification- dynamic client registration when the authorization server advertises it
- write-only import into the encrypted auth store
- forced refresh with refresh-token rotation
- redacted status only
- no silent scope escalation on refresh
- loopback
httponly for local protocol tests; production resources must usehttps
KHEISH_AUTH_STORE_MASTER_KEY or KHEISH_AUTH_STORE_MASTER_KEY_FILE set. The CLI writes the completed account through the daemon API; it does not perform an offline auth-store write.
For SSH or headless machines, use --no-open. The CLI prints a JSON object containing authorization_url, redirect_uri, and slot_id; open authorization_url in a browser that can reach the callback host.
127.0.0.1 on the machine running the CLI. For SSH, either run the browser on that same machine or choose a fixed callback port and forward it:
http://127.0.0.1:18765/callback.
Check, refresh, or remove the local account:
mcp.oauth.<id>. You can override it with --slot.
Custom MCP config
Reference the stored OAuth account from Codex-compatible MCP config:oauth_slot_ref names the daemon auth slot. oauth_resource must match the resource used during login. oauth_scopes must be a subset of the scopes originally approved by the user.
Current runtime behavior is scoped and fail-closed: Kheish can store, inspect, refresh, and validate MCP OAuth accounts, and HTTP MCP servers that require OAuth are not initialized with daemon-global credentials at bootstrap. If a server requires OAuth material during bootstrap, the runtime snapshot reports:
catalog_only until a vendor-specific true-binary E2E proves discovery, login, refresh, retry, scope behavior, and tool/resource use.
Linear-specific boundary: Linear’s hosted MCP server supports Streamable HTTP and an interactive OAuth flow upstream. The checked Linear OAuth path reached authorization URL generation only; do not copy that login target into oauth_resource unless it exactly matches the resource used by the authorization server. To use Linear tools today, use the built-in planning profile with mcp.linear.LINEAR_API_KEY stored in the daemon secret store.
Troubleshooting
authorization server does not advertise dynamic registration: pass--client-id, and--client-secretonly when the upstream client type requires it.callback state did not match: retry the login. Kheish rejects mismatched callbacks instead of importing the account.requires https resource URLs: usehttpsfor production.--allow-http-for-loopbackis only for local fixture tests on127.0.0.1,localhost, or::1.attempted to add unapproved scope: re-runmcp oauth loginwith the broader scopes. Agents cannot silently consent to scope escalation.secret is still referenced by one or more MCP servers: stop or restart the daemon without that MCP config before deleting the account.
Evidence note
- Code verified:
crates/kheish-auth/src/oauth.rs,crates/kheish-auth/src/backends/mcp_oauth.rs,crates/kheish-auth/src/manager.rs,crates/kheish-auth/src/broker.rs,crates/kheish-daemon/src/api/handlers.rs,crates/kheish-daemon/src/cli/commands/mcp.rs,crates/kheish-daemon/src/cli/commands/runtime.rs,crates/kheish-mcp/src/config.rs,crates/kheish-mcp/src/manager.rs. - CLI verified:
mcp oauth status/login/refresh/logoutandruntime auth accounts list/get/refresh/revokeare implemented in the daemon CLI. - Daemon live tested: yes for the generic MCP OAuth account protocol path with
scripts/e2e/mcp_oauth_protocol_true_binary.sh; scoped OAuth-backed HTTP MCP authorization is unit-tested at the client/broker boundary, while vendor-specific OAuth tool catalogs still require their own true-binary E2E before being promoted fromcatalog_only. - Vendor OAuth checked: Linear
mcp oauth loginreached authorization URL generation only, but this did not complete account import and did not promote Linear OAuth-backed tool use in Kheish runtime. The supported Linear runtime path remains bearer/API-key auth throughmcp.linear.LINEAR_API_KEY. - Provider-specific tested: OpenAI and Anthropic account backends have deterministic coverage; run manual daemon validation with your real Codex/Claude credentials before production rollout.
