@buildaureon/mcp 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/auth.md CHANGED
@@ -1,351 +1,351 @@
1
- # Authentication Guide
2
-
3
- How **`@buildaureon/mcp`** `v0.1.1` authenticates to the live AUREON API — aligned with `@buildaureon/sdk`, safe for humans and for agents that call the **43** stdio tools.
4
-
5
- Related docs: [Setup](./setup.md) · [Tools](./tools.md) · [Agent guide](./agent-guide.md) · [Architecture](./architecture.md) · [Security](./security.md) · [Package README](../README.md)
6
-
7
- ---
8
-
9
- ## Who this is for
10
-
11
- - **Agent operators** wiring Cursor or Claude Desktop with an issued developer key
12
- - **Integrators** comparing MCP auth to the typed SDK client
13
- - **Security reviewers** checking that private keys never enter the MCP process
14
- - **Agents** reading this file as context before calling `aureon_me`, restore, or vault prepare tools
15
-
16
- If you have not configured the host yet, start with [./setup.md](./setup.md), then return here for credential semantics.
17
-
18
- ---
19
-
20
- ## Goals of MCP auth
21
-
22
- 1. Reach the resolved API (default local mainnet `http://127.0.0.1:8788` / 4663). Opt in to the public host with `AUREON_NETWORK=testnet` (still 46630).
23
- 2. Bind control-plane actions to a wallet identity (issued key or Bearer session).
24
- 3. Keep signing and broadcasting of on-chain vault steps **outside** MCP.
25
- 4. Prefer a long-lived issued key for always-on agents over interactive wallet handshakes.
26
-
27
- The operator utility at [app.aureonlabs.network](https://app.aureonlabs.network) remains wallet-Bearer oriented for humans. MCP and the SDK share the issued-key path for automation.
28
-
29
- ---
30
-
31
- ## Credential types
32
-
33
- | Credential | Where you get it | Put it in MCP? | What it does |
34
- | --- | --- | --- | --- |
35
- | **Issued developer API key** | Developers page → create key | Yes — `AUREON_API_KEY` | Product access **and** wallet identity for control-plane tools. **Recommended.** |
36
- | **Bootstrap / env-style key** | Rare / special environments | Only if explicitly issued for that purpose as `AUREON_API_KEY` | Same transport header as an issued key; treat with equal secrecy. Prefer Developers-issued keys for production agents. |
37
- | **Wallet Bearer token** | Wallet sign-in, or `aureon_verify_wallet` | Optional — `AUREON_AUTH_TOKEN` or in-process after verify | Session for utility-style identity. **Wins** when both key and Bearer are present. |
38
- | **Wallet private key** | Your wallet / HSM / signing bot | **Never** in MCP env | Sign and broadcast deposit/withdraw txs **outside** MCP after prepare tools return unsigned steps. |
39
-
40
- Plain language:
41
-
42
- - **Issued key** = “this agent may call the API as my Developers-bound wallet.”
43
- - **Bearer** = “this process has an active wallet session.”
44
- - **Private key** = “this other process may move funds on chain.” MCP does not hold that.
45
-
46
- ---
47
-
48
- ## Environment variables (auth-focused)
49
-
50
- | Variable | Role |
51
- | --- | --- |
52
- | `AUREON_API_KEY` | Preferred. Issued developer key. |
53
- | `AUREON_AUTH_TOKEN` | Optional Bearer. Use when you intentionally want a session without (or in addition to) a key — see conflict rules below. |
54
- | `AUREON_NETWORK` | Optional. Omit for mainnet (4663 / 8788). Set `testnet` for the public host (still 46630). |
55
- | `AUREON_API_URL` | Optional override. Must match `AUREON_NETWORK` if both are set. |
56
-
57
- Startup rule: at least one of `AUREON_API_KEY` or `AUREON_AUTH_TOKEN` must be set or the MCP process exits with a clear error.
58
-
59
- See also the setup tables in [./setup.md](./setup.md).
60
-
61
- ---
62
-
63
- ## Recommended path: issued developer key
64
-
65
- This is the default for Cursor, Claude, and other always-on agents.
66
-
67
- ### Steps
68
-
69
- 1. Issue a key on the **same** API you will call. Local mainnet: Developers on `http://127.0.0.1:5174`. Public testnet: [app.aureonlabs.network](https://app.aureonlabs.network) (still 46630).
70
- 2. Connect the wallet that should own objectives and Capital Book state.
71
- 3. Open **Developers** and create a key (name it after the host, e.g. `cursor-mcp`).
72
- 4. Copy the secret once into the host MCP `env` as `AUREON_API_KEY`.
73
- 5. Do **not** set `AUREON_AUTH_TOKEN` unless you have a specific reason.
74
- 6. Restart the host and call `aureon_ping` then `aureon_me`.
75
-
76
- Minimal env (local mainnet 8788 / 4663):
77
-
78
- ```bash
79
- AUREON_API_KEY=aureon_....
80
- # AUREON_NETWORK=testnet # only for the public host (still 46630)
81
- ```
82
-
83
- With only the issued key, agents can sync portfolio, create objectives, fetch restore plans, restore, refresh watchdog, and manage developer keys — without an interactive signature each session.
84
-
85
- Rotate or revoke from the same Developers page if the secret is exposed. Update the host config immediately after rotation.
86
-
87
- ---
88
-
89
- ## Optional wallet handshake (Bearer session)
90
-
91
- Use when you need a utility-style session, when debugging auth, or when an issued key is unavailable and you already hold a Bearer.
92
-
93
- ### Tools involved
94
-
95
- | Tool | Role |
96
- | --- | --- |
97
- | `aureon_get_auth_nonce` | Fetch an EIP-191 challenge message for an address |
98
- | `aureon_verify_wallet` | Submit address + message + signature (+ optional invite); **stores** the returned Bearer in-process |
99
- | `aureon_logout` | Revoke the session server-side and clear the in-process token |
100
- | `aureon_me` | Show the wallet for the active key or Bearer |
101
- | `aureon_dev_login` | Preview-only login — **not** available on the production API |
102
-
103
- ### Sequence
104
-
105
- ```text
106
- Agent → aureon_get_auth_nonce(address)
107
- ← challenge message
108
-
109
- Agent → host wallet signs message (EIP-191) [outside MCP]
110
- ← signature
111
-
112
- Agent → aureon_verify_wallet(address, message, signature, inviteCode?)
113
- ← token; MCP session.setToken(token)
114
-
115
- Later tools use getAccessToken() from the in-process session provider.
116
- ```
117
-
118
- Early access may require an `inviteCode` on first verify for a new wallet.
119
-
120
- You may also seed `AUREON_AUTH_TOKEN` in the host env if you already obtained a Bearer elsewhere. That token is loaded into the same in-process session provider at startup.
121
-
122
- Prefer issued keys for unattended agents. Handshakes need a human (or separate signing host) for every new session after logout or process restart — unless the Bearer is re-injected via env.
123
-
124
- ---
125
-
126
- ## How MCP stores Bearer in-process
127
-
128
- On startup, `@buildaureon/mcp` builds an `@buildaureon/sdk` client with:
129
-
130
- - `apiKey` from `AUREON_API_KEY` (if set)
131
- - `getAccessToken` from a small session provider initialized with `AUREON_AUTH_TOKEN` (if set)
132
-
133
- When `aureon_verify_wallet` (or `aureon_dev_login` on a preview API) succeeds, the MCP layer calls `session.setToken(token)`.
134
-
135
- When `aureon_logout` succeeds, it clears the in-process token after the API revoke.
136
-
137
- Important properties:
138
-
139
- - The Bearer lives **only in the MCP process memory** (plus whatever you put in host env).
140
- - Restarting the host clears memory unless `AUREON_AUTH_TOKEN` is still in env.
141
- - MCP does not write tokens to disk and does not sync them into Cursor chat history by itself — but agents may echo tool results; treat tool output as sensitive.
142
-
143
- Issued keys do not need this session store for identity. The key header alone identifies the Developers-bound wallet.
144
-
145
- ---
146
-
147
- ## `aureon_me` and `aureon_logout`
148
-
149
- ### `aureon_me`
150
-
151
- Returns the wallet bound to the **effective** credential the gateway sees: issued key identity, or Bearer session when a Bearer is active and winning.
152
-
153
- Use it as the first identity check after setup:
154
-
155
- - Expected address matches your Developers wallet → good.
156
- - Unexpected address → you likely have a stale Bearer winning over the key (see conflict rules).
157
-
158
- ### `aureon_logout`
159
-
160
- Revokes the current Bearer session and clears the in-process token.
161
-
162
- It does **not** revoke your issued developer API key. Key lifecycle is managed on the Developers page (`aureon_revoke_api_key` / pause toggle tools, or the UI).
163
-
164
- After logout, if only `AUREON_API_KEY` remains, subsequent tools continue as the key-bound wallet. If you had neither key nor a remaining env Bearer, authenticated calls will fail until you configure credentials again.
165
-
166
- ---
167
-
168
- ## What MCP never does
169
-
170
- | Action | MCP behavior |
171
- | --- | --- |
172
- | Hold a wallet private key | Never — not in env, not in tool args, not in memory by design |
173
- | Sign EIP-191 auth challenges | Host / wallet signs; MCP only transports nonce and verify |
174
- | Sign or broadcast vault txs | `aureon_prepare_vault_*` returns **unsigned** steps only |
175
- | Custodialize funds | Non-custodial; settlement remains plan-driven on the API / vault |
176
- | Replace the operator utility | Humans still use the app; MCP is the agent adapter |
177
- | Enable `aureon_dev_login` on production | Production rejects it; use issued keys |
178
-
179
- If an agent asks for a private key “so MCP can deposit,” refuse and point to prepare → external sign → sync. See [./security.md](./security.md).
180
-
181
- ---
182
-
183
- ## Conflict rules: key + Bearer together
184
-
185
- Both credentials may be present:
186
-
187
- 1. Host sets `AUREON_API_KEY` **and** `AUREON_AUTH_TOKEN`, or
188
- 2. Host sets only the key, then the agent runs `aureon_verify_wallet` and stores a Bearer in-process.
189
-
190
- **Rule:** when both are sent on a request, the **Bearer wins** for wallet identity.
191
-
192
- Implications:
193
-
194
- - An old Bearer can mask a freshly rotated issued key’s wallet.
195
- - Debugging “wrong wallet on `aureon_me`” almost always means clear Bearer: call `aureon_logout`, remove `AUREON_AUTH_TOKEN` from env, restart the host.
196
- - For always-on agents, keep config key-only so identity is predictable across restarts.
197
-
198
- Bootstrap or special env keys still travel as `AUREON_API_KEY`. They do not change the Bearer-wins rule when a session token is also attached.
199
-
200
- ---
201
-
202
- ## Private key: outside MCP only
203
-
204
- Vault deposit and withdraw are two-phase:
205
-
206
- 1. **MCP / SDK prepare** — `aureon_prepare_vault_deposit` or `aureon_prepare_vault_withdraw` returns unsigned calldata / steps.
207
- 2. **External signer** — a wallet UI, hardware wallet, or a separate `@buildaureon/sdk` script with a private key broadcasts the txs.
208
- 3. **Sync** — `aureon_sync_portfolio` / `aureon_get_vault` to refresh Capital Book state.
209
-
210
- Never paste a private key into MCP tool arguments or host env “for convenience.” That expands the blast radius of every chat that can invoke tools.
211
-
212
- ---
213
-
214
- ## Common errors
215
-
216
- | Error / symptom | Meaning | Fix |
217
- | --- | --- | --- |
218
- | Startup: set `AUREON_API_KEY` or `AUREON_AUTH_TOKEN` | No credential configured | Add issued key to host `env` — [./setup.md](./setup.md) |
219
- | `401` Unauthorized | Key revoked/paused, Bearer expired, or typo | Rotate key or re-verify wallet |
220
- | Wrong wallet on `aureon_me` | Bearer winning over key | `aureon_logout`; remove env Bearer; restart |
221
- | `aureon_verify_wallet` fails | Bad signature, stale nonce, or missing invite | New nonce; re-sign; supply `inviteCode` if required |
222
- | `aureon_dev_login` fails on live API | Expected | Use an issued key. Public host is still 46630. |
223
- | Prepare tools succeed but funds do not move | Unsigned steps not broadcast | Sign outside MCP with a real wallet |
224
- | Agent invents a local API URL | Misconfigured override | Omit `AUREON_API_URL` for 8788, or set `AUREON_NETWORK=testnet` |
225
-
226
- Map structured SDK errors in tool output to the same categories; do not retry blindly on `401` without rotating credentials.
227
-
228
- ---
229
-
230
- ## Agent-safe practices
231
-
232
- 1. **Prefer issued keys** in host config; avoid interactive Bearer for unattended loops.
233
- 2. **Never request private keys** in chat; guide operators to prepare → external broadcast.
234
- 3. **Do not echo full API keys or Bearers** back into long chat logs when summarizing tool results.
235
- 4. **Call `aureon_me` once** after connect to confirm identity before write tools.
236
- 5. **On identity mismatch**, clear Bearer before creating objectives or restoring.
237
- 6. **Treat Developers keys like passwords** — rotate on leak; use labeled keys per host.
238
- 7. **Keep MCP local stdio** — do not expose the process on a public port.
239
- 8. **Read** [./agent-guide.md](./agent-guide.md) before multi-step restore or market-event rehearsals.
240
- 9. **Respect locked objective fields** — recreate rather than fighting update errors (see tools doc).
241
- 10. **Assume tool output may be logged** by the host; minimize secret material in responses.
242
-
243
- ---
244
-
245
- ## Topology (mental model)
246
-
247
- ```text
248
- MCP host (Cursor / Claude)
249
- │ stdio
250
-
251
- @buildaureon/mcp (54 tools, no private key)
252
-
253
-
254
- @buildaureon/sdk (HTTP, retries, types)
255
- │ HTTP(S) + API key and/or Bearer
256
-
257
- default http://127.0.0.1:8788 (4663)
258
- opt-in https://api.aureonlabs.network (still 46630)
259
-
260
- ├── control plane (objectives, portfolio, restore, …)
261
- └── prepare vault steps → human/agent signs elsewhere
262
- ```
263
-
264
- Architecture detail: [./architecture.md](./architecture.md).
265
-
266
- ---
267
-
268
- ## FAQ
269
-
270
- ### Is an issued key enough for restore?
271
-
272
- Yes. `aureon_restore_objective` and related control-plane tools authenticate with the issued key. On-chain funding of the vault still needs external signing when deposits are required.
273
-
274
- ### When should I use Bearer instead?
275
-
276
- Interactive debugging, parity with the operator utility session model, or short-lived demos. Not the default for scheduled agents.
277
-
278
- ### What is a “bootstrap” key in this doc?
279
-
280
- A key supplied via environment rather than freshly minted in the UI mid-session. Operationally it still goes in `AUREON_API_KEY`. Prefer Developers-issued keys you can pause and revoke from the console.
281
-
282
- ### Does logout delete my API key?
283
-
284
- No. Logout clears Bearer session state. Manage keys on the Developers page or via developer tools.
285
-
286
- ### Can MCP and the SDK share the same issued key?
287
-
288
- Yes. Same live API, same key family. Revoking the key affects both surfaces.
289
-
290
- ### Why does Bearer win over the key?
291
-
292
- So an explicit wallet session can override key identity when operators intentionally complete a handshake. For agents, avoid that ambiguity by not setting Bearer.
293
-
294
- ### Where do I configure credentials?
295
-
296
- In the MCP host `env` block — see Cursor / Claude examples in [./setup.md](./setup.md). Primary launch remains `npx -y @buildaureon/mcp`.
297
-
298
- ---
299
-
300
- ## Rotating credentials safely
301
-
302
- When a key may have leaked (pasted in chat, committed to a repo, shared in a screenshot):
303
-
304
- 1. Open [app.aureonlabs.network](https://app.aureonlabs.network) → **Developers**.
305
- 2. Pause or revoke the compromised key immediately.
306
- 3. Create a replacement key with a new label.
307
- 4. Update every MCP host `env` that still references the old secret.
308
- 5. Restart those hosts so in-memory clients reload.
309
- 6. Call `aureon_me` once to confirm the bound wallet is unchanged and authorized.
310
-
311
- If a Bearer may have leaked, call `aureon_logout` from a trusted session (if still valid), remove `AUREON_AUTH_TOKEN` from env, and re-verify only if you still need a session. Prefer switching the agent to issued-key-only afterward.
312
-
313
- Do not reuse the compromised secret “temporarily.” Treat rotation as mandatory once exposure is plausible.
314
-
315
- ---
316
-
317
- ## Relationship to the SDK
318
-
319
- `@buildaureon/mcp` does not invent a second auth protocol. It configures `createAureonClient` from `@buildaureon/sdk` with the same headers the SDK would send in a script:
320
-
321
- - Issued key → API key header / client option
322
- - Bearer → access token via the session provider
323
- - Base URL → `http://127.0.0.1:8788` by default (4663). Public host is `AUREON_NETWORK=testnet` (still 46630).
324
-
325
- If a typed SDK script works with your issued key but MCP fails, compare env names (`AUREON_API_KEY` vs hard-coded client options) and confirm the host actually injects env into the stdio child process.
326
-
327
- Package version for this guide: **`@buildaureon/mcp` `v0.1.1`**.
328
-
329
- ---
330
-
331
- ## Quick reference checklist
332
-
333
- - [ ] Issued key from Developers page in `AUREON_API_KEY`
334
- - [ ] No private key anywhere in MCP config
335
- - [ ] `AUREON_AUTH_TOKEN` unset unless you need a session
336
- - [ ] `aureon_me` shows the expected wallet
337
- - [ ] You know Bearer wins if both are present
338
- - [ ] Vault moves use prepare tools + external signer
339
- - [ ] Leaked secrets → revoke / rotate on Developers
340
- - [ ] After rotation, every host env updated and restarted
341
-
342
- ---
343
-
344
- ## Next steps
345
-
346
- - Finish host wiring: [./setup.md](./setup.md)
347
- - Tool schemas: [./tools.md](./tools.md)
348
- - Playbooks: [./agent-guide.md](./agent-guide.md)
349
- - Boundaries: [./architecture.md](./architecture.md)
350
- - Threat model: [./security.md](./security.md)
351
- - Package home: [../README.md](../README.md)
1
+ # Authentication Guide
2
+
3
+ How **`@buildaureon/mcp`** `v0.1.9` authenticates to the live AUREON API — aligned with `@buildaureon/sdk`, safe for humans and for agents that call the **54** stdio tools.
4
+
5
+ Related docs: [Setup](./setup.md) · [Tools](./tools.md) · [Agent guide](./agent-guide.md) · [Architecture](./architecture.md) · [Security](./security.md) · [Package README](../README.md)
6
+
7
+ ---
8
+
9
+ ## Who this is for
10
+
11
+ - **Agent operators** wiring Cursor or Claude Desktop with an issued developer key
12
+ - **Integrators** comparing MCP auth to the typed SDK client
13
+ - **Security reviewers** checking that private keys never enter the MCP process
14
+ - **Agents** reading this file as context before calling `aureon_me`, restore, or vault prepare tools
15
+
16
+ If you have not configured the host yet, start with [./setup.md](./setup.md), then return here for credential semantics.
17
+
18
+ ---
19
+
20
+ ## Goals of MCP auth
21
+
22
+ 1. Reach the official API `https://api.aureonlabs.network` (currently testnet 46630). Opt in to chain 4663 with `AUREON_NETWORK=mainnet`.
23
+ 2. Bind control-plane actions to a wallet identity (issued key or Bearer session).
24
+ 3. Keep signing and broadcasting of on-chain vault steps **outside** MCP.
25
+ 4. Prefer a long-lived issued key for always-on agents over interactive wallet handshakes.
26
+
27
+ The operator utility at [app.aureonlabs.network](https://app.aureonlabs.network) remains wallet-Bearer oriented for humans. MCP and the SDK share the issued-key path for automation.
28
+
29
+ ---
30
+
31
+ ## Credential types
32
+
33
+ | Credential | Where you get it | Put it in MCP? | What it does |
34
+ | --- | --- | --- | --- |
35
+ | **Issued developer API key** | Developers page → create key | Yes — `AUREON_API_KEY` | Product access **and** wallet identity for control-plane tools. **Recommended.** |
36
+ | **Bootstrap / env-style key** | Rare / special environments | Only if explicitly issued for that purpose as `AUREON_API_KEY` | Same transport header as an issued key; treat with equal secrecy. Prefer Developers-issued keys for production agents. |
37
+ | **Wallet Bearer token** | Wallet sign-in, or `aureon_verify_wallet` | Optional — `AUREON_AUTH_TOKEN` or in-process after verify | Session for utility-style identity. **Wins** when both key and Bearer are present. |
38
+ | **Wallet private key** | Your wallet / HSM / signing bot | **Never** in MCP env | Sign and broadcast deposit/withdraw txs **outside** MCP after prepare tools return unsigned steps. |
39
+
40
+ Plain language:
41
+
42
+ - **Issued key** = “this agent may call the API as my Developers-bound wallet.”
43
+ - **Bearer** = “this process has an active wallet session.”
44
+ - **Private key** = “this other process may move funds on chain.” MCP does not hold that.
45
+
46
+ ---
47
+
48
+ ## Environment variables (auth-focused)
49
+
50
+ | Variable | Role |
51
+ | --- | --- |
52
+ | `AUREON_API_KEY` | Preferred. Issued developer key. |
53
+ | `AUREON_AUTH_TOKEN` | Optional Bearer. Use when you intentionally want a session without (or in addition to) a key — see conflict rules below. |
54
+ | `AUREON_NETWORK` | Optional. Omit for official API / testnet 46630. Set `mainnet` for chain 4663. |
55
+ | `AUREON_API_URL` | Optional override of `https://api.aureonlabs.network`. |
56
+
57
+ Startup rule: at least one of `AUREON_API_KEY` or `AUREON_AUTH_TOKEN` must be set or the MCP process exits with a clear error.
58
+
59
+ See also the setup tables in [./setup.md](./setup.md).
60
+
61
+ ---
62
+
63
+ ## Recommended path: issued developer key
64
+
65
+ This is the default for Cursor, Claude, and other always-on agents.
66
+
67
+ ### Steps
68
+
69
+ 1. Issue a key at [app.aureonlabs.network](https://app.aureonlabs.network) **Developers**.
70
+ 2. Connect the wallet that should own objectives and Capital Book state.
71
+ 3. Open **Developers** and create a key (name it after the host, e.g. `cursor-mcp`).
72
+ 4. Copy the secret once into the host MCP `env` as `AUREON_API_KEY`.
73
+ 5. Do **not** set `AUREON_AUTH_TOKEN` unless you have a specific reason.
74
+ 6. Restart the host and call `aureon_ping` then `aureon_me`.
75
+
76
+ Minimal env (official API):
77
+
78
+ ```bash
79
+ AUREON_API_KEY=aureon_....
80
+ # AUREON_NETWORK=mainnet # chain 4663 on the same official host
81
+ ```
82
+
83
+ With only the issued key, agents can sync portfolio, create objectives, fetch restore plans, restore, refresh watchdog, and manage developer keys — without an interactive signature each session.
84
+
85
+ Rotate or revoke from the same Developers page if the secret is exposed. Update the host config immediately after rotation.
86
+
87
+ ---
88
+
89
+ ## Optional wallet handshake (Bearer session)
90
+
91
+ Use when you need a utility-style session, when debugging auth, or when an issued key is unavailable and you already hold a Bearer.
92
+
93
+ ### Tools involved
94
+
95
+ | Tool | Role |
96
+ | --- | --- |
97
+ | `aureon_get_auth_nonce` | Fetch an EIP-191 challenge message for an address |
98
+ | `aureon_verify_wallet` | Submit address + message + signature (+ optional invite); **stores** the returned Bearer in-process |
99
+ | `aureon_logout` | Revoke the session server-side and clear the in-process token |
100
+ | `aureon_me` | Show the wallet for the active key or Bearer |
101
+ | `aureon_dev_login` | Preview-only login — **not** available on the production API |
102
+
103
+ ### Sequence
104
+
105
+ ```text
106
+ Agent → aureon_get_auth_nonce(address)
107
+ ← challenge message
108
+
109
+ Agent → host wallet signs message (EIP-191) [outside MCP]
110
+ ← signature
111
+
112
+ Agent → aureon_verify_wallet(address, message, signature, inviteCode?)
113
+ ← token; MCP session.setToken(token)
114
+
115
+ Later tools use getAccessToken() from the in-process session provider.
116
+ ```
117
+
118
+ Early access may require an `inviteCode` on first verify for a new wallet.
119
+
120
+ You may also seed `AUREON_AUTH_TOKEN` in the host env if you already obtained a Bearer elsewhere. That token is loaded into the same in-process session provider at startup.
121
+
122
+ Prefer issued keys for unattended agents. Handshakes need a human (or separate signing host) for every new session after logout or process restart — unless the Bearer is re-injected via env.
123
+
124
+ ---
125
+
126
+ ## How MCP stores Bearer in-process
127
+
128
+ On startup, `@buildaureon/mcp` builds an `@buildaureon/sdk` client with:
129
+
130
+ - `apiKey` from `AUREON_API_KEY` (if set)
131
+ - `getAccessToken` from a small session provider initialized with `AUREON_AUTH_TOKEN` (if set)
132
+
133
+ When `aureon_verify_wallet` (or `aureon_dev_login` on a preview API) succeeds, the MCP layer calls `session.setToken(token)`.
134
+
135
+ When `aureon_logout` succeeds, it clears the in-process token after the API revoke.
136
+
137
+ Important properties:
138
+
139
+ - The Bearer lives **only in the MCP process memory** (plus whatever you put in host env).
140
+ - Restarting the host clears memory unless `AUREON_AUTH_TOKEN` is still in env.
141
+ - MCP does not write tokens to disk and does not sync them into Cursor chat history by itself — but agents may echo tool results; treat tool output as sensitive.
142
+
143
+ Issued keys do not need this session store for identity. The key header alone identifies the Developers-bound wallet.
144
+
145
+ ---
146
+
147
+ ## `aureon_me` and `aureon_logout`
148
+
149
+ ### `aureon_me`
150
+
151
+ Returns the wallet bound to the **effective** credential the gateway sees: issued key identity, or Bearer session when a Bearer is active and winning.
152
+
153
+ Use it as the first identity check after setup:
154
+
155
+ - Expected address matches your Developers wallet → good.
156
+ - Unexpected address → you likely have a stale Bearer winning over the key (see conflict rules).
157
+
158
+ ### `aureon_logout`
159
+
160
+ Revokes the current Bearer session and clears the in-process token.
161
+
162
+ It does **not** revoke your issued developer API key. Key lifecycle is managed on the Developers page (`aureon_revoke_api_key` / pause toggle tools, or the UI).
163
+
164
+ After logout, if only `AUREON_API_KEY` remains, subsequent tools continue as the key-bound wallet. If you had neither key nor a remaining env Bearer, authenticated calls will fail until you configure credentials again.
165
+
166
+ ---
167
+
168
+ ## What MCP never does
169
+
170
+ | Action | MCP behavior |
171
+ | --- | --- |
172
+ | Hold a wallet private key | Never — not in env, not in tool args, not in memory by design |
173
+ | Sign EIP-191 auth challenges | Host / wallet signs; MCP only transports nonce and verify |
174
+ | Sign or broadcast vault txs | `aureon_prepare_vault_*` returns **unsigned** steps only |
175
+ | Custodialize funds | Non-custodial; settlement remains plan-driven on the API / vault |
176
+ | Replace the operator utility | Humans still use the app; MCP is the agent adapter |
177
+ | Enable `aureon_dev_login` on production | Production rejects it; use issued keys |
178
+
179
+ If an agent asks for a private key “so MCP can deposit,” refuse and point to prepare → external sign → sync. See [./security.md](./security.md).
180
+
181
+ ---
182
+
183
+ ## Conflict rules: key + Bearer together
184
+
185
+ Both credentials may be present:
186
+
187
+ 1. Host sets `AUREON_API_KEY` **and** `AUREON_AUTH_TOKEN`, or
188
+ 2. Host sets only the key, then the agent runs `aureon_verify_wallet` and stores a Bearer in-process.
189
+
190
+ **Rule:** when both are sent on a request, the **Bearer wins** for wallet identity.
191
+
192
+ Implications:
193
+
194
+ - An old Bearer can mask a freshly rotated issued key’s wallet.
195
+ - Debugging “wrong wallet on `aureon_me`” almost always means clear Bearer: call `aureon_logout`, remove `AUREON_AUTH_TOKEN` from env, restart the host.
196
+ - For always-on agents, keep config key-only so identity is predictable across restarts.
197
+
198
+ Bootstrap or special env keys still travel as `AUREON_API_KEY`. They do not change the Bearer-wins rule when a session token is also attached.
199
+
200
+ ---
201
+
202
+ ## Private key: outside MCP only
203
+
204
+ Vault deposit and withdraw are two-phase:
205
+
206
+ 1. **MCP / SDK prepare** — `aureon_prepare_vault_deposit` or `aureon_prepare_vault_withdraw` returns unsigned calldata / steps.
207
+ 2. **External signer** — a wallet UI, hardware wallet, or a separate `@buildaureon/sdk` script with a private key broadcasts the txs.
208
+ 3. **Sync** — `aureon_sync_portfolio` / `aureon_get_vault` to refresh Capital Book state.
209
+
210
+ Never paste a private key into MCP tool arguments or host env “for convenience.” That expands the blast radius of every chat that can invoke tools.
211
+
212
+ ---
213
+
214
+ ## Common errors
215
+
216
+ | Error / symptom | Meaning | Fix |
217
+ | --- | --- | --- |
218
+ | Startup: set `AUREON_API_KEY` or `AUREON_AUTH_TOKEN` | No credential configured | Add issued key to host `env` — [./setup.md](./setup.md) |
219
+ | `401` Unauthorized | Key revoked/paused, Bearer expired, or typo | Rotate key or re-verify wallet |
220
+ | Wrong wallet on `aureon_me` | Bearer winning over key | `aureon_logout`; remove env Bearer; restart |
221
+ | `aureon_verify_wallet` fails | Bad signature, stale nonce, or missing invite | New nonce; re-sign; supply `inviteCode` if required |
222
+ | `aureon_dev_login` fails on live API | Expected | Use an issued key. Public host is still 46630. |
223
+ | Prepare tools succeed but funds do not move | Unsigned steps not broadcast | Sign outside MCP with a real wallet |
224
+ | Agent invents a local API URL | Misconfigured override | Omit `AUREON_API_URL` for the official API, or set `AUREON_NETWORK=mainnet` |
225
+
226
+ Map structured SDK errors in tool output to the same categories; do not retry blindly on `401` without rotating credentials.
227
+
228
+ ---
229
+
230
+ ## Agent-safe practices
231
+
232
+ 1. **Prefer issued keys** in host config; avoid interactive Bearer for unattended loops.
233
+ 2. **Never request private keys** in chat; guide operators to prepare → external broadcast.
234
+ 3. **Do not echo full API keys or Bearers** back into long chat logs when summarizing tool results.
235
+ 4. **Call `aureon_me` once** after connect to confirm identity before write tools.
236
+ 5. **On identity mismatch**, clear Bearer before creating objectives or restoring.
237
+ 6. **Treat Developers keys like passwords** — rotate on leak; use labeled keys per host.
238
+ 7. **Keep MCP local stdio** — do not expose the process on a public port.
239
+ 8. **Read** [./agent-guide.md](./agent-guide.md) before multi-step restore or market-event rehearsals.
240
+ 9. **Respect locked objective fields** — recreate rather than fighting update errors (see tools doc).
241
+ 10. **Assume tool output may be logged** by the host; minimize secret material in responses.
242
+
243
+ ---
244
+
245
+ ## Topology (mental model)
246
+
247
+ ```text
248
+ MCP host (Cursor / Claude)
249
+ │ stdio
250
+
251
+ @buildaureon/mcp (54 tools, no private key)
252
+
253
+
254
+ @buildaureon/sdk (HTTP, retries, types)
255
+ │ HTTP(S) + API key and/or Bearer
256
+
257
+ default https://api.aureonlabs.network (46630)
258
+ opt-in AUREON_NETWORK=mainnet (chain 4663, same host)
259
+
260
+ ├── control plane (objectives, portfolio, restore, …)
261
+ └── prepare vault steps → human/agent signs elsewhere
262
+ ```
263
+
264
+ Architecture detail: [./architecture.md](./architecture.md).
265
+
266
+ ---
267
+
268
+ ## FAQ
269
+
270
+ ### Is an issued key enough for restore?
271
+
272
+ Yes. `aureon_restore_objective` and related control-plane tools authenticate with the issued key. On-chain funding of the vault still needs external signing when deposits are required.
273
+
274
+ ### When should I use Bearer instead?
275
+
276
+ Interactive debugging, parity with the operator utility session model, or short-lived demos. Not the default for scheduled agents.
277
+
278
+ ### What is a “bootstrap” key in this doc?
279
+
280
+ A key supplied via environment rather than freshly minted in the UI mid-session. Operationally it still goes in `AUREON_API_KEY`. Prefer Developers-issued keys you can pause and revoke from the console.
281
+
282
+ ### Does logout delete my API key?
283
+
284
+ No. Logout clears Bearer session state. Manage keys on the Developers page or via developer tools.
285
+
286
+ ### Can MCP and the SDK share the same issued key?
287
+
288
+ Yes. Same live API, same key family. Revoking the key affects both surfaces.
289
+
290
+ ### Why does Bearer win over the key?
291
+
292
+ So an explicit wallet session can override key identity when operators intentionally complete a handshake. For agents, avoid that ambiguity by not setting Bearer.
293
+
294
+ ### Where do I configure credentials?
295
+
296
+ In the MCP host `env` block — see Cursor / Claude examples in [./setup.md](./setup.md). Primary launch remains `npx -y @buildaureon/mcp`.
297
+
298
+ ---
299
+
300
+ ## Rotating credentials safely
301
+
302
+ When a key may have leaked (pasted in chat, committed to a repo, shared in a screenshot):
303
+
304
+ 1. Open [app.aureonlabs.network](https://app.aureonlabs.network) → **Developers**.
305
+ 2. Pause or revoke the compromised key immediately.
306
+ 3. Create a replacement key with a new label.
307
+ 4. Update every MCP host `env` that still references the old secret.
308
+ 5. Restart those hosts so in-memory clients reload.
309
+ 6. Call `aureon_me` once to confirm the bound wallet is unchanged and authorized.
310
+
311
+ If a Bearer may have leaked, call `aureon_logout` from a trusted session (if still valid), remove `AUREON_AUTH_TOKEN` from env, and re-verify only if you still need a session. Prefer switching the agent to issued-key-only afterward.
312
+
313
+ Do not reuse the compromised secret “temporarily.” Treat rotation as mandatory once exposure is plausible.
314
+
315
+ ---
316
+
317
+ ## Relationship to the SDK
318
+
319
+ `@buildaureon/mcp` does not invent a second auth protocol. It configures `createAureonClient` from `@buildaureon/sdk` with the same headers the SDK would send in a script:
320
+
321
+ - Issued key → API key header / client option
322
+ - Bearer → access token via the session provider
323
+ - Base URL → `https://api.aureonlabs.network` by default (currently 46630). `AUREON_NETWORK=mainnet` selects chain 4663.
324
+
325
+ If a typed SDK script works with your issued key but MCP fails, compare env names (`AUREON_API_KEY` vs hard-coded client options) and confirm the host actually injects env into the stdio child process.
326
+
327
+ Package version for this guide: **`@buildaureon/mcp` `v0.1.9`**.
328
+
329
+ ---
330
+
331
+ ## Quick reference checklist
332
+
333
+ - [ ] Issued key from Developers page in `AUREON_API_KEY`
334
+ - [ ] No private key anywhere in MCP config
335
+ - [ ] `AUREON_AUTH_TOKEN` unset unless you need a session
336
+ - [ ] `aureon_me` shows the expected wallet
337
+ - [ ] You know Bearer wins if both are present
338
+ - [ ] Vault moves use prepare tools + external signer
339
+ - [ ] Leaked secrets → revoke / rotate on Developers
340
+ - [ ] After rotation, every host env updated and restarted
341
+
342
+ ---
343
+
344
+ ## Next steps
345
+
346
+ - Finish host wiring: [./setup.md](./setup.md)
347
+ - Tool schemas: [./tools.md](./tools.md)
348
+ - Playbooks: [./agent-guide.md](./agent-guide.md)
349
+ - Boundaries: [./architecture.md](./architecture.md)
350
+ - Threat model: [./security.md](./security.md)
351
+ - Package home: [../README.md](../README.md)