Set up or restore memory account
setup_accountSet up or restore your persistent memory connection.
Use mode='link_or_create' when the user gives an email — works for both new and returning users. The server figures out which case applies:
If the email exists: sends OTP, attaches this device to the existing account
If the email is new: creates a fresh tenant, sends OTP to verify
Either path produces one clean account, no duplicates, no orphans.
Call setup_account(mode='link_or_create', email='their@email.com'). Then ask the user for the 6-digit code from their email and call setup_account(mode='verify', code='123456', email='their@email.com'). Passing email= on verify is required — session IDs rotate between requests on some clients.
mode='restore': use when the user provides an emk_* API key directly.
mode='reveal_key': echo the full emk_* API key. Works directly on an ALREADY-authenticated session; if the session isn't bound (some clients rotate or omit session ids between requests, so this can happen right after a successful verify), pass email= to receive a 6-digit code, then call again with email= and code= — the same rotation-proof lookup as mode='verify'. Success responses only show a key fingerprint (first 8 chars + last 4) — call this mode only when the user actually needs the full key, e.g. to persist it as 'Authorization: Bearer ' in an MCP connector config. Callers who prove neither a bound session nor email ownership are refused.
If no email yet, ask: 'What email should I use for your memory account?'
After setup completes, call search_facts as the first action to load prior context.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | 6-digit verification code from email (required for mode='verify'). | |
| mode | Yes | 'link_or_create' = primary path — user provides email, server handles new vs returning. 'verify' = OTP confirmation step after link_or_create (pass email= and code=). 'restore' = user has emk_* API key from a prior session. 'link_email' = add email to an existing anonymous session. 'reveal_key' = echo the full API key (bound session, or email= + code= to verify by emailed OTP; responses otherwise show only a fingerprint). | |
| No | Email address. Required for mode='link_or_create'. Also pass on mode='verify' — required when session state is lost (common in claude.ai chat due to session ID rotation). | ||
| api_key | No | API key from a previous session (required for mode='restore') | |
| agent_id | No | Optional: bind a sticky agent identity (e.g. 'emily_code_4.7') in the same call. Equivalent to calling bind_agent immediately after a successful setup. Persists to mcp_sessions.agent_id (migration 0008). wake_status and load_context will default to this agent_id when called without an explicit agent_id= arg. Per-call override still works. |