@buildaureon/mcp 0.1.7 → 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/CHANGELOG.md +62 -0
- package/README.md +402 -399
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/docs/agent-guide.md +652 -652
- package/docs/architecture.md +377 -377
- package/docs/auth.md +351 -349
- package/docs/security.md +335 -335
- package/docs/setup.md +347 -346
- package/docs/tools.md +765 -765
- package/examples/claude-desktop.json +11 -12
- package/examples/cursor.mcp.json +11 -12
- package/package.json +67 -63
package/docs/architecture.md
CHANGED
|
@@ -1,377 +1,377 @@
|
|
|
1
|
-
# Architecture
|
|
2
|
-
|
|
3
|
-
How `@buildaureon/mcp` sits on top of `@buildaureon/sdk` and the hosted AUREON API.
|
|
4
|
-
|
|
5
|
-
This document is for humans integrating the package and for AI agents that need a stable mental model of layers, ownership, and request flow. It describes the published adapter only: a thin stdio MCP server that forwards tool calls to the SDK
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 1. Overview
|
|
10
|
-
|
|
11
|
-
**AUREON** exposes Financial Compass control-plane APIs (objectives, portfolio book, health, restore plans, vault prepare helpers, developer keys). Agents do not need to invent HTTP paths or auth headers when they can call named MCP tools instead.
|
|
12
|
-
|
|
13
|
-
**`@buildaureon/mcp`** is that named surface. It:
|
|
14
|
-
|
|
15
|
-
- Speaks Model Context Protocol over **stdio** to a host (Cursor, Claude Desktop, or any MCP-compatible runner).
|
|
16
|
-
- Validates tool arguments with **Zod** schemas at the handler boundary.
|
|
17
|
-
- Delegates every successful call to **`@buildaureon/sdk`** (`AureonClient`).
|
|
18
|
-
- Formats JSON results and maps SDK errors into short, agent-readable text.
|
|
19
|
-
|
|
20
|
-
It does **not** embed policy math, vault encoding, keeper logic, or chain broadcasting. Those live in the API, the chain contracts, and the operator’s own signing path.
|
|
21
|
-
|
|
22
|
-
### Layer stack
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
Host (Cursor / Claude / other MCP host)
|
|
26
|
-
→ MCP JSON-RPC over stdio
|
|
27
|
-
→ mcp handlers + Zod
|
|
28
|
-
→ @buildaureon/sdk HTTP client
|
|
29
|
-
→ https://api.aureonlabs.network
|
|
30
|
-
→ vault / Robinhood Chain settlement path
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### System context (mermaid)
|
|
34
|
-
|
|
35
|
-
```mermaid
|
|
36
|
-
flowchart TB
|
|
37
|
-
subgraph hosts [MCP_hosts]
|
|
38
|
-
Cursor[Cursor]
|
|
39
|
-
Claude[Claude_Desktop]
|
|
40
|
-
Other[Other_MCP_hosts]
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
subgraph mcpPkg ["@buildaureon/mcp"]
|
|
44
|
-
Stdio[StdioServerTransport]
|
|
45
|
-
Registry[McpServer_tool_registry]
|
|
46
|
-
Handlers[Zod_handlers]
|
|
47
|
-
Format[format_and_errors]
|
|
48
|
-
Session[SessionTokenProvider]
|
|
49
|
-
Client[AureonClient_bundle]
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
subgraph sdkPkg ["@buildaureon/sdk"]
|
|
53
|
-
HTTP[HTTP_transport]
|
|
54
|
-
Types[Types_and_validation]
|
|
55
|
-
ErrModel[Error_codes]
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
API[
|
|
59
|
-
Vault[Smart_Vault]
|
|
60
|
-
Chain[Robinhood_Chain]
|
|
61
|
-
|
|
62
|
-
Cursor --> Stdio
|
|
63
|
-
Claude --> Stdio
|
|
64
|
-
Other --> Stdio
|
|
65
|
-
Stdio --> Registry
|
|
66
|
-
Registry --> Handlers
|
|
67
|
-
Handlers --> Format
|
|
68
|
-
Handlers --> Client
|
|
69
|
-
Client --> Session
|
|
70
|
-
Client --> HTTP
|
|
71
|
-
HTTP --> Types
|
|
72
|
-
HTTP --> ErrModel
|
|
73
|
-
HTTP --> API
|
|
74
|
-
API --> Vault
|
|
75
|
-
Vault --> Chain
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
The MCP binary is a **local adapter**. Hosts spawn it as a child process; it is not intended as a public HTTP gateway.
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
## 2. Responsibility table
|
|
83
|
-
|
|
84
|
-
| Concern | Owner | Notes |
|
|
85
|
-
| --- | --- | --- |
|
|
86
|
-
| Tool names and descriptions | MCP | One tool per public SDK method |
|
|
87
|
-
| Zod argument schemas | MCP | Reject bad shapes before network I/O |
|
|
88
|
-
| Pretty-print JSON for agents | MCP (`format.ts`) | Stable indentation / truncation hygiene |
|
|
89
|
-
| Map SDK errors → text | MCP (`errors.ts`) | Prefer `[CODE] message` form |
|
|
90
|
-
| Env config (`AUREON_*`) | MCP (`config.ts`) | Startup validation |
|
|
91
|
-
| stdio / MCP JSON-RPC | `@modelcontextprotocol/sdk` | Transport + server primitives |
|
|
92
|
-
| HTTPS client, retries, timeouts | SDK | Shared with non-MCP apps |
|
|
93
|
-
| Request/response types | SDK | Canonical TypeScript contracts |
|
|
94
|
-
| Input normalization | SDK | Amounts, ids, enums |
|
|
95
|
-
| Error codes (`UNAUTHORIZED`, …) | SDK | Cross-client consistency |
|
|
96
|
-
| Session token holder | SDK provider + MCP auth tools | Mutable Bearer in-process |
|
|
97
|
-
| Policy engine / restore planning | Hosted API | Not reimplemented in MCP |
|
|
98
|
-
| Vault calldata encoding | Hosted API | Prepare endpoints return unsigned steps |
|
|
99
|
-
| On-chain broadcast / signing | Operator / host wallet | Outside MCP process |
|
|
100
|
-
| Key pause / revoke | API + developer tools | Control-plane lifecycle |
|
|
101
|
-
|
|
102
|
-
Rule of thumb: if a change affects every AUREON client (CLI scripts, bots, MCP), put it in the **SDK or API**. If it only helps agents discover or call the surface, put it in **MCP**.
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
|
-
## 3. Request lifecycle
|
|
107
|
-
|
|
108
|
-
### Process start
|
|
109
|
-
|
|
110
|
-
1. Host launches `aureon-mcp` (or `npx -y @buildaureon/mcp`) with environment variables.
|
|
111
|
-
2. `src/index.ts` calls `startServer()` from `server.ts`.
|
|
112
|
-
3. `loadConfig()`
|
|
113
|
-
4. Startup requires at least one credential: issued API key and/or initial Bearer.
|
|
114
|
-
5. `createClient()` builds a `SessionTokenProvider` and an `AureonClient` bound to that provider.
|
|
115
|
-
6. `registerTools()` attaches the full tool catalog to an `McpServer` instance.
|
|
116
|
-
7. `StdioServerTransport` connects; the process blocks on stdin/stdout until the host exits.
|
|
117
|
-
|
|
118
|
-
### Per tool call
|
|
119
|
-
|
|
120
|
-
```mermaid
|
|
121
|
-
sequenceDiagram
|
|
122
|
-
participant Host as MCP_host
|
|
123
|
-
participant MCP as aureon_mcp
|
|
124
|
-
participant Zod as Zod_schema
|
|
125
|
-
participant SDK as AureonClient
|
|
126
|
-
participant API as AUREON_API
|
|
127
|
-
|
|
128
|
-
Host->>MCP: tools/call name + args
|
|
129
|
-
MCP->>Zod: parse arguments
|
|
130
|
-
alt invalid
|
|
131
|
-
Zod-->>MCP: ZodError
|
|
132
|
-
MCP-->>Host: isError text
|
|
133
|
-
else valid
|
|
134
|
-
MCP->>SDK: matching method
|
|
135
|
-
SDK->>API: HTTPS + auth headers
|
|
136
|
-
alt API / transport failure
|
|
137
|
-
API-->>SDK: error
|
|
138
|
-
SDK-->>MCP: AureonError or Error
|
|
139
|
-
MCP-->>Host: fail mapped text
|
|
140
|
-
else success
|
|
141
|
-
API-->>SDK: JSON body
|
|
142
|
-
SDK-->>MCP: typed result
|
|
143
|
-
MCP-->>Host: ok formatted JSON
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Typical agent loop (restore):
|
|
149
|
-
|
|
150
|
-
1. `aureon_get_health` — detect violation / drift.
|
|
151
|
-
2. `aureon_get_restore_plan` — inspect proposed steps and settlement mode.
|
|
152
|
-
3. `aureon_restore_objective` — execute plan; read `settlement: "vault" | "staged"`.
|
|
153
|
-
4. Optionally `aureon_list_executions` / timeline tools for receipts.
|
|
154
|
-
|
|
155
|
-
Issued API keys travel as `X-Aureon-Api-Key`. Optional wallet Bearer uses `Authorization`. Neither is printed into tool results.
|
|
156
|
-
|
|
157
|
-
---
|
|
158
|
-
|
|
159
|
-
## 4. Tool registration
|
|
160
|
-
|
|
161
|
-
Registration is centralized and domain-split:
|
|
162
|
-
|
|
163
|
-
| Module | Role |
|
|
164
|
-
| --- | --- |
|
|
165
|
-
| `tools/catalog.ts` | Canonical ordered list of tool names / count |
|
|
166
|
-
| `tools/index.ts` | Calls each domain `register*` helper |
|
|
167
|
-
| `tools/handler.ts` | Shared `ok` / `fail` wrappers |
|
|
168
|
-
| `tools/read.ts` | Overview, portfolio read, health, timeline, … |
|
|
169
|
-
| `tools/compass.ts` | Restore plan, restore, executions |
|
|
170
|
-
| `tools/vault.ts` | Vault status + prepare deposit/withdraw |
|
|
171
|
-
| `tools/auth.ts` | Nonce, verify, login, logout, me |
|
|
172
|
-
| `tools/objectives.ts` | Create / update / pause / resume |
|
|
173
|
-
| `tools/portfolio.ts` | Set / clear / sync Capital Book |
|
|
174
|
-
| `tools/market.ts` | Presets, shocks, watchdog |
|
|
175
|
-
| `tools/developer.ts` | List / create / revoke / toggle API keys |
|
|
176
|
-
|
|
177
|
-
Design constraints:
|
|
178
|
-
|
|
179
|
-
1. **One tool per SDK method** — predictable for agents and docs.
|
|
180
|
-
2. **Names are stable** — `aureon_*` prefix; catalog is the source of truth for count.
|
|
181
|
-
3. **Handlers stay thin** — parse → call → format; no second business layer.
|
|
182
|
-
4. **Write tools are explicit** — agents must choose create/restore/prepare; nothing auto-trades.
|
|
183
|
-
|
|
184
|
-
When adding a new SDK method, the MCP checklist is: catalog entry, Zod schema, register helper, docs row in `tools.md`, and a short example in the agent guide if the workflow is non-obvious.
|
|
185
|
-
|
|
186
|
-
---
|
|
187
|
-
|
|
188
|
-
## 5. Session provider
|
|
189
|
-
|
|
190
|
-
`client.ts` wires:
|
|
191
|
-
|
|
192
|
-
```text
|
|
193
|
-
createSessionTokenProvider(initialToken?)
|
|
194
|
-
createAureonClient({ baseUrl, apiKey, getAccessToken })
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
Behavior:
|
|
198
|
-
|
|
199
|
-
- **Issued API key** is fixed for the process lifetime (from env). It authenticates the control plane without a wallet handshake.
|
|
200
|
-
- **Bearer token** is mutable. Auth tools (`aureon_verify_wallet`, `aureon_dev_login`) call `session.setToken(...)`. `aureon_logout` clears it.
|
|
201
|
-
- `getAccessToken` is consulted per SDK request so mid-session verify/login takes effect without restarting the host.
|
|
202
|
-
- MCP never persists tokens to disk. Memory only, for the child process lifetime.
|
|
203
|
-
|
|
204
|
-
Recommended production posture: rely on an issued key for agent hosts; use wallet Bearer only when a human-driven verify flow is intentional.
|
|
205
|
-
|
|
206
|
-
---
|
|
207
|
-
|
|
208
|
-
## 6. Error mapping
|
|
209
|
-
|
|
210
|
-
`errors.ts` converts failures into compact strings:
|
|
211
|
-
|
|
212
|
-
| Input | Output shape |
|
|
213
|
-
| --- | --- |
|
|
214
|
-
| SDK `AureonError` | `[CODE] message` |
|
|
215
|
-
| Generic `Error` | `message` |
|
|
216
|
-
| Unknown throw | `String(err)` |
|
|
217
|
-
|
|
218
|
-
Handlers mark tool responses with `isError: true` so hosts surface failures distinctly from JSON payloads.
|
|
219
|
-
|
|
220
|
-
Agents should:
|
|
221
|
-
|
|
222
|
-
- Treat `[UNAUTHORIZED]` / `[FORBIDDEN]` as credential or key-state problems (paused/revoked key, missing Bearer).
|
|
223
|
-
- Treat `[VALIDATION]` as bad arguments — fix inputs, do not retry blindly.
|
|
224
|
-
- Treat transport timeouts as transient; retry read tools carefully, avoid duplicate write tools without idempotency checks.
|
|
225
|
-
|
|
226
|
-
MCP does not invent new error codes. Codes originate in the SDK / API so scripts and agents share vocabulary.
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
## 7. What lives in SDK vs MCP
|
|
231
|
-
|
|
232
|
-
### Lives in `@buildaureon/sdk`
|
|
233
|
-
|
|
234
|
-
- HTTP transport to
|
|
235
|
-
- Header composition (API key + Bearer).
|
|
236
|
-
- Retries, timeouts, and typed client methods.
|
|
237
|
-
- Shared types for objectives, health, restore plans, vault prepare results.
|
|
238
|
-
- Session token provider factory.
|
|
239
|
-
- Canonical error model (`isAureonError`, codes).
|
|
240
|
-
|
|
241
|
-
### Lives in `@buildaureon/mcp`
|
|
242
|
-
|
|
243
|
-
- Process entry (`index.ts`) and stdio server bootstrap (`server.ts`).
|
|
244
|
-
- Env loading / startup gates (`config.ts`).
|
|
245
|
-
- Client bundle assembly for MCP (`client.ts`).
|
|
246
|
-
- Tool catalog, Zod schemas, domain registration modules.
|
|
247
|
-
- Agent-facing formatting (`format.ts`) and error text (`errors.ts`).
|
|
248
|
-
- Examples of host MCP JSON configs (Cursor / Claude Desktop).
|
|
249
|
-
|
|
250
|
-
### Lives outside both packages
|
|
251
|
-
|
|
252
|
-
- Private keys and hardware wallets.
|
|
253
|
-
- Transaction broadcasting and gas payment.
|
|
254
|
-
- Human approval UX in the host product.
|
|
255
|
-
- Hosted policy engine, keepers, and vault contracts.
|
|
256
|
-
|
|
257
|
-
---
|
|
258
|
-
|
|
259
|
-
## 8. Conceptual file map
|
|
260
|
-
|
|
261
|
-
| Path | Responsibility |
|
|
262
|
-
| --- | --- |
|
|
263
|
-
| `src/index.ts` | CLI / bin entry — starts the server |
|
|
264
|
-
| `src/server.ts` | Config → client → register tools → stdio connect |
|
|
265
|
-
| `src/config.ts` | Parse and validate `AUREON_*` env |
|
|
266
|
-
| `src/client.ts` | `AureonClient` + `SessionTokenProvider` bundle |
|
|
267
|
-
| `src/errors.ts` | SDK / unknown → agent-readable text |
|
|
268
|
-
| `src/format.ts` | JSON formatting for tool results |
|
|
269
|
-
| `src/tools/catalog.ts` | Ordered tool names and `TOOL_COUNT` |
|
|
270
|
-
| `src/tools/handler.ts` | Shared success / failure response helpers |
|
|
271
|
-
| `src/tools/index.ts` | Registers all domains onto `McpServer` |
|
|
272
|
-
| `src/tools/read.ts` | Read-mostly control-plane queries |
|
|
273
|
-
| `src/tools/compass.ts` | Restore plan and execution surface |
|
|
274
|
-
| `src/tools/vault.ts` | Vault reads + unsigned prepare helpers |
|
|
275
|
-
| `src/tools/auth.ts` | Auth handshake + session mutation |
|
|
276
|
-
| `src/tools/objectives.ts` | Objective lifecycle writes |
|
|
277
|
-
| `src/tools/portfolio.ts` | Capital Book mutations / sync |
|
|
278
|
-
| `src/tools/market.ts` | Market presets, events, watchdog |
|
|
279
|
-
| `src/tools/developer.ts` | Issued API key management |
|
|
280
|
-
|
|
281
|
-
Supporting package docs (`setup`, `auth`, `tools`, `agent-guide`, `security`) describe usage; this file describes structure.
|
|
282
|
-
|
|
283
|
-
---
|
|
284
|
-
|
|
285
|
-
## 9. Versioning
|
|
286
|
-
|
|
287
|
-
| Artifact | Version meaning |
|
|
288
|
-
| --- | --- |
|
|
289
|
-
| `@buildaureon/mcp` package version | Adapter release (tool catalog, schemas, formatting) |
|
|
290
|
-
| MCP server `version` field | Mirrors package version reported to hosts |
|
|
291
|
-
| `@buildaureon/sdk` dependency | Protocol / client contract with the API |
|
|
292
|
-
| API
|
|
293
|
-
|
|
294
|
-
Compatibility expectations:
|
|
295
|
-
|
|
296
|
-
- **Patch** MCP releases: formatting, docs, defensive validation — no tool renames.
|
|
297
|
-
- **Minor** MCP releases: new tools mirroring new SDK methods; existing names stay.
|
|
298
|
-
- **Major** MCP releases: breaking tool renames or required auth model changes (rare; documented in release notes).
|
|
299
|
-
|
|
300
|
-
Agents should pin a known MCP package version in host config when reproducibility matters. Prefer matching SDK majors that the MCP release was tested against.
|
|
301
|
-
|
|
302
|
-
---
|
|
303
|
-
|
|
304
|
-
## 10. Design principles
|
|
305
|
-
|
|
306
|
-
1. **Thin adapter** — do not reimplement SDK validation or policy in MCP.
|
|
307
|
-
2. **One tool per SDK method** — keep discovery and docs mechanical.
|
|
308
|
-
3. **Honest settlement** — pass through `settlement` fields; never claim on-chain when staged.
|
|
309
|
-
4. **Non-custodial** — prepare tools stop at unsigned calldata.
|
|
310
|
-
5. **Local stdio** — not a multi-tenant public MCP HTTP service.
|
|
311
|
-
6. **Secrets stay out of logs** — formatters must not dump env or Authorization headers.
|
|
312
|
-
7. **Least surprise** — tool names and JSON shapes should match SDK method names closely enough that humans can map them without a glossary.
|
|
313
|
-
|
|
314
|
-
---
|
|
315
|
-
|
|
316
|
-
## 11. Host ownership and vault prepare
|
|
317
|
-
|
|
318
|
-
Hosts declare the command (`npx` / `aureon-mcp`) plus env (`AUREON_API_KEY`, optional Bearer / API URL). The host owns which chats may invoke tools and how humans approve on-chain steps. MCP owns only the child process that answers tool calls.
|
|
319
|
-
|
|
320
|
-
Vault prepare is intentionally incomplete from a settlement perspective:
|
|
321
|
-
|
|
322
|
-
1. Agent calls `aureon_prepare_vault_deposit` or `aureon_prepare_vault_withdraw`.
|
|
323
|
-
2. MCP → SDK → API returns unsigned steps / calldata descriptions.
|
|
324
|
-
3. A human or external signer reviews and broadcasts.
|
|
325
|
-
4. Later reads (`aureon_get_vault`, status tools) reflect chain state once confirmed.
|
|
326
|
-
|
|
327
|
-
MCP never submits signed transactions. That boundary is load-bearing for the security model (see `security.md`).
|
|
328
|
-
|
|
329
|
-
---
|
|
330
|
-
|
|
331
|
-
## 12. FAQ
|
|
332
|
-
|
|
333
|
-
**Is MCP a second API?**
|
|
334
|
-
No. It is a stdio adapter over the same SDK client used by scripts.
|
|
335
|
-
|
|
336
|
-
**Can I run MCP without an issued API key?**
|
|
337
|
-
Only if a valid Bearer is supplied (env or verify/login tools). Issued keys are the recommended agent path.
|
|
338
|
-
|
|
339
|
-
**Where does business logic run?**
|
|
340
|
-
On the hosted API and chain. MCP formats and forwards.
|
|
341
|
-
|
|
342
|
-
**Why Zod if the SDK already validates?**
|
|
343
|
-
Early rejection at the tool boundary improves agent feedback. SDK validation remains authoritative for deeper rules.
|
|
344
|
-
|
|
345
|
-
**Does MCP cache portfolio or health?**
|
|
346
|
-
No long-lived cache. Each tool call hits the SDK/API (subject to normal HTTP behavior).
|
|
347
|
-
|
|
348
|
-
**What happens if the host restarts?**
|
|
349
|
-
The MCP child restarts; in-memory Bearer is lost. Issued key from env is reloaded.
|
|
350
|
-
|
|
351
|
-
**How many tools are there?**
|
|
352
|
-
See `tools/catalog.ts` (`TOOL_COUNT`) and `tools.md`.
|
|
353
|
-
|
|
354
|
-
**Can I expose MCP over the public internet?**
|
|
355
|
-
Do not. The trust model assumes a local host-spawned stdio process.
|
|
356
|
-
|
|
357
|
-
**Where should I put custom agent workflows?**
|
|
358
|
-
In prompts, host rules, or orchestration — not by forking business logic into MCP handlers.
|
|
359
|
-
|
|
360
|
-
**How does this relate to the operator utility?**
|
|
361
|
-
The utility remains a separate wallet-Bearer UI. MCP does not replace it.
|
|
362
|
-
|
|
363
|
-
---
|
|
364
|
-
|
|
365
|
-
## 13. Related documents
|
|
366
|
-
|
|
367
|
-
- [Setup](./setup.md) — install and host configuration patterns
|
|
368
|
-
- [Authentication](./auth.md) — API keys, Bearer handshake, session tools
|
|
369
|
-
- [Tools](./tools.md) — full tool catalog
|
|
370
|
-
- [Agent guide](./agent-guide.md) — recommended call sequences
|
|
371
|
-
- [Security](./security.md) — threat model and operational hygiene
|
|
372
|
-
|
|
373
|
-
---
|
|
374
|
-
|
|
375
|
-
## 14. Summary
|
|
376
|
-
|
|
377
|
-
`@buildaureon/mcp` is a **thin stdio adapter**: Host → MCP handlers/Zod → `@buildaureon/sdk` → `https://api.aureonlabs.network` → vault/chain. Responsibilities are split so agents get a stable tool surface while all financial intelligence and custody boundaries remain outside the MCP process.
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
How `@buildaureon/mcp` sits on top of `@buildaureon/sdk` and the hosted AUREON API.
|
|
4
|
+
|
|
5
|
+
This document is for humans integrating the package and for AI agents that need a stable mental model of layers, ownership, and request flow. It describes the published adapter only: a thin stdio MCP server that forwards tool calls to the SDK. Default API is `https://api.aureonlabs.network` (currently testnet 46630). `AUREON_NETWORK=mainnet` selects chain 4663 on the same official host.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Overview
|
|
10
|
+
|
|
11
|
+
**AUREON** exposes Financial Compass control-plane APIs (objectives, portfolio book, health, restore plans, vault prepare helpers, developer keys). Agents do not need to invent HTTP paths or auth headers when they can call named MCP tools instead.
|
|
12
|
+
|
|
13
|
+
**`@buildaureon/mcp`** is that named surface. It:
|
|
14
|
+
|
|
15
|
+
- Speaks Model Context Protocol over **stdio** to a host (Cursor, Claude Desktop, or any MCP-compatible runner).
|
|
16
|
+
- Validates tool arguments with **Zod** schemas at the handler boundary.
|
|
17
|
+
- Delegates every successful call to **`@buildaureon/sdk`** (`AureonClient`).
|
|
18
|
+
- Formats JSON results and maps SDK errors into short, agent-readable text.
|
|
19
|
+
|
|
20
|
+
It does **not** embed policy math, vault encoding, keeper logic, or chain broadcasting. Those live in the API, the chain contracts, and the operator’s own signing path.
|
|
21
|
+
|
|
22
|
+
### Layer stack
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Host (Cursor / Claude / other MCP host)
|
|
26
|
+
→ MCP JSON-RPC over stdio
|
|
27
|
+
→ mcp handlers + Zod
|
|
28
|
+
→ @buildaureon/sdk HTTP client
|
|
29
|
+
→ https://api.aureonlabs.network (46630 default, or 4663 with AUREON_NETWORK=mainnet)
|
|
30
|
+
→ vault / Robinhood Chain settlement path
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### System context (mermaid)
|
|
34
|
+
|
|
35
|
+
```mermaid
|
|
36
|
+
flowchart TB
|
|
37
|
+
subgraph hosts [MCP_hosts]
|
|
38
|
+
Cursor[Cursor]
|
|
39
|
+
Claude[Claude_Desktop]
|
|
40
|
+
Other[Other_MCP_hosts]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
subgraph mcpPkg ["@buildaureon/mcp"]
|
|
44
|
+
Stdio[StdioServerTransport]
|
|
45
|
+
Registry[McpServer_tool_registry]
|
|
46
|
+
Handlers[Zod_handlers]
|
|
47
|
+
Format[format_and_errors]
|
|
48
|
+
Session[SessionTokenProvider]
|
|
49
|
+
Client[AureonClient_bundle]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
subgraph sdkPkg ["@buildaureon/sdk"]
|
|
53
|
+
HTTP[HTTP_transport]
|
|
54
|
+
Types[Types_and_validation]
|
|
55
|
+
ErrModel[Error_codes]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
API[official_api_aureonlabs_network]
|
|
59
|
+
Vault[Smart_Vault]
|
|
60
|
+
Chain[Robinhood_Chain]
|
|
61
|
+
|
|
62
|
+
Cursor --> Stdio
|
|
63
|
+
Claude --> Stdio
|
|
64
|
+
Other --> Stdio
|
|
65
|
+
Stdio --> Registry
|
|
66
|
+
Registry --> Handlers
|
|
67
|
+
Handlers --> Format
|
|
68
|
+
Handlers --> Client
|
|
69
|
+
Client --> Session
|
|
70
|
+
Client --> HTTP
|
|
71
|
+
HTTP --> Types
|
|
72
|
+
HTTP --> ErrModel
|
|
73
|
+
HTTP --> API
|
|
74
|
+
API --> Vault
|
|
75
|
+
Vault --> Chain
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The MCP binary is a **local adapter**. Hosts spawn it as a child process; it is not intended as a public HTTP gateway.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 2. Responsibility table
|
|
83
|
+
|
|
84
|
+
| Concern | Owner | Notes |
|
|
85
|
+
| --- | --- | --- |
|
|
86
|
+
| Tool names and descriptions | MCP | One tool per public SDK method |
|
|
87
|
+
| Zod argument schemas | MCP | Reject bad shapes before network I/O |
|
|
88
|
+
| Pretty-print JSON for agents | MCP (`format.ts`) | Stable indentation / truncation hygiene |
|
|
89
|
+
| Map SDK errors → text | MCP (`errors.ts`) | Prefer `[CODE] message` form |
|
|
90
|
+
| Env config (`AUREON_*`) | MCP (`config.ts`) | Startup validation |
|
|
91
|
+
| stdio / MCP JSON-RPC | `@modelcontextprotocol/sdk` | Transport + server primitives |
|
|
92
|
+
| HTTPS client, retries, timeouts | SDK | Shared with non-MCP apps |
|
|
93
|
+
| Request/response types | SDK | Canonical TypeScript contracts |
|
|
94
|
+
| Input normalization | SDK | Amounts, ids, enums |
|
|
95
|
+
| Error codes (`UNAUTHORIZED`, …) | SDK | Cross-client consistency |
|
|
96
|
+
| Session token holder | SDK provider + MCP auth tools | Mutable Bearer in-process |
|
|
97
|
+
| Policy engine / restore planning | Hosted API | Not reimplemented in MCP |
|
|
98
|
+
| Vault calldata encoding | Hosted API | Prepare endpoints return unsigned steps |
|
|
99
|
+
| On-chain broadcast / signing | Operator / host wallet | Outside MCP process |
|
|
100
|
+
| Key pause / revoke | API + developer tools | Control-plane lifecycle |
|
|
101
|
+
|
|
102
|
+
Rule of thumb: if a change affects every AUREON client (CLI scripts, bots, MCP), put it in the **SDK or API**. If it only helps agents discover or call the surface, put it in **MCP**.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 3. Request lifecycle
|
|
107
|
+
|
|
108
|
+
### Process start
|
|
109
|
+
|
|
110
|
+
1. Host launches `aureon-mcp` (or `npx -y @buildaureon/mcp`) with environment variables.
|
|
111
|
+
2. `src/index.ts` calls `startServer()` from `server.ts`.
|
|
112
|
+
3. `loadConfig()` uses `resolveAureonNetworkFromEnv()` (default official API / 46630; `AUREON_NETWORK=mainnet` for chain 4663), plus `AUREON_API_KEY` and optional `AUREON_AUTH_TOKEN`.
|
|
113
|
+
4. Startup requires at least one credential: issued API key and/or initial Bearer.
|
|
114
|
+
5. `createClient()` builds a `SessionTokenProvider` and an `AureonClient` bound to that provider.
|
|
115
|
+
6. `registerTools()` attaches the full tool catalog to an `McpServer` instance.
|
|
116
|
+
7. `StdioServerTransport` connects; the process blocks on stdin/stdout until the host exits.
|
|
117
|
+
|
|
118
|
+
### Per tool call
|
|
119
|
+
|
|
120
|
+
```mermaid
|
|
121
|
+
sequenceDiagram
|
|
122
|
+
participant Host as MCP_host
|
|
123
|
+
participant MCP as aureon_mcp
|
|
124
|
+
participant Zod as Zod_schema
|
|
125
|
+
participant SDK as AureonClient
|
|
126
|
+
participant API as AUREON_API
|
|
127
|
+
|
|
128
|
+
Host->>MCP: tools/call name + args
|
|
129
|
+
MCP->>Zod: parse arguments
|
|
130
|
+
alt invalid
|
|
131
|
+
Zod-->>MCP: ZodError
|
|
132
|
+
MCP-->>Host: isError text
|
|
133
|
+
else valid
|
|
134
|
+
MCP->>SDK: matching method
|
|
135
|
+
SDK->>API: HTTPS + auth headers
|
|
136
|
+
alt API / transport failure
|
|
137
|
+
API-->>SDK: error
|
|
138
|
+
SDK-->>MCP: AureonError or Error
|
|
139
|
+
MCP-->>Host: fail mapped text
|
|
140
|
+
else success
|
|
141
|
+
API-->>SDK: JSON body
|
|
142
|
+
SDK-->>MCP: typed result
|
|
143
|
+
MCP-->>Host: ok formatted JSON
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Typical agent loop (restore):
|
|
149
|
+
|
|
150
|
+
1. `aureon_get_health` — detect violation / drift.
|
|
151
|
+
2. `aureon_get_restore_plan` — inspect proposed steps and settlement mode.
|
|
152
|
+
3. `aureon_restore_objective` — execute plan; read `settlement: "vault" | "staged"`.
|
|
153
|
+
4. Optionally `aureon_list_executions` / timeline tools for receipts.
|
|
154
|
+
|
|
155
|
+
Issued API keys travel as `X-Aureon-Api-Key`. Optional wallet Bearer uses `Authorization`. Neither is printed into tool results.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## 4. Tool registration
|
|
160
|
+
|
|
161
|
+
Registration is centralized and domain-split:
|
|
162
|
+
|
|
163
|
+
| Module | Role |
|
|
164
|
+
| --- | --- |
|
|
165
|
+
| `tools/catalog.ts` | Canonical ordered list of tool names / count |
|
|
166
|
+
| `tools/index.ts` | Calls each domain `register*` helper |
|
|
167
|
+
| `tools/handler.ts` | Shared `ok` / `fail` wrappers |
|
|
168
|
+
| `tools/read.ts` | Overview, portfolio read, health, timeline, … |
|
|
169
|
+
| `tools/compass.ts` | Restore plan, restore, executions |
|
|
170
|
+
| `tools/vault.ts` | Vault status + prepare deposit/withdraw |
|
|
171
|
+
| `tools/auth.ts` | Nonce, verify, login, logout, me |
|
|
172
|
+
| `tools/objectives.ts` | Create / update / pause / resume |
|
|
173
|
+
| `tools/portfolio.ts` | Set / clear / sync Capital Book |
|
|
174
|
+
| `tools/market.ts` | Presets, shocks, watchdog |
|
|
175
|
+
| `tools/developer.ts` | List / create / revoke / toggle API keys |
|
|
176
|
+
|
|
177
|
+
Design constraints:
|
|
178
|
+
|
|
179
|
+
1. **One tool per SDK method** — predictable for agents and docs.
|
|
180
|
+
2. **Names are stable** — `aureon_*` prefix; catalog is the source of truth for count.
|
|
181
|
+
3. **Handlers stay thin** — parse → call → format; no second business layer.
|
|
182
|
+
4. **Write tools are explicit** — agents must choose create/restore/prepare; nothing auto-trades.
|
|
183
|
+
|
|
184
|
+
When adding a new SDK method, the MCP checklist is: catalog entry, Zod schema, register helper, docs row in `tools.md`, and a short example in the agent guide if the workflow is non-obvious.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## 5. Session provider
|
|
189
|
+
|
|
190
|
+
`client.ts` wires:
|
|
191
|
+
|
|
192
|
+
```text
|
|
193
|
+
createSessionTokenProvider(initialToken?)
|
|
194
|
+
createAureonClient({ baseUrl, apiKey, getAccessToken })
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Behavior:
|
|
198
|
+
|
|
199
|
+
- **Issued API key** is fixed for the process lifetime (from env). It authenticates the control plane without a wallet handshake.
|
|
200
|
+
- **Bearer token** is mutable. Auth tools (`aureon_verify_wallet`, `aureon_dev_login`) call `session.setToken(...)`. `aureon_logout` clears it.
|
|
201
|
+
- `getAccessToken` is consulted per SDK request so mid-session verify/login takes effect without restarting the host.
|
|
202
|
+
- MCP never persists tokens to disk. Memory only, for the child process lifetime.
|
|
203
|
+
|
|
204
|
+
Recommended production posture: rely on an issued key for agent hosts; use wallet Bearer only when a human-driven verify flow is intentional.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## 6. Error mapping
|
|
209
|
+
|
|
210
|
+
`errors.ts` converts failures into compact strings:
|
|
211
|
+
|
|
212
|
+
| Input | Output shape |
|
|
213
|
+
| --- | --- |
|
|
214
|
+
| SDK `AureonError` | `[CODE] message` |
|
|
215
|
+
| Generic `Error` | `message` |
|
|
216
|
+
| Unknown throw | `String(err)` |
|
|
217
|
+
|
|
218
|
+
Handlers mark tool responses with `isError: true` so hosts surface failures distinctly from JSON payloads.
|
|
219
|
+
|
|
220
|
+
Agents should:
|
|
221
|
+
|
|
222
|
+
- Treat `[UNAUTHORIZED]` / `[FORBIDDEN]` as credential or key-state problems (paused/revoked key, missing Bearer).
|
|
223
|
+
- Treat `[VALIDATION]` as bad arguments — fix inputs, do not retry blindly.
|
|
224
|
+
- Treat transport timeouts as transient; retry read tools carefully, avoid duplicate write tools without idempotency checks.
|
|
225
|
+
|
|
226
|
+
MCP does not invent new error codes. Codes originate in the SDK / API so scripts and agents share vocabulary.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## 7. What lives in SDK vs MCP
|
|
231
|
+
|
|
232
|
+
### Lives in `@buildaureon/sdk`
|
|
233
|
+
|
|
234
|
+
- HTTP transport to the official API (default 46630, or 4663 when `AUREON_NETWORK=mainnet`).
|
|
235
|
+
- Header composition (API key + Bearer).
|
|
236
|
+
- Retries, timeouts, and typed client methods.
|
|
237
|
+
- Shared types for objectives, health, restore plans, vault prepare results.
|
|
238
|
+
- Session token provider factory.
|
|
239
|
+
- Canonical error model (`isAureonError`, codes).
|
|
240
|
+
|
|
241
|
+
### Lives in `@buildaureon/mcp`
|
|
242
|
+
|
|
243
|
+
- Process entry (`index.ts`) and stdio server bootstrap (`server.ts`).
|
|
244
|
+
- Env loading / startup gates (`config.ts`).
|
|
245
|
+
- Client bundle assembly for MCP (`client.ts`).
|
|
246
|
+
- Tool catalog, Zod schemas, domain registration modules.
|
|
247
|
+
- Agent-facing formatting (`format.ts`) and error text (`errors.ts`).
|
|
248
|
+
- Examples of host MCP JSON configs (Cursor / Claude Desktop).
|
|
249
|
+
|
|
250
|
+
### Lives outside both packages
|
|
251
|
+
|
|
252
|
+
- Private keys and hardware wallets.
|
|
253
|
+
- Transaction broadcasting and gas payment.
|
|
254
|
+
- Human approval UX in the host product.
|
|
255
|
+
- Hosted policy engine, keepers, and vault contracts.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## 8. Conceptual file map
|
|
260
|
+
|
|
261
|
+
| Path | Responsibility |
|
|
262
|
+
| --- | --- |
|
|
263
|
+
| `src/index.ts` | CLI / bin entry — starts the server |
|
|
264
|
+
| `src/server.ts` | Config → client → register tools → stdio connect |
|
|
265
|
+
| `src/config.ts` | Parse and validate `AUREON_*` env |
|
|
266
|
+
| `src/client.ts` | `AureonClient` + `SessionTokenProvider` bundle |
|
|
267
|
+
| `src/errors.ts` | SDK / unknown → agent-readable text |
|
|
268
|
+
| `src/format.ts` | JSON formatting for tool results |
|
|
269
|
+
| `src/tools/catalog.ts` | Ordered tool names and `TOOL_COUNT` |
|
|
270
|
+
| `src/tools/handler.ts` | Shared success / failure response helpers |
|
|
271
|
+
| `src/tools/index.ts` | Registers all domains onto `McpServer` |
|
|
272
|
+
| `src/tools/read.ts` | Read-mostly control-plane queries |
|
|
273
|
+
| `src/tools/compass.ts` | Restore plan and execution surface |
|
|
274
|
+
| `src/tools/vault.ts` | Vault reads + unsigned prepare helpers |
|
|
275
|
+
| `src/tools/auth.ts` | Auth handshake + session mutation |
|
|
276
|
+
| `src/tools/objectives.ts` | Objective lifecycle writes |
|
|
277
|
+
| `src/tools/portfolio.ts` | Capital Book mutations / sync |
|
|
278
|
+
| `src/tools/market.ts` | Market presets, events, watchdog |
|
|
279
|
+
| `src/tools/developer.ts` | Issued API key management |
|
|
280
|
+
|
|
281
|
+
Supporting package docs (`setup`, `auth`, `tools`, `agent-guide`, `security`) describe usage; this file describes structure.
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## 9. Versioning
|
|
286
|
+
|
|
287
|
+
| Artifact | Version meaning |
|
|
288
|
+
| --- | --- |
|
|
289
|
+
| `@buildaureon/mcp` package version | Adapter release (tool catalog, schemas, formatting) |
|
|
290
|
+
| MCP server `version` field | Mirrors package version reported to hosts |
|
|
291
|
+
| `@buildaureon/sdk` dependency | Protocol / client contract with the API |
|
|
292
|
+
| Public API `api.aureonlabs.network` | Server-side behavior on **testnet 46630**; may evolve independently |
|
|
293
|
+
|
|
294
|
+
Compatibility expectations:
|
|
295
|
+
|
|
296
|
+
- **Patch** MCP releases: formatting, docs, defensive validation — no tool renames.
|
|
297
|
+
- **Minor** MCP releases: new tools mirroring new SDK methods; existing names stay.
|
|
298
|
+
- **Major** MCP releases: breaking tool renames or required auth model changes (rare; documented in release notes).
|
|
299
|
+
|
|
300
|
+
Agents should pin a known MCP package version in host config when reproducibility matters. Prefer matching SDK majors that the MCP release was tested against.
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## 10. Design principles
|
|
305
|
+
|
|
306
|
+
1. **Thin adapter** — do not reimplement SDK validation or policy in MCP.
|
|
307
|
+
2. **One tool per SDK method** — keep discovery and docs mechanical.
|
|
308
|
+
3. **Honest settlement** — pass through `settlement` fields; never claim on-chain when staged.
|
|
309
|
+
4. **Non-custodial** — prepare tools stop at unsigned calldata.
|
|
310
|
+
5. **Local stdio** — not a multi-tenant public MCP HTTP service.
|
|
311
|
+
6. **Secrets stay out of logs** — formatters must not dump env or Authorization headers.
|
|
312
|
+
7. **Least surprise** — tool names and JSON shapes should match SDK method names closely enough that humans can map them without a glossary.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## 11. Host ownership and vault prepare
|
|
317
|
+
|
|
318
|
+
Hosts declare the command (`npx` / `aureon-mcp`) plus env (`AUREON_API_KEY`, optional Bearer / API URL). The host owns which chats may invoke tools and how humans approve on-chain steps. MCP owns only the child process that answers tool calls.
|
|
319
|
+
|
|
320
|
+
Vault prepare is intentionally incomplete from a settlement perspective:
|
|
321
|
+
|
|
322
|
+
1. Agent calls `aureon_prepare_vault_deposit` or `aureon_prepare_vault_withdraw`.
|
|
323
|
+
2. MCP → SDK → API returns unsigned steps / calldata descriptions.
|
|
324
|
+
3. A human or external signer reviews and broadcasts.
|
|
325
|
+
4. Later reads (`aureon_get_vault`, status tools) reflect chain state once confirmed.
|
|
326
|
+
|
|
327
|
+
MCP never submits signed transactions. That boundary is load-bearing for the security model (see `security.md`).
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## 12. FAQ
|
|
332
|
+
|
|
333
|
+
**Is MCP a second API?**
|
|
334
|
+
No. It is a stdio adapter over the same SDK client used by scripts.
|
|
335
|
+
|
|
336
|
+
**Can I run MCP without an issued API key?**
|
|
337
|
+
Only if a valid Bearer is supplied (env or verify/login tools). Issued keys are the recommended agent path.
|
|
338
|
+
|
|
339
|
+
**Where does business logic run?**
|
|
340
|
+
On the hosted API and chain. MCP formats and forwards.
|
|
341
|
+
|
|
342
|
+
**Why Zod if the SDK already validates?**
|
|
343
|
+
Early rejection at the tool boundary improves agent feedback. SDK validation remains authoritative for deeper rules.
|
|
344
|
+
|
|
345
|
+
**Does MCP cache portfolio or health?**
|
|
346
|
+
No long-lived cache. Each tool call hits the SDK/API (subject to normal HTTP behavior).
|
|
347
|
+
|
|
348
|
+
**What happens if the host restarts?**
|
|
349
|
+
The MCP child restarts; in-memory Bearer is lost. Issued key from env is reloaded.
|
|
350
|
+
|
|
351
|
+
**How many tools are there?**
|
|
352
|
+
See `tools/catalog.ts` (`TOOL_COUNT`) and `tools.md`.
|
|
353
|
+
|
|
354
|
+
**Can I expose MCP over the public internet?**
|
|
355
|
+
Do not. The trust model assumes a local host-spawned stdio process.
|
|
356
|
+
|
|
357
|
+
**Where should I put custom agent workflows?**
|
|
358
|
+
In prompts, host rules, or orchestration — not by forking business logic into MCP handlers.
|
|
359
|
+
|
|
360
|
+
**How does this relate to the operator utility?**
|
|
361
|
+
The utility remains a separate wallet-Bearer UI. MCP does not replace it.
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## 13. Related documents
|
|
366
|
+
|
|
367
|
+
- [Setup](./setup.md) — install and host configuration patterns
|
|
368
|
+
- [Authentication](./auth.md) — API keys, Bearer handshake, session tools
|
|
369
|
+
- [Tools](./tools.md) — full tool catalog
|
|
370
|
+
- [Agent guide](./agent-guide.md) — recommended call sequences
|
|
371
|
+
- [Security](./security.md) — threat model and operational hygiene
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## 14. Summary
|
|
376
|
+
|
|
377
|
+
`@buildaureon/mcp` is a **thin stdio adapter**: Host → MCP handlers/Zod → `@buildaureon/sdk` → official API (`https://api.aureonlabs.network`) → vault/chain. Responsibilities are split so agents get a stable tool surface while all financial intelligence and custody boundaries remain outside the MCP process.
|