@aura-payments/mcp-server 1.0.0

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/dist/index.js ADDED
@@ -0,0 +1,562 @@
1
+ 'use strict';
2
+
3
+ var mcp_js = require('@modelcontextprotocol/sdk/server/mcp.js');
4
+ var sdk = require('@aura-payments/sdk');
5
+ var zod = require('zod');
6
+
7
+ // src/index.ts
8
+ var cached = null;
9
+ function getClient() {
10
+ if (cached) return cached;
11
+ const apiKey = process.env.AURA_API_KEY;
12
+ if (!apiKey) {
13
+ throw new MissingAuraApiKeyError();
14
+ }
15
+ cached = new sdk.AuraClient({
16
+ apiKey,
17
+ baseUrl: process.env.AURA_BASE_URL,
18
+ // Honor caller's preference; default to SDK default (auto on POST/PUT)
19
+ autoIdempotency: process.env.AURA_AUTO_IDEMPOTENCY !== "false"
20
+ });
21
+ return cached;
22
+ }
23
+ var MissingAuraApiKeyError = class extends Error {
24
+ constructor() {
25
+ super(
26
+ 'AURA_API_KEY not set. Configure it in your MCP client config \u2014 for example in mcp.json: { "mcpServers": { "aura": { "command": "aura-mcp", "env": { "AURA_API_KEY": "pk_live_..." } } } }. Get a key at https://getaura.sh.'
27
+ );
28
+ this.name = "MissingAuraApiKeyError";
29
+ }
30
+ };
31
+
32
+ // src/resources/agents.ts
33
+ function registerAgentResources(server) {
34
+ server.resource(
35
+ "agent",
36
+ new mcp_js.ResourceTemplate("aura://agents/{id}", { list: void 0 }),
37
+ async (uri, { id }) => {
38
+ const client = getClient();
39
+ const agent = await client.agents.get(String(id));
40
+ return {
41
+ contents: [
42
+ {
43
+ uri: uri.href,
44
+ mimeType: "application/json",
45
+ text: JSON.stringify(agent, null, 2)
46
+ }
47
+ ]
48
+ };
49
+ }
50
+ );
51
+ server.resource(
52
+ "agent-balance",
53
+ new mcp_js.ResourceTemplate("aura://agents/{id}/balance", { list: void 0 }),
54
+ async (uri, { id }) => {
55
+ const client = getClient();
56
+ const balance = await client.agents.getBalance(String(id));
57
+ return {
58
+ contents: [
59
+ {
60
+ uri: uri.href,
61
+ mimeType: "application/json",
62
+ text: JSON.stringify(balance, null, 2)
63
+ }
64
+ ]
65
+ };
66
+ }
67
+ );
68
+ }
69
+ function registerMandateResources(server) {
70
+ server.resource(
71
+ "mandates-pending",
72
+ "aura://mandates/pending",
73
+ async (uri) => {
74
+ const client = getClient();
75
+ const page = await client.mandates.listPending({ limit: 50 });
76
+ return {
77
+ contents: [
78
+ {
79
+ uri: uri.href,
80
+ mimeType: "application/json",
81
+ text: JSON.stringify(page, null, 2)
82
+ }
83
+ ]
84
+ };
85
+ }
86
+ );
87
+ server.resource(
88
+ "mandate",
89
+ new mcp_js.ResourceTemplate("aura://mandates/{id}", { list: void 0 }),
90
+ async (uri, { id }) => {
91
+ const client = getClient();
92
+ const mandate = await client.mandates.get(String(id));
93
+ return {
94
+ contents: [
95
+ {
96
+ uri: uri.href,
97
+ mimeType: "application/json",
98
+ text: JSON.stringify(mandate, null, 2)
99
+ }
100
+ ]
101
+ };
102
+ }
103
+ );
104
+ }
105
+ async function withToolErrorHandling(body, successFormatter = defaultJsonFormatter) {
106
+ try {
107
+ const result = await body();
108
+ return {
109
+ content: [{ type: "text", text: successFormatter(result) }]
110
+ };
111
+ } catch (err) {
112
+ return formatError(err);
113
+ }
114
+ }
115
+ function defaultJsonFormatter(data) {
116
+ return JSON.stringify(data, null, 2);
117
+ }
118
+ function formatError(err) {
119
+ if (err instanceof MissingAuraApiKeyError) {
120
+ return errorResult("CONFIG_ERROR", err.message);
121
+ }
122
+ if (err instanceof sdk.AuraAuthenticationError) {
123
+ return errorResult(
124
+ "AUTH_ERROR",
125
+ `Authentication failed: ${err.message}. Check that AURA_API_KEY is correct and not revoked.`
126
+ );
127
+ }
128
+ if (err instanceof sdk.AuraNotFoundError) {
129
+ return errorResult("NOT_FOUND", err.message);
130
+ }
131
+ if (err instanceof sdk.AuraValidationError) {
132
+ return errorResult("VALIDATION_ERROR", err.message);
133
+ }
134
+ if (err instanceof sdk.AuraRateLimitError) {
135
+ return errorResult(
136
+ "RATE_LIMITED",
137
+ `Rate limited. ${err.retryAfter ? `Retry after ${err.retryAfter}s.` : "Back off and retry."}`
138
+ );
139
+ }
140
+ if (err instanceof sdk.AuraTimeoutError) {
141
+ return errorResult("TIMEOUT", err.message);
142
+ }
143
+ if (err instanceof sdk.AuraAPIError) {
144
+ return errorResult(`API_ERROR_${err.statusCode}`, err.message);
145
+ }
146
+ if (err instanceof sdk.AuraError) {
147
+ return errorResult(err.code || "AURA_ERROR", err.message);
148
+ }
149
+ if (err instanceof Error) {
150
+ return errorResult("UNKNOWN_ERROR", err.message);
151
+ }
152
+ return errorResult("UNKNOWN_ERROR", String(err));
153
+ }
154
+ function errorResult(code, message) {
155
+ return {
156
+ isError: true,
157
+ content: [
158
+ {
159
+ type: "text",
160
+ text: `errorCode: ${code}
161
+ message: ${message}`
162
+ }
163
+ ]
164
+ };
165
+ }
166
+ function toolError(code, message) {
167
+ return errorResult(code, message);
168
+ }
169
+
170
+ // src/tools/agents.ts
171
+ var ChainSchema = zod.z.enum(["ARC", "ARB", "BASE", "ETH", "MATIC"]);
172
+ var SpendingLimitSchema = zod.z.object({
173
+ limitType: zod.z.enum([
174
+ "per_transaction",
175
+ "daily",
176
+ "weekly",
177
+ "monthly",
178
+ "lifetime"
179
+ ]),
180
+ maxAmount: zod.z.string().describe("Whole-number USDC amount as a string"),
181
+ currency: zod.z.string().optional().default("USDC")
182
+ });
183
+ var MerchantRuleSchema = zod.z.object({
184
+ ruleType: zod.z.enum(["allowlist", "blocklist"]),
185
+ destinationType: zod.z.enum(["address", "domain", "category", "entity_id"]),
186
+ destinationValue: zod.z.string().min(1)
187
+ });
188
+ function registerAgentTools(server) {
189
+ server.tool(
190
+ "aura_create_agent",
191
+ "Create a new AI agent with a dedicated wallet and optional initial spending policy. The wallet is provisioned on-chain during this call (a few seconds latency).",
192
+ {
193
+ name: zod.z.string().min(1).max(100),
194
+ description: zod.z.string().max(500).optional(),
195
+ type: zod.z.enum(["treasury", "payment", "trading", "custom"]),
196
+ chain: ChainSchema.optional().default("ARC"),
197
+ metadata: zod.z.record(zod.z.unknown()).optional(),
198
+ initialPolicy: zod.z.object({
199
+ name: zod.z.string().optional(),
200
+ description: zod.z.string().optional(),
201
+ spendingLimits: zod.z.array(SpendingLimitSchema).optional(),
202
+ merchantRules: zod.z.array(MerchantRuleSchema).optional(),
203
+ requiresApprovalAbove: zod.z.string().optional(),
204
+ autoApproveBelow: zod.z.string().optional()
205
+ }).optional()
206
+ },
207
+ async (args) => withToolErrorHandling(async () => {
208
+ const client = getClient();
209
+ return client.agents.create(args);
210
+ })
211
+ );
212
+ server.tool(
213
+ "aura_list_agents",
214
+ "List agents for the authenticated account, paginated. Filter by status or type.",
215
+ {
216
+ status: zod.z.enum(["active", "paused", "archived"]).optional(),
217
+ type: zod.z.enum(["treasury", "payment", "trading", "custom"]).optional(),
218
+ limit: zod.z.number().int().min(1).max(200).optional(),
219
+ offset: zod.z.number().int().min(0).optional()
220
+ },
221
+ async (args) => withToolErrorHandling(async () => {
222
+ const client = getClient();
223
+ return client.agents.list(args);
224
+ })
225
+ );
226
+ server.tool(
227
+ "aura_get_agent",
228
+ "Get a single agent by id with its current status, wallet, and recent activity.",
229
+ {
230
+ agentId: zod.z.string().uuid()
231
+ },
232
+ async ({ agentId }) => withToolErrorHandling(async () => {
233
+ const client = getClient();
234
+ return client.agents.get(agentId);
235
+ })
236
+ );
237
+ server.tool(
238
+ "aura_get_agent_balance",
239
+ "Get the current USDC balance of an agent's wallet (on-chain at request time).",
240
+ {
241
+ agentId: zod.z.string().uuid()
242
+ },
243
+ async ({ agentId }) => withToolErrorHandling(async () => {
244
+ const client = getClient();
245
+ return client.agents.getBalance(agentId);
246
+ })
247
+ );
248
+ server.tool(
249
+ "aura_freeze_agent",
250
+ "Kill switch \u2014 halt all autonomous activity for an agent. Sets status=paused AND auto-rejects every pending mandate the agent has in flight. Idempotent.",
251
+ {
252
+ agentId: zod.z.string().uuid(),
253
+ reason: zod.z.string().max(500).optional().describe("Surfaced in activity event metadata for audit trail")
254
+ },
255
+ async (args) => withToolErrorHandling(async () => {
256
+ const client = getClient();
257
+ return client.agents.freeze(args);
258
+ })
259
+ );
260
+ server.tool(
261
+ "aura_unfreeze_agent",
262
+ "Resume autonomous activity for a frozen agent (status -> active). Previously cascade-rejected mandates are NOT restored \u2014 the agent re-creates them on its next loop.",
263
+ {
264
+ agentId: zod.z.string().uuid()
265
+ },
266
+ async (args) => withToolErrorHandling(async () => {
267
+ const client = getClient();
268
+ return client.agents.unfreeze(args);
269
+ })
270
+ );
271
+ server.tool(
272
+ "aura_evaluate_policy",
273
+ "Run a hypothetical transaction through the policy engine WITHOUT executing it. Returns the decision (auto_approve / auto_deny / requires_human_approval) and which rules matched. When the decision requires human approval, a mandate row is created and its id is returned.",
274
+ {
275
+ agentId: zod.z.string().uuid(),
276
+ amount: zod.z.string().describe("USDC amount as decimal string"),
277
+ destination: zod.z.string().describe("Counterparty wallet (0x...) or merchant identifier"),
278
+ destinationType: zod.z.enum(["address", "domain", "category", "entity_id"]).optional(),
279
+ reasoning: zod.z.string().optional(),
280
+ metadata: zod.z.record(zod.z.unknown()).optional()
281
+ },
282
+ async (args) => withToolErrorHandling(async () => {
283
+ const client = getClient();
284
+ return client.agents.evaluate(args);
285
+ })
286
+ );
287
+ }
288
+ var ChainSchema2 = zod.z.enum(["ARC", "ARB", "BASE", "ETH", "MATIC"]);
289
+ var SplitInputSchema = zod.z.object({
290
+ ownerType: zod.z.enum([
291
+ "buyer",
292
+ "seller",
293
+ "platform",
294
+ "vendor",
295
+ "creator",
296
+ "affiliate",
297
+ "logistics",
298
+ "tax"
299
+ ]),
300
+ ownerId: zod.z.string().uuid(),
301
+ role: zod.z.enum([
302
+ "seller",
303
+ "platform",
304
+ "vendor",
305
+ "creator",
306
+ "affiliate",
307
+ "logistics",
308
+ "tax"
309
+ ]),
310
+ percentage: zod.z.number().min(0).max(100)
311
+ });
312
+ function registerEscrowTools(server) {
313
+ server.tool(
314
+ "aura_create_escrow",
315
+ "Create a new escrow with payment splits across vendor/platform/seller wallets. Default chain is ARC. Async by default \u2014 returns an escrowId immediately while contract deployment continues in background.",
316
+ {
317
+ orderId: zod.z.string().describe("Caller-provided order id, unique per account"),
318
+ buyerOwnerId: zod.z.string().uuid().describe("UUID of the buyer in the platform"),
319
+ amount: zod.z.string().describe('Whole-number USDC amount as a string (e.g. "100" for $100)'),
320
+ chain: ChainSchema2.optional().describe("Target chain. Defaults to ARC"),
321
+ splits: zod.z.array(SplitInputSchema).min(1).describe("Payment splits. Percentages must sum to 100.")
322
+ },
323
+ async (args) => withToolErrorHandling(async () => {
324
+ const client = getClient();
325
+ return client.escrows.create(args);
326
+ })
327
+ );
328
+ server.tool(
329
+ "aura_get_escrow",
330
+ "Get the current state of an escrow by id, including splits and on-chain deployment status.",
331
+ {
332
+ escrowId: zod.z.string().uuid()
333
+ },
334
+ async ({ escrowId }) => withToolErrorHandling(async () => {
335
+ const client = getClient();
336
+ return client.escrows.get(escrowId);
337
+ })
338
+ );
339
+ server.tool(
340
+ "aura_list_escrows",
341
+ "List escrows for the authenticated account, optionally filtered by state. Returns paginated results.",
342
+ {
343
+ state: zod.z.enum([
344
+ "initiated",
345
+ "deployed",
346
+ "funded",
347
+ "locked",
348
+ "released",
349
+ "refunded",
350
+ "disputed",
351
+ "all"
352
+ ]).optional(),
353
+ sortBy: zod.z.enum(["created_desc", "created_asc", "amount_desc", "amount_asc"]).optional(),
354
+ search: zod.z.string().optional(),
355
+ limit: zod.z.number().int().min(1).max(200).optional(),
356
+ offset: zod.z.number().int().min(0).optional()
357
+ },
358
+ async (args) => withToolErrorHandling(async () => {
359
+ const client = getClient();
360
+ return client.escrows.list(args);
361
+ })
362
+ );
363
+ server.tool(
364
+ "aura_fund_escrow",
365
+ "Fund an existing escrow from the buyer wallet. Once funded, the escrow can be released (after unlock conditions) or refunded.",
366
+ {
367
+ escrowId: zod.z.string().uuid(),
368
+ buyerWalletId: zod.z.string().uuid(),
369
+ amount: zod.z.string().describe("USDC amount to fund (whole-number string)"),
370
+ correlationId: zod.z.string().optional()
371
+ },
372
+ async (args) => withToolErrorHandling(async () => {
373
+ const client = getClient();
374
+ return client.escrows.fund(args);
375
+ })
376
+ );
377
+ server.tool(
378
+ "aura_release_escrow",
379
+ "Release a funded escrow to the recipients per the original splits. Requires the unlock conditions to be met (or manual override with actorId).",
380
+ {
381
+ escrowId: zod.z.string().uuid(),
382
+ actorId: zod.z.string().uuid().describe("UUID of the user/agent performing the release"),
383
+ reason: zod.z.string().optional(),
384
+ correlationId: zod.z.string().optional()
385
+ },
386
+ async (args) => withToolErrorHandling(async () => {
387
+ const client = getClient();
388
+ return client.escrows.release(args);
389
+ })
390
+ );
391
+ server.tool(
392
+ "aura_refund_escrow",
393
+ "Refund a funded escrow back to the buyer. Requires a reason (audit trail).",
394
+ {
395
+ escrowId: zod.z.string().uuid(),
396
+ reason: zod.z.string().min(10),
397
+ actorId: zod.z.string().uuid()
398
+ },
399
+ async (args) => withToolErrorHandling(async () => {
400
+ const client = getClient();
401
+ return client.escrows.refund(args);
402
+ })
403
+ );
404
+ server.tool(
405
+ "aura_receive_and_split",
406
+ 'Receive USDC and split it to recipients in ONE call \u2014 composes escrow create\u2192fund\u2192release. The payer (payerOwnerId) may be the agent itself (splitting funds it holds) or a counterparty; funds move from that party\'s Aura wallet. Returns a `stage` (created|deployed|funded|released): if it stops at "deployed" with `fundingRequired`, fund that wallet (e.g. aura_request_testnet_funds) and retry. Testnet only.',
407
+ {
408
+ orderId: zod.z.string().describe("Caller-provided order id, unique per account"),
409
+ payerOwnerId: zod.z.string().describe("Entity that funds the escrow (the agent itself or a counterparty)"),
410
+ amount: zod.z.string().describe('Whole-number USDC amount as a string (e.g. "50"). Each split must net \u2265 $1 after fees.'),
411
+ splits: zod.z.array(SplitInputSchema).min(1).describe("Payment splits. Percentages must sum to 100."),
412
+ chain: zod.z.enum(["ARC", "ARB", "BASE"]).optional().describe("Testnet chain. Defaults to ARC."),
413
+ actorId: zod.z.string().optional().describe("Actor recorded on release. Defaults to payerOwnerId."),
414
+ autoRelease: zod.z.boolean().optional().describe("Release immediately after funding. Default true."),
415
+ waitForDeploymentMs: zod.z.number().int().min(0).optional().describe("Max ms to wait for on-chain deployment. Default 60000."),
416
+ waitForFundingMs: zod.z.number().int().min(0).optional().describe("Max ms to wait for funds to settle (funded/locked) before releasing. Default 60000.")
417
+ },
418
+ async (args) => withToolErrorHandling(async () => {
419
+ const client = getClient();
420
+ return client.escrows.receiveAndSplit(args);
421
+ })
422
+ );
423
+ }
424
+ function registerMandateTools(server) {
425
+ server.tool(
426
+ "aura_list_mandates",
427
+ "List mandates for the authenticated account. Defaults to status=pending so it acts as the operator's inbox by default. Most-urgent (soonest-expiring) first.",
428
+ {
429
+ status: zod.z.enum(["pending", "approved", "rejected", "cancelled"]).optional().default("pending"),
430
+ agentId: zod.z.string().uuid().optional(),
431
+ limit: zod.z.number().int().min(1).max(200).optional(),
432
+ cursor: zod.z.string().uuid().optional().describe("Last mandate id from the previous page")
433
+ },
434
+ async (args) => withToolErrorHandling(async () => {
435
+ const client = getClient();
436
+ return client.mandates.list(args);
437
+ })
438
+ );
439
+ server.tool(
440
+ "aura_get_mandate",
441
+ "Get a single mandate by id, including its full intent payload (the action the agent wants to take), expiry, and decision history.",
442
+ {
443
+ mandateId: zod.z.string().uuid()
444
+ },
445
+ async ({ mandateId }) => withToolErrorHandling(async () => {
446
+ const client = getClient();
447
+ return client.mandates.get(mandateId);
448
+ })
449
+ );
450
+ server.tool(
451
+ "aura_approve_mandate",
452
+ "Approve a pending mandate. The decisionSignature MUST be precomputed by the caller (HMAC-SHA256 over `${mandateId}:approve:${decidedAt}`) \u2014 the LLM should never see the HMAC secret. Use the CLI or mobile app to compute it. Idempotent: re-approving an already-approved mandate returns the existing decision.",
453
+ {
454
+ mandateId: zod.z.string().uuid(),
455
+ decisionMethod: zod.z.enum(["biometric", "passcode", "manual"]),
456
+ decisionSignature: zod.z.string().min(16).describe("HMAC-SHA256 hex digest, computed by the caller"),
457
+ decidedAt: zod.z.string().datetime().optional().describe('ISO-8601 timestamp the signature commits to. Defaults to "now" server-side.')
458
+ },
459
+ async (args) => withToolErrorHandling(async () => {
460
+ const client = getClient();
461
+ return client.mandates.approve(args);
462
+ })
463
+ );
464
+ server.tool(
465
+ "aura_reject_mandate",
466
+ "Reject a pending mandate. Same signature scheme as approve \u2014 caller computes it, LLM forwards.",
467
+ {
468
+ mandateId: zod.z.string().uuid(),
469
+ decisionMethod: zod.z.enum(["biometric", "passcode", "manual"]),
470
+ decisionSignature: zod.z.string().min(16),
471
+ decidedAt: zod.z.string().datetime().optional(),
472
+ reason: zod.z.string().optional().describe("Human-readable reason logged to the activity feed")
473
+ },
474
+ async (args) => withToolErrorHandling(async () => {
475
+ const client = getClient();
476
+ return client.mandates.reject(args);
477
+ })
478
+ );
479
+ }
480
+ var TestnetChainSchema = zod.z.enum(["ARC", "ARB", "BASE"]);
481
+ function walletCreateEnabled() {
482
+ const v = (process.env.AURA_MCP_ALLOW_WALLET_CREATE ?? "").trim().toLowerCase();
483
+ return v === "1" || v === "true" || v === "yes";
484
+ }
485
+ function registerWalletTools(server) {
486
+ server.tool(
487
+ "aura_get_wallet_balance",
488
+ "Get a wallet's current USDC balance (on-chain at request time).",
489
+ {
490
+ walletId: zod.z.string().uuid()
491
+ },
492
+ async ({ walletId }) => withToolErrorHandling(async () => {
493
+ const client = getClient();
494
+ return client.wallets.getBalance(walletId);
495
+ })
496
+ );
497
+ server.tool(
498
+ "aura_create_wallet",
499
+ "Provision (create-or-get) a wallet to RECEIVE USDC into. Idempotent and moves no money. Testnet only. Disabled unless the host sets AURA_MCP_ALLOW_WALLET_CREATE=1.",
500
+ {
501
+ entityId: zod.z.string().min(1).describe("Your unique identifier for the wallet owner (e.g. the agent id)"),
502
+ chain: TestnetChainSchema.optional().describe("Testnet chain. Defaults to ARC."),
503
+ type: zod.z.enum([
504
+ "BUSINESS",
505
+ "buyer",
506
+ "seller",
507
+ "platform",
508
+ "vendor",
509
+ "creator",
510
+ "affiliate",
511
+ "logistics",
512
+ "tax"
513
+ ]).optional().describe("Wallet owner type. Defaults to BUSINESS.")
514
+ },
515
+ async ({ entityId, chain, type }) => {
516
+ if (!walletCreateEnabled()) {
517
+ return toolError(
518
+ "WALLET_CREATE_DISABLED",
519
+ "Wallet creation is disabled on this MCP host. Set AURA_MCP_ALLOW_WALLET_CREATE=1 in the server env to enable it, or create the wallet via the Aura CLI (`aura wallet create`) or SDK."
520
+ );
521
+ }
522
+ return withToolErrorHandling(async () => {
523
+ const client = getClient();
524
+ return client.wallets.create({ entityId, chain, type });
525
+ });
526
+ }
527
+ );
528
+ server.tool(
529
+ "aura_request_testnet_funds",
530
+ "Request testnet USDC for a wallet from the platform faucet (testnet only). Drips are async \u2014 balance reflects after a few seconds. Returns FAUCET_UNAVAILABLE if the deployment has no faucet enabled.",
531
+ {
532
+ walletId: zod.z.string().uuid(),
533
+ token: zod.z.string().optional().describe("Token to drip. Defaults to 'USDC'."),
534
+ chain: TestnetChainSchema.optional().describe("Override the wallet's chain.")
535
+ },
536
+ async ({ walletId, token, chain }) => withToolErrorHandling(async () => {
537
+ const client = getClient();
538
+ return client.wallets.requestTestnetFunds(walletId, { token, chain });
539
+ })
540
+ );
541
+ }
542
+
543
+ // src/index.ts
544
+ function createServer(options = {}) {
545
+ const server = new mcp_js.McpServer({
546
+ name: options.name ?? "aura-payments",
547
+ version: options.version ?? "1.0.0"
548
+ });
549
+ registerEscrowTools(server);
550
+ registerAgentTools(server);
551
+ registerMandateTools(server);
552
+ registerWalletTools(server);
553
+ registerAgentResources(server);
554
+ registerMandateResources(server);
555
+ return server;
556
+ }
557
+
558
+ exports.MissingAuraApiKeyError = MissingAuraApiKeyError;
559
+ exports.createServer = createServer;
560
+ exports.getClient = getClient;
561
+ //# sourceMappingURL=index.js.map
562
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts","../src/resources/agents.ts","../src/resources/mandates.ts","../src/errors.ts","../src/tools/agents.ts","../src/tools/escrows.ts","../src/tools/mandates.ts","../src/tools/wallets.ts","../src/index.ts"],"names":["AuraClient","ResourceTemplate","AuraAuthenticationError","AuraNotFoundError","AuraValidationError","AuraRateLimitError","AuraTimeoutError","AuraAPIError","AuraError","z","ChainSchema","McpServer"],"mappings":";;;;;;;AAYA,IAAI,MAAA,GAA4B,IAAA;AAEzB,SAAS,SAAA,GAAwB;AACtC,EAAA,IAAI,QAAQ,OAAO,MAAA;AACnB,EAAA,MAAM,MAAA,GAAS,QAAQ,GAAA,CAAI,YAAA;AAC3B,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,sBAAA,EAAuB;AAAA,EACnC;AACA,EAAA,MAAA,GAAS,IAAIA,cAAA,CAAW;AAAA,IACtB,MAAA;AAAA,IACA,OAAA,EAAS,QAAQ,GAAA,CAAI,aAAA;AAAA;AAAA,IAErB,eAAA,EAAiB,OAAA,CAAQ,GAAA,CAAI,qBAAA,KAA0B;AAAA,GACxD,CAAA;AACD,EAAA,OAAO,MAAA;AACT;AAEO,IAAM,sBAAA,GAAN,cAAqC,KAAA,CAAM;AAAA,EAChD,WAAA,GAAc;AACZ,IAAA,KAAA;AAAA,MACE;AAAA,KAIF;AACA,IAAA,IAAA,CAAK,IAAA,GAAO,wBAAA;AAAA,EACd;AACF;;;ACvBO,SAAS,uBAAuB,MAAA,EAAyB;AAC9D,EAAA,MAAA,CAAO,QAAA;AAAA,IACL,OAAA;AAAA,IACA,IAAIC,uBAAA,CAAiB,oBAAA,EAAsB,EAAE,IAAA,EAAM,QAAW,CAAA;AAAA,IAC9D,OAAO,GAAA,EAAK,EAAE,EAAA,EAAG,KAAM;AACrB,MAAA,MAAM,SAAS,SAAA,EAAU;AACzB,MAAA,MAAM,QAAQ,MAAM,MAAA,CAAO,OAAO,GAAA,CAAI,MAAA,CA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AAK;AAAA,MAC1B,OAAOA,KAAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,oCAAoC,CAAA;AAAA,MAC1E,KAAA,EAAO,kBAAA,CAAmB,QAAA,EAAS,CAAE,SAAS,8BAA8B;AAAA,KAC9E;AAAA,IACA,OAAO,EAAE,QAAA,EAAU,OAAO,KAAA,EAAM,KAC9B,sBAAsB,YAAY;AAChC,MAAA,MAAM,SAAS,SAAA,EAAU;AACzB,MAAA,OAAO,OAAO,OAAA,CAAQ,mBAAA,CAAoB,UAAU,EAAE,KAAA,EAAO,OAAO,CAAA;AAAA,IACtE,CAAC;AAAA,GACL;AACF;;;AChEO,SAAS,YAAA,CAAa,OAAA,GAA+B,EAAC,EAAc;AACzE,EAAA,MAAM,MAAA,GAAS,IAAIE,gBAAA,CAAU;AAAA,IAC3B,IAAA,EAAM,QAAQ,IAAA,IAAQ,eAAA;AAAA,IACtB,OAAA,EAAS,QAAQ,OAAA,IAAW;AAAA,GAC7B,CAAA;AAGD,EAAA,mBAAA,CAAoB,MAAM,CAAA;AAC1B,EAAA,kBAAA,CAAmB,MAAM,CAAA;AACzB,EAAA,oBAAA,CAAqB,MAAM,CAAA;AAC3B,EAAA,mBAAA,CAAoB,MAAM,CAAA;AAG1B,EAAA,sBAAA,CAAuB,MAAM,CAAA;AAC7B,EAAA,wBAAA,CAAyB,MAAM,CAAA;AAE/B,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["/**\n * Aura SDK client factory for the MCP server.\n *\n * Reads `AURA_API_KEY` and (optionally) `AURA_BASE_URL` from the environment\n * the MCP host launched us in (Claude Desktop / Cursor / etc. inject env via\n * the `env` field in mcp.json). The client is created lazily on first tool\n * invocation so missing env doesn't crash the server during the MCP handshake\n * — instead, the FIRST tool call returns a clear error the LLM can act on.\n */\n\nimport { AuraClient } from '@aura-payments/sdk'\n\nlet cached: AuraClient | null = null\n\nexport function getClient(): AuraClient {\n if (cached) return cached\n const apiKey = process.env.AURA_API_KEY\n if (!apiKey) {\n throw new MissingAuraApiKeyError()\n }\n cached = new AuraClient({\n apiKey,\n baseUrl: process.env.AURA_BASE_URL,\n // Honor caller's preference; default to SDK default (auto on POST/PUT)\n autoIdempotency: process.env.AURA_AUTO_IDEMPOTENCY !== 'false',\n })\n return cached\n}\n\nexport class MissingAuraApiKeyError extends Error {\n constructor() {\n super(\n 'AURA_API_KEY not set. Configure it in your MCP client config — for ' +\n 'example in mcp.json: { \"mcpServers\": { \"aura\": { \"command\": ' +\n '\"aura-mcp\", \"env\": { \"AURA_API_KEY\": \"pk_live_...\" } } } }. Get a ' +\n 'key at https://getaura.sh.'\n )\n this.name = 'MissingAuraApiKeyError'\n }\n}\n","/**\n * Agent resources for the Aura MCP server.\n *\n * Resources let the LLM \"read\" structured data without invoking a tool. The\n * URI scheme `aura://agents/{id}` lets the LLM pull an agent's state into\n * its context when the user asks \"what's the status of agent X?\" — without\n * the round-trip cost (and audit log noise) of a full tool call.\n */\n\nimport {\n ResourceTemplate,\n} from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nimport { getClient } from '../client'\n\nexport function registerAgentResources(server: McpServer): void {\n server.resource(\n 'agent',\n new ResourceTemplate('aura://agents/{id}', { list: undefined }),\n async (uri, { id }) => {\n const client = getClient()\n const agent = await client.agents.get(String(id))\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(agent, null, 2),\n },\n ],\n }\n }\n )\n\n server.resource(\n 'agent-balance',\n new ResourceTemplate('aura://agents/{id}/balance', { list: undefined }),\n async (uri, { id }) => {\n const client = getClient()\n const balance = await client.agents.getBalance(String(id))\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(balance, null, 2),\n },\n ],\n }\n }\n )\n}\n","/**\n * Mandate resources for the Aura MCP server.\n *\n * `aura://mandates/pending` — the operator's inbox as a resource. The LLM\n * can pull this into context to answer \"what's waiting for approval?\"\n * without invoking a tool. The list is account-scoped via the API key.\n */\n\nimport {\n ResourceTemplate,\n} from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nimport { getClient } from '../client'\n\nexport function registerMandateResources(server: McpServer): void {\n server.resource(\n 'mandates-pending',\n 'aura://mandates/pending',\n async (uri) => {\n const client = getClient()\n const page = await client.mandates.listPending({ limit: 50 })\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(page, null, 2),\n },\n ],\n }\n }\n )\n\n server.resource(\n 'mandate',\n new ResourceTemplate('aura://mandates/{id}', { list: undefined }),\n async (uri, { id }) => {\n const client = getClient()\n const mandate = await client.mandates.get(String(id))\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(mandate, null, 2),\n },\n ],\n }\n }\n )\n}\n","/**\n * Error helpers — wrap an SDK call so any throw becomes a structured MCP\n * tool error instead of crashing the server. The MCP spec expects tools to\n * return `{ content: [...], isError: true }` on failure so the LLM can read\n * the error message and decide what to do (retry with different args, ask\n * the user, give up). We never let exceptions escape past the tool boundary.\n */\n\nimport {\n AuraAPIError,\n AuraAuthenticationError,\n AuraError,\n AuraNotFoundError,\n AuraRateLimitError,\n AuraTimeoutError,\n AuraValidationError,\n} from '@aura-payments/sdk'\n\nimport { MissingAuraApiKeyError } from './client'\n\n// The MCP SDK's CallToolResult requires an index signature for forward-compat\n// metadata fields (`_meta`, custom annotations, etc.). Both shapes include it\n// so they're assignable to the SDK's expected return type.\n\nexport interface ToolErrorResult {\n [key: string]: unknown\n content: Array<{ type: 'text'; text: string }>\n isError: true\n}\n\nexport interface ToolSuccessResult {\n [key: string]: unknown\n content: Array<{ type: 'text'; text: string }>\n isError?: false\n}\n\n/**\n * Wrap an async tool body so any thrown error becomes an `isError: true`\n * MCP tool result with a human-readable message. Adds an `errorCode` line\n * the LLM can pattern-match on for retry decisions.\n */\nexport async function withToolErrorHandling<T>(\n body: () => Promise<T>,\n successFormatter: (data: T) => string = defaultJsonFormatter\n): Promise<ToolSuccessResult | ToolErrorResult> {\n try {\n const result = await body()\n return {\n content: [{ type: 'text', text: successFormatter(result) }],\n }\n } catch (err) {\n return formatError(err)\n }\n}\n\nfunction defaultJsonFormatter(data: unknown): string {\n return JSON.stringify(data, null, 2)\n}\n\nfunction formatError(err: unknown): ToolErrorResult {\n if (err instanceof MissingAuraApiKeyError) {\n return errorResult('CONFIG_ERROR', err.message)\n }\n if (err instanceof AuraAuthenticationError) {\n return errorResult(\n 'AUTH_ERROR',\n `Authentication failed: ${err.message}. Check that AURA_API_KEY is correct and not revoked.`\n )\n }\n if (err instanceof AuraNotFoundError) {\n return errorResult('NOT_FOUND', err.message)\n }\n if (err instanceof AuraValidationError) {\n return errorResult('VALIDATION_ERROR', err.message)\n }\n if (err instanceof AuraRateLimitError) {\n return errorResult(\n 'RATE_LIMITED',\n `Rate limited. ${err.retryAfter ? `Retry after ${err.retryAfter}s.` : 'Back off and retry.'}`\n )\n }\n if (err instanceof AuraTimeoutError) {\n return errorResult('TIMEOUT', err.message)\n }\n if (err instanceof AuraAPIError) {\n return errorResult(`API_ERROR_${err.statusCode}`, err.message)\n }\n if (err instanceof AuraError) {\n return errorResult(err.code || 'AURA_ERROR', err.message)\n }\n if (err instanceof Error) {\n return errorResult('UNKNOWN_ERROR', err.message)\n }\n return errorResult('UNKNOWN_ERROR', String(err))\n}\n\nfunction errorResult(code: string, message: string): ToolErrorResult {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `errorCode: ${code}\\nmessage: ${message}`,\n },\n ],\n }\n}\n\n/**\n * Build a structured tool error directly (without an exception) — used by\n * guards like the wallet-create env gate that decline to act before any SDK\n * call. Same shape `withToolErrorHandling` produces, so the LLM reads it\n * identically.\n */\nexport function toolError(code: string, message: string): ToolErrorResult {\n return errorResult(code, message)\n}\n","/**\n * Agent tools for the Aura MCP server.\n *\n * Wraps AuraClient.agents — the agent-native primitives that make Aura the\n * payments substrate for AI agents. `freeze` and `evaluate` are the most\n * load-bearing for agent safety: an LLM operator can pause an autonomous\n * agent or pre-check a transaction without committing it.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { z } from 'zod'\n\n\nimport { getClient } from '../client'\nimport { withToolErrorHandling } from '../errors'\n\nconst ChainSchema = z.enum(['ARC', 'ARB', 'BASE', 'ETH', 'MATIC'])\n\nconst SpendingLimitSchema = z.object({\n limitType: z.enum([\n 'per_transaction',\n 'daily',\n 'weekly',\n 'monthly',\n 'lifetime',\n ]),\n maxAmount: z.string().describe('Whole-number USDC amount as a string'),\n currency: z.string().optional().default('USDC'),\n})\n\nconst MerchantRuleSchema = z.object({\n ruleType: z.enum(['allowlist', 'blocklist']),\n destinationType: z.enum(['address', 'domain', 'category', 'entity_id']),\n destinationValue: z.string().min(1),\n})\n\nexport function registerAgentTools(server: McpServer): void {\n server.tool(\n 'aura_create_agent',\n 'Create a new AI agent with a dedicated wallet and optional initial spending policy. The wallet is provisioned on-chain during this call (a few seconds latency).',\n {\n name: z.string().min(1).max(100),\n description: z.string().max(500).optional(),\n type: z.enum(['treasury', 'payment', 'trading', 'custom']),\n chain: ChainSchema.optional().default('ARC'),\n metadata: z.record(z.unknown()).optional(),\n initialPolicy: z\n .object({\n name: z.string().optional(),\n description: z.string().optional(),\n spendingLimits: z.array(SpendingLimitSchema).optional(),\n merchantRules: z.array(MerchantRuleSchema).optional(),\n requiresApprovalAbove: z.string().optional(),\n autoApproveBelow: z.string().optional(),\n })\n .optional(),\n },\n async (args) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.agents.create(args)\n })\n )\n\n server.tool(\n 'aura_list_agents',\n 'List agents for the authenticated account, paginated. Filter by status or type.',\n {\n status: z.enum(['active', 'paused', 'archived']).optional(),\n type: z.enum(['treasury', 'payment', 'trading', 'custom']).optional(),\n limit: z.number().int().min(1).max(200).optional(),\n offset: z.number().int().min(0).optional(),\n },\n async (args) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.agents.list(args)\n })\n )\n\n server.tool(\n 'aura_get_agent',\n 'Get a single agent by id with its current status, wallet, and recent activity.',\n {\n agentId: z.string().uuid(),\n },\n async ({ agentId }) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.agents.get(agentId)\n })\n )\n\n server.tool(\n 'aura_get_agent_balance',\n 'Get the current USDC balance of an agent\\'s wallet (on-chain at request time).',\n {\n agentId: z.string().uuid(),\n },\n async ({ agentId }) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.agents.getBalance(agentId)\n })\n )\n\n server.tool(\n 'aura_freeze_agent',\n 'Kill switch — halt all autonomous activity for an agent. Sets status=paused AND auto-rejects every pending mandate the agent has in flight. Idempotent.',\n {\n agentId: z.string().uuid(),\n reason: z.string().max(500).optional().describe('Surfaced in activity event metadata for audit trail'),\n },\n async (args) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.agents.freeze(args)\n })\n )\n\n server.tool(\n 'aura_unfreeze_agent',\n 'Resume autonomous activity for a frozen agent (status -> active). Previously cascade-rejected mandates are NOT restored — the agent re-creates them on its next loop.',\n {\n agentId: z.string().uuid(),\n },\n async (args) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.agents.unfreeze(args)\n })\n )\n\n server.tool(\n 'aura_evaluate_policy',\n 'Run a hypothetical transaction through the policy engine WITHOUT executing it. Returns the decision (auto_approve / auto_deny / requires_human_approval) and which rules matched. When the decision requires human approval, a mandate row is created and its id is returned.',\n {\n agentId: z.string().uuid(),\n amount: z.string().describe('USDC amount as decimal string'),\n destination: z.string().describe('Counterparty wallet (0x...) or merchant identifier'),\n destinationType: z\n .enum(['address', 'domain', 'category', 'entity_id'])\n .optional(),\n reasoning: z.string().optional(),\n metadata: z.record(z.unknown()).optional(),\n },\n async (args) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.agents.evaluate(args)\n })\n )\n}\n","/**\n * Escrow tools for the Aura MCP server.\n *\n * Wraps the AuraClient.escrows resource. Each tool is a thin delegation —\n * the SDK handles auth, retries, idempotency. We just declare the input\n * schema (so the LLM knows what to pass), call the SDK, and JSON-stringify\n * the result so the LLM can read it.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { z } from 'zod'\n\n\nimport { getClient } from '../client'\nimport { withToolErrorHandling } from '../errors'\n\nconst ChainSchema = z.enum(['ARC', 'ARB', 'BASE', 'ETH', 'MATIC'])\n\nconst SplitInputSchema = z.object({\n ownerType: z.enum([\n 'buyer',\n 'seller',\n 'platform',\n 'vendor',\n 'creator',\n 'affiliate',\n 'logistics',\n 'tax',\n ]),\n ownerId: z.string().uuid(),\n role: z.enum([\n 'seller',\n 'platform',\n 'vendor',\n 'creator',\n 'affiliate',\n 'logistics',\n 'tax',\n ]),\n percentage: z.number().min(0).max(100),\n})\n\nexport function registerEscrowTools(server: McpServer): void {\n server.tool(\n 'aura_create_escrow',\n 'Create a new escrow with payment splits across vendor/platform/seller wallets. Default chain is ARC. Async by default — returns an escrowId immediately while contract deployment continues in background.',\n {\n orderId: z.string().describe('Caller-provided order id, unique per account'),\n buyerOwnerId: z.string().uuid().describe('UUID of the buyer in the platform'),\n amount: z\n .string()\n .describe('Whole-number USDC amount as a string (e.g. \"100\" for $100)'),\n chain: ChainSchema.optional().describe('Target chain. Defaults to ARC'),\n splits: z\n .array(SplitInputSchema)\n .min(1)\n .describe('Payment splits. Percentages must sum to 100.'),\n },\n async (args) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.escrows.create(args)\n })\n )\n\n server.tool(\n 'aura_get_escrow',\n 'Get the current state of an escrow by id, including splits and on-chain deployment status.',\n {\n escrowId: z.string().uuid(),\n },\n async ({ escrowId }) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.escrows.get(escrowId)\n })\n )\n\n server.tool(\n 'aura_list_escrows',\n 'List escrows for the authenticated account, optionally filtered by state. Returns paginated results.',\n {\n state: z\n .enum([\n 'initiated',\n 'deployed',\n 'funded',\n 'locked',\n 'released',\n 'refunded',\n 'disputed',\n 'all',\n ])\n .optional(),\n sortBy: z\n .enum(['created_desc', 'created_asc', 'amount_desc', 'amount_asc'])\n .optional(),\n search: z.string().optional(),\n limit: z.number().int().min(1).max(200).optional(),\n offset: z.number().int().min(0).optional(),\n },\n async (args) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.escrows.list(args)\n })\n )\n\n server.tool(\n 'aura_fund_escrow',\n 'Fund an existing escrow from the buyer wallet. Once funded, the escrow can be released (after unlock conditions) or refunded.',\n {\n escrowId: z.string().uuid(),\n buyerWalletId: z.string().uuid(),\n amount: z.string().describe('USDC amount to fund (whole-number string)'),\n correlationId: z.string().optional(),\n },\n async (args) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.escrows.fund(args)\n })\n )\n\n server.tool(\n 'aura_release_escrow',\n 'Release a funded escrow to the recipients per the original splits. Requires the unlock conditions to be met (or manual override with actorId).',\n {\n escrowId: z.string().uuid(),\n actorId: z.string().uuid().describe('UUID of the user/agent performing the release'),\n reason: z.string().optional(),\n correlationId: z.string().optional(),\n },\n async (args) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.escrows.release(args)\n })\n )\n\n server.tool(\n 'aura_refund_escrow',\n 'Refund a funded escrow back to the buyer. Requires a reason (audit trail).',\n {\n escrowId: z.string().uuid(),\n reason: z.string().min(10),\n actorId: z.string().uuid(),\n },\n async (args) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.escrows.refund(args)\n })\n )\n\n server.tool(\n 'aura_receive_and_split',\n 'Receive USDC and split it to recipients in ONE call — composes escrow create→fund→release. The payer (payerOwnerId) may be the agent itself (splitting funds it holds) or a counterparty; funds move from that party\\'s Aura wallet. Returns a `stage` (created|deployed|funded|released): if it stops at \"deployed\" with `fundingRequired`, fund that wallet (e.g. aura_request_testnet_funds) and retry. Testnet only.',\n {\n orderId: z.string().describe('Caller-provided order id, unique per account'),\n payerOwnerId: z\n .string()\n .describe('Entity that funds the escrow (the agent itself or a counterparty)'),\n amount: z\n .string()\n .describe('Whole-number USDC amount as a string (e.g. \"50\"). Each split must net ≥ $1 after fees.'),\n splits: z\n .array(SplitInputSchema)\n .min(1)\n .describe('Payment splits. Percentages must sum to 100.'),\n chain: z\n .enum(['ARC', 'ARB', 'BASE'])\n .optional()\n .describe('Testnet chain. Defaults to ARC.'),\n actorId: z\n .string()\n .optional()\n .describe('Actor recorded on release. Defaults to payerOwnerId.'),\n autoRelease: z\n .boolean()\n .optional()\n .describe('Release immediately after funding. Default true.'),\n waitForDeploymentMs: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Max ms to wait for on-chain deployment. Default 60000.'),\n waitForFundingMs: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Max ms to wait for funds to settle (funded/locked) before releasing. Default 60000.'),\n },\n async (args) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.escrows.receiveAndSplit(args)\n })\n )\n}\n","/**\n * Mandate tools for the Aura MCP server.\n *\n * Wraps AuraClient.mandates — the operator's approval inbox. The MCP layer\n * is read-and-list focused; approve/reject require a signed decision, which\n * we expose as a separate tool that takes a precomputed signature. The LLM\n * shouldn't ever see the operator's HMAC secret, so the signature must be\n * computed by the caller's environment (CLI, mobile app, etc.) and passed\n * in. The tool simply forwards it.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { z } from 'zod'\n\n\nimport { getClient } from '../client'\nimport { withToolErrorHandling } from '../errors'\n\nexport function registerMandateTools(server: McpServer): void {\n server.tool(\n 'aura_list_mandates',\n \"List mandates for the authenticated account. Defaults to status=pending so it acts as the operator's inbox by default. Most-urgent (soonest-expiring) first.\",\n {\n status: z\n .enum(['pending', 'approved', 'rejected', 'cancelled'])\n .optional()\n .default('pending'),\n agentId: z.string().uuid().optional(),\n limit: z.number().int().min(1).max(200).optional(),\n cursor: z.string().uuid().optional().describe('Last mandate id from the previous page'),\n },\n async (args) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.mandates.list(args)\n })\n )\n\n server.tool(\n 'aura_get_mandate',\n \"Get a single mandate by id, including its full intent payload (the action the agent wants to take), expiry, and decision history.\",\n {\n mandateId: z.string().uuid(),\n },\n async ({ mandateId }) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.mandates.get(mandateId)\n })\n )\n\n server.tool(\n 'aura_approve_mandate',\n \"Approve a pending mandate. The decisionSignature MUST be precomputed by the caller (HMAC-SHA256 over `${mandateId}:approve:${decidedAt}`) — the LLM should never see the HMAC secret. Use the CLI or mobile app to compute it. Idempotent: re-approving an already-approved mandate returns the existing decision.\",\n {\n mandateId: z.string().uuid(),\n decisionMethod: z.enum(['biometric', 'passcode', 'manual']),\n decisionSignature: z\n .string()\n .min(16)\n .describe('HMAC-SHA256 hex digest, computed by the caller'),\n decidedAt: z\n .string()\n .datetime()\n .optional()\n .describe('ISO-8601 timestamp the signature commits to. Defaults to \"now\" server-side.'),\n },\n async (args) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.mandates.approve(args)\n })\n )\n\n server.tool(\n 'aura_reject_mandate',\n 'Reject a pending mandate. Same signature scheme as approve — caller computes it, LLM forwards.',\n {\n mandateId: z.string().uuid(),\n decisionMethod: z.enum(['biometric', 'passcode', 'manual']),\n decisionSignature: z.string().min(16),\n decidedAt: z.string().datetime().optional(),\n reason: z.string().optional().describe('Human-readable reason logged to the activity feed'),\n },\n async (args) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.mandates.reject(args)\n })\n )\n}\n","/**\n * Wallet tools for the Aura MCP server.\n *\n * Surface for the agent receive path (AURA-015):\n * - `aura_get_wallet_balance` — read on-chain USDC balance.\n * - `aura_create_wallet` — provision a receive address (create-or-get,\n * MOVES NO MONEY). Gated behind `AURA_MCP_ALLOW_WALLET_CREATE` so the host\n * operator must consciously enable autonomous provisioning; testnet chains\n * only on this surface. Mainnet creation stays on the SDK/dashboard.\n * - `aura_request_testnet_funds` — drip testnet USDC via the platform faucet\n * (capability-probed; graceful when the endpoint isn't deployed yet).\n *\n * `transfer` is deliberately NOT exposed here — moving money autonomously is\n * out of scope for the MCP surface.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { z } from 'zod'\n\n\nimport { getClient } from '../client'\nimport { toolError, withToolErrorHandling } from '../errors'\n\n/** Testnet chains only on the agent surface (ARC/ARB/BASE map to testnets). */\nconst TestnetChainSchema = z.enum(['ARC', 'ARB', 'BASE'])\n\n/** Whether the host operator has enabled autonomous wallet creation. */\nfunction walletCreateEnabled(): boolean {\n const v = (process.env.AURA_MCP_ALLOW_WALLET_CREATE ?? '').trim().toLowerCase()\n return v === '1' || v === 'true' || v === 'yes'\n}\n\nexport function registerWalletTools(server: McpServer): void {\n server.tool(\n 'aura_get_wallet_balance',\n \"Get a wallet's current USDC balance (on-chain at request time).\",\n {\n walletId: z.string().uuid(),\n },\n async ({ walletId }) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.wallets.getBalance(walletId)\n })\n )\n\n server.tool(\n 'aura_create_wallet',\n 'Provision (create-or-get) a wallet to RECEIVE USDC into. Idempotent and moves no money. Testnet only. Disabled unless the host sets AURA_MCP_ALLOW_WALLET_CREATE=1.',\n {\n entityId: z\n .string()\n .min(1)\n .describe('Your unique identifier for the wallet owner (e.g. the agent id)'),\n chain: TestnetChainSchema.optional().describe('Testnet chain. Defaults to ARC.'),\n type: z\n .enum([\n 'BUSINESS',\n 'buyer',\n 'seller',\n 'platform',\n 'vendor',\n 'creator',\n 'affiliate',\n 'logistics',\n 'tax',\n ])\n .optional()\n .describe('Wallet owner type. Defaults to BUSINESS.'),\n },\n async ({ entityId, chain, type }) => {\n if (!walletCreateEnabled()) {\n return toolError(\n 'WALLET_CREATE_DISABLED',\n 'Wallet creation is disabled on this MCP host. Set ' +\n 'AURA_MCP_ALLOW_WALLET_CREATE=1 in the server env to enable it, or ' +\n 'create the wallet via the Aura CLI (`aura wallet create`) or SDK.'\n )\n }\n return withToolErrorHandling(async () => {\n const client = getClient()\n return client.wallets.create({ entityId, chain, type })\n })\n }\n )\n\n server.tool(\n 'aura_request_testnet_funds',\n 'Request testnet USDC for a wallet from the platform faucet (testnet only). Drips are async — balance reflects after a few seconds. Returns FAUCET_UNAVAILABLE if the deployment has no faucet enabled.',\n {\n walletId: z.string().uuid(),\n token: z.string().optional().describe(\"Token to drip. Defaults to 'USDC'.\"),\n chain: TestnetChainSchema.optional().describe(\"Override the wallet's chain.\"),\n },\n async ({ walletId, token, chain }) =>\n withToolErrorHandling(async () => {\n const client = getClient()\n return client.wallets.requestTestnetFunds(walletId, { token, chain })\n })\n )\n}\n","/**\n * Aura Payments MCP Server — programmatic entry point.\n *\n * The MCP server exposes Aura's escrow, agent, mandate, and wallet primitives\n * as Model Context Protocol tools and resources, so AI agents (Claude,\n * Cursor, Continue, custom orchestrators) can drive Aura natively over\n * stdio without writing HTTP boilerplate.\n *\n * This file exports `createServer()` for programmatic use (tests, custom\n * transports, embedding in other MCP hosts). For the standalone binary,\n * see `bin.ts`.\n *\n * Wire shape: thin wrapper over `@aura-payments/sdk`. We do not duplicate\n * any business logic — the SDK is the single source of truth for HTTP\n * shape, idempotency, retries, and error mapping.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nimport { registerAgentResources } from './resources/agents'\nimport { registerMandateResources } from './resources/mandates'\nimport { registerAgentTools } from './tools/agents'\nimport { registerEscrowTools } from './tools/escrows'\nimport { registerMandateTools } from './tools/mandates'\nimport { registerWalletTools } from './tools/wallets'\n\nexport interface CreateServerOptions {\n name?: string\n version?: string\n}\n\n/**\n * Build a fully-configured MCP server with all Aura tools and resources\n * registered. The caller is responsible for connecting it to a transport\n * (stdio, SSE, etc.).\n */\nexport function createServer(options: CreateServerOptions = {}): McpServer {\n const server = new McpServer({\n name: options.name ?? 'aura-payments',\n version: options.version ?? '1.0.0',\n })\n\n // Tools — actions the LLM can take.\n registerEscrowTools(server)\n registerAgentTools(server)\n registerMandateTools(server)\n registerWalletTools(server)\n\n // Resources — data the LLM can read into context.\n registerAgentResources(server)\n registerMandateResources(server)\n\n return server\n}\n\nexport { getClient, MissingAuraApiKeyError } from './client'\n"]}