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.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 fail-closed: Kheish can store, inspect, refresh, and validate MCP OAuth accounts, but it does not yet expose OAuth-backed MCP tools from these configs. 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; it does not expose OAuth-backed MCP tools in Kheish runtime. 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; OAuth-backed MCP tool/resource use is intentionally not documented as available yet. - 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.
