Security & Auth Deep Dive

OAuth 2.1 & Device Flow for Automated Crypto Trading Agents

Static exchange API keys are the #1 security failure mode in AI trading bots: keys leak into chat logs, prompt histories, or `.env` files with overly broad permissions. Eterna replaces static API keys with standard OAuth 2.1 discovery and scoped tokens.

Updated: By Eterna Engineering (Security & Agent Architecture Team)Read as Markdown
Direct Answer

Eterna MCP uses OAuth 2.1 (`https://ai-auth.eterna.exchange`) with PKCE for interactive clients (Claude, Cursor, ChatGPT) and OAuth Device Authorization Flow for headless terminals and CLIs (`@eterna-hybrid-exchange/cli`). Every OAuth sign-in automatically provisions an isolated no-KYC trading sub-account with zero raw exchange API secrets exposed to the LLM.

Auth Issuerai-auth.eterna.exchangeRFC 8414 & RFC 9728 discovery
Scopemcp:fullScoped to isolated agent sub-account
Secrets in PromptZeroLLM never sees exchange signing keys
Account Isolation1 sub-account / authBlast-radius containment by default
https://mcp.eterna.exchange/mcp

1. Automatic MCP OAuth Discovery Flow

Modern MCP clients discover Eterna's authorization server automatically without manual client IDs.

  1. 01Client requests protected resource metadata

    When an MCP client connects to `https://mcp.eterna.exchange/mcp`, an unauthenticated request returns `401` pointing to `/.well-known/oauth-protected-resource`.

  2. 02Authorization server metadata & PKCE

    The client reads `/.well-known/oauth-authorization-server` on `ai-auth.eterna.exchange`, performs dynamic registration if needed, and opens a browser login with PKCE.

  3. 03Sub-account auto-provisioning

    On first sign-in, Eterna creates an isolated trading sub-account automatically (no KYC, no separate `register_agent` tool call required).

  4. 04Token refresh & revocation

    Short-lived access tokens authenticate each `execute_code` call; revoking access immediately cuts off agent execution without rotating master account keys.

2. Common Auth Issues & Fixes

Error messages, root causes, and exact fixes
Error / Failure ModeRoot CauseExact Fix
401 Unauthorized on /mcpAccess token expired or missing Authorization Bearer headerRe-authenticate via your client's /mcp menu or run `npx @eterna-hybrid-exchange/cli auth login`.
OAuth callback failed in local IDEBrowser popup blocked or stale cached MCP sessionClear the cached MCP OAuth token in Cursor/Claude settings and reconnect to `https://mcp.eterna.exchange/mcp`.
Insufficient balance after loginFunds were deposited to Funding Wallet but not transferred to Trading WalletCall `eterna.getAllCoinsBalance()` and `eterna.transferToTrading({ coin: 'USDT', amount })`.
FAQ

Frequently asked questions

Does the LLM ever see my underlying exchange API key?
No. The LLM only passes TypeScript code to `execute_code`. Signing and exchange execution happen server-side inside the authenticated gateway.
Is there a `register_agent` MCP tool I need to call first?
No. There is no `register_agent` tool. Signing in via OAuth 2.1 provisions your isolated sub-account automatically.
Primary Sources

References & verification links

Start Trading via MCP

Connect your AI agent in 30 seconds

One remote MCP URL. 800+ USDT perpetuals, 380+ spot pairs, 0.014% maker / 0.035% taker, no KYC.

View on GitHub