@guiie/buda-mcp 1.5.1 → 1.5.2

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.
Files changed (103) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/PUBLISH_CHECKLIST.md +39 -32
  3. package/dist/audit.d.ts +21 -0
  4. package/dist/audit.d.ts.map +1 -0
  5. package/dist/audit.js +14 -0
  6. package/dist/http.js +25 -3
  7. package/dist/tools/account.js +1 -1
  8. package/dist/tools/arbitrage.js +1 -1
  9. package/dist/tools/balance.js +1 -1
  10. package/dist/tools/balances.js +1 -1
  11. package/dist/tools/banks.js +1 -1
  12. package/dist/tools/batch_orders.d.ts +1 -1
  13. package/dist/tools/batch_orders.d.ts.map +1 -1
  14. package/dist/tools/batch_orders.js +12 -2
  15. package/dist/tools/cancel_all_orders.d.ts +1 -1
  16. package/dist/tools/cancel_all_orders.d.ts.map +1 -1
  17. package/dist/tools/cancel_all_orders.js +10 -13
  18. package/dist/tools/cancel_order.d.ts +1 -1
  19. package/dist/tools/cancel_order.d.ts.map +1 -1
  20. package/dist/tools/cancel_order.js +9 -9
  21. package/dist/tools/cancel_order_by_client_id.d.ts +1 -1
  22. package/dist/tools/cancel_order_by_client_id.d.ts.map +1 -1
  23. package/dist/tools/cancel_order_by_client_id.js +9 -9
  24. package/dist/tools/compare_markets.d.ts +9 -0
  25. package/dist/tools/compare_markets.d.ts.map +1 -1
  26. package/dist/tools/compare_markets.js +63 -53
  27. package/dist/tools/dead_mans_switch.d.ts +1 -1
  28. package/dist/tools/dead_mans_switch.d.ts.map +1 -1
  29. package/dist/tools/dead_mans_switch.js +35 -3
  30. package/dist/tools/deposits.js +2 -2
  31. package/dist/tools/fees.js +1 -1
  32. package/dist/tools/lightning.d.ts +1 -1
  33. package/dist/tools/lightning.d.ts.map +1 -1
  34. package/dist/tools/lightning.js +11 -9
  35. package/dist/tools/market_sentiment.js +1 -1
  36. package/dist/tools/market_summary.js +1 -1
  37. package/dist/tools/markets.js +1 -1
  38. package/dist/tools/order_lookup.js +2 -2
  39. package/dist/tools/orderbook.js +1 -1
  40. package/dist/tools/orders.js +1 -1
  41. package/dist/tools/place_order.d.ts +1 -1
  42. package/dist/tools/place_order.d.ts.map +1 -1
  43. package/dist/tools/place_order.js +22 -4
  44. package/dist/tools/price_history.js +1 -1
  45. package/dist/tools/quotation.js +1 -1
  46. package/dist/tools/receive_addresses.d.ts +1 -1
  47. package/dist/tools/receive_addresses.d.ts.map +1 -1
  48. package/dist/tools/receive_addresses.js +11 -11
  49. package/dist/tools/remittance_recipients.js +2 -2
  50. package/dist/tools/remittances.d.ts +2 -2
  51. package/dist/tools/remittances.d.ts.map +1 -1
  52. package/dist/tools/remittances.js +19 -20
  53. package/dist/tools/simulate_order.js +1 -1
  54. package/dist/tools/spread.js +1 -1
  55. package/dist/tools/technical_indicators.js +1 -1
  56. package/dist/tools/ticker.js +1 -1
  57. package/dist/tools/trades.js +1 -1
  58. package/dist/tools/volume.js +1 -1
  59. package/dist/tools/withdrawals.d.ts +1 -1
  60. package/dist/tools/withdrawals.d.ts.map +1 -1
  61. package/dist/tools/withdrawals.js +10 -10
  62. package/dist/utils.d.ts +10 -0
  63. package/dist/utils.d.ts.map +1 -1
  64. package/dist/utils.js +25 -0
  65. package/package.json +1 -1
  66. package/server.json +2 -2
  67. package/src/audit.ts +24 -0
  68. package/src/http.ts +27 -3
  69. package/src/tools/account.ts +1 -1
  70. package/src/tools/arbitrage.ts +1 -1
  71. package/src/tools/balance.ts +1 -1
  72. package/src/tools/balances.ts +1 -1
  73. package/src/tools/banks.ts +1 -1
  74. package/src/tools/batch_orders.ts +12 -1
  75. package/src/tools/cancel_all_orders.ts +10 -12
  76. package/src/tools/cancel_order.ts +9 -8
  77. package/src/tools/cancel_order_by_client_id.ts +9 -8
  78. package/src/tools/compare_markets.ts +78 -61
  79. package/src/tools/dead_mans_switch.ts +37 -2
  80. package/src/tools/deposits.ts +2 -2
  81. package/src/tools/fees.ts +1 -1
  82. package/src/tools/lightning.ts +12 -9
  83. package/src/tools/market_sentiment.ts +1 -1
  84. package/src/tools/market_summary.ts +1 -1
  85. package/src/tools/markets.ts +1 -1
  86. package/src/tools/order_lookup.ts +2 -2
  87. package/src/tools/orderbook.ts +1 -1
  88. package/src/tools/orders.ts +1 -1
  89. package/src/tools/place_order.ts +24 -5
  90. package/src/tools/price_history.ts +1 -1
  91. package/src/tools/quotation.ts +1 -1
  92. package/src/tools/receive_addresses.ts +11 -10
  93. package/src/tools/remittance_recipients.ts +2 -2
  94. package/src/tools/remittances.ts +19 -18
  95. package/src/tools/simulate_order.ts +1 -1
  96. package/src/tools/spread.ts +1 -1
  97. package/src/tools/technical_indicators.ts +1 -1
  98. package/src/tools/ticker.ts +1 -1
  99. package/src/tools/trades.ts +1 -1
  100. package/src/tools/volume.ts +1 -1
  101. package/src/tools/withdrawals.ts +10 -9
  102. package/src/utils.ts +33 -0
  103. package/test/unit.ts +362 -4
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { BudaApiError } from "../client.js";
3
3
  import { CACHE_TTL } from "../cache.js";
4
+ import { validateCurrency } from "../validation.js";
4
5
  export const toolSchema = {
5
6
  name: "compare_markets",
6
7
  description: "Returns side-by-side ticker data for all trading pairs of a given base currency across Buda.com's " +
@@ -18,63 +19,72 @@ export const toolSchema = {
18
19
  required: ["base_currency"],
19
20
  },
20
21
  };
22
+ export async function handleCompareMarkets(args, client, cache) {
23
+ const { base_currency } = args;
24
+ const currencyError = validateCurrency(base_currency);
25
+ if (currencyError) {
26
+ return {
27
+ content: [{ type: "text", text: JSON.stringify({ error: currencyError, code: "INVALID_CURRENCY" }) }],
28
+ isError: true,
29
+ };
30
+ }
31
+ try {
32
+ const base = base_currency.toUpperCase();
33
+ const data = await cache.getOrFetch("tickers:all", CACHE_TTL.TICKER, () => client.get("/tickers"));
34
+ const matching = data.tickers.filter((t) => {
35
+ const [tickerBase] = t.market_id.split("-");
36
+ return tickerBase === base;
37
+ });
38
+ if (matching.length === 0) {
39
+ return {
40
+ content: [
41
+ {
42
+ type: "text",
43
+ text: JSON.stringify({
44
+ error: `No markets found for base currency '${base}'.`,
45
+ code: "NOT_FOUND",
46
+ }),
47
+ },
48
+ ],
49
+ isError: true,
50
+ };
51
+ }
52
+ const result = {
53
+ base_currency: base,
54
+ markets: matching.map((t) => ({
55
+ market_id: t.market_id,
56
+ last_price: parseFloat(t.last_price[0]),
57
+ last_price_currency: t.last_price[1],
58
+ best_bid: t.max_bid ? parseFloat(t.max_bid[0]) : null,
59
+ best_ask: t.min_ask ? parseFloat(t.min_ask[0]) : null,
60
+ volume_24h: t.volume ? parseFloat(t.volume[0]) : null,
61
+ price_change_24h: t.price_variation_24h
62
+ ? parseFloat((parseFloat(t.price_variation_24h) * 100).toFixed(4))
63
+ : null,
64
+ price_change_7d: t.price_variation_7d
65
+ ? parseFloat((parseFloat(t.price_variation_7d) * 100).toFixed(4))
66
+ : null,
67
+ })),
68
+ };
69
+ return {
70
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
71
+ };
72
+ }
73
+ catch (err) {
74
+ const msg = err instanceof BudaApiError
75
+ ? { error: err.message, code: err.status }
76
+ : { error: String(err), code: "UNKNOWN" };
77
+ return {
78
+ content: [{ type: "text", text: JSON.stringify(msg) }],
79
+ isError: true,
80
+ };
81
+ }
82
+ }
21
83
  export function register(server, client, cache) {
22
84
  server.tool(toolSchema.name, toolSchema.description, {
23
85
  base_currency: z
24
86
  .string()
25
87
  .describe("Base currency to compare across all available markets (e.g. 'BTC', 'ETH', 'XRP')."),
26
- }, async ({ base_currency }) => {
27
- try {
28
- const base = base_currency.toUpperCase();
29
- const data = await cache.getOrFetch("tickers:all", CACHE_TTL.TICKER, () => client.get("/tickers"));
30
- const matching = data.tickers.filter((t) => {
31
- const [tickerBase] = t.market_id.split("-");
32
- return tickerBase === base;
33
- });
34
- if (matching.length === 0) {
35
- return {
36
- content: [
37
- {
38
- type: "text",
39
- text: JSON.stringify({
40
- error: `No markets found for base currency '${base}'.`,
41
- code: "NOT_FOUND",
42
- }),
43
- },
44
- ],
45
- isError: true,
46
- };
47
- }
48
- const result = {
49
- base_currency: base,
50
- markets: matching.map((t) => ({
51
- market_id: t.market_id,
52
- last_price: parseFloat(t.last_price[0]),
53
- last_price_currency: t.last_price[1],
54
- best_bid: t.max_bid ? parseFloat(t.max_bid[0]) : null,
55
- best_ask: t.min_ask ? parseFloat(t.min_ask[0]) : null,
56
- volume_24h: t.volume ? parseFloat(t.volume[0]) : null,
57
- price_change_24h: t.price_variation_24h
58
- ? parseFloat((parseFloat(t.price_variation_24h) * 100).toFixed(4))
59
- : null,
60
- price_change_7d: t.price_variation_7d
61
- ? parseFloat((parseFloat(t.price_variation_7d) * 100).toFixed(4))
62
- : null,
63
- })),
64
- };
65
- return {
66
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
67
- };
68
- }
69
- catch (err) {
70
- const msg = err instanceof BudaApiError
71
- ? { error: err.message, code: err.status, path: err.path }
72
- : { error: String(err), code: "UNKNOWN" };
73
- return {
74
- content: [{ type: "text", text: JSON.stringify(msg) }],
75
- isError: true,
76
- };
77
- }
78
- });
88
+ }, (args) => handleCompareMarkets(args, client, cache));
79
89
  }
80
90
  //# sourceMappingURL=compare_markets.js.map
@@ -55,7 +55,7 @@ type ScheduleArgs = {
55
55
  ttl_seconds: number;
56
56
  confirmation_token: string;
57
57
  };
58
- export declare function handleScheduleCancelAll(args: ScheduleArgs, client: BudaClient): Promise<{
58
+ export declare function handleScheduleCancelAll(args: ScheduleArgs, client: BudaClient, transport?: "http" | "stdio"): Promise<{
59
59
  content: Array<{
60
60
  type: "text";
61
61
  text: string;
@@ -1 +1 @@
1
- {"version":3,"file":"dead_mans_switch.d.ts","sourceRoot":"","sources":["../../src/tools/dead_mans_switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,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C,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAwCvE;AAID,wBAAgB,QAAQ,CACtB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,UAAU,EAClB,SAAS,GAAE,OAAO,GAAG,MAAgB,GACpC,IAAI,CA2FN"}
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { validateMarketId } from "../validation.js";
3
+ import { logAudit } from "../audit.js";
3
4
  const timers = new Map();
4
5
  async function cancelAllOrdersForMarket(marketId, client) {
5
6
  try {
@@ -85,7 +86,7 @@ export const disarmToolSchema = {
85
86
  required: ["market_id"],
86
87
  },
87
88
  };
88
- export async function handleScheduleCancelAll(args, client) {
89
+ export async function handleScheduleCancelAll(args, client, transport = "stdio") {
89
90
  const { market_id, ttl_seconds, confirmation_token } = args;
90
91
  if (confirmation_token !== "CONFIRM") {
91
92
  return {
@@ -127,6 +128,7 @@ export async function handleScheduleCancelAll(args, client) {
127
128
  }
128
129
  const id = market_id.toLowerCase();
129
130
  const entry = armTimer(id, ttl_seconds, client);
131
+ logAudit({ ts: new Date().toISOString(), tool: "schedule_cancel_all", transport, args_summary: { market_id: market_id.toUpperCase(), ttl_seconds }, success: true });
130
132
  return {
131
133
  content: [
132
134
  {
@@ -256,11 +258,41 @@ export function register(server, client, transport = "stdio") {
256
258
  market_id: z
257
259
  .string()
258
260
  .describe("Market ID whose timer should be renewed (e.g. 'BTC-CLP')."),
259
- }, (args) => handleRenewCancelTimer(args, client));
261
+ }, (args) => {
262
+ if (transport === "http") {
263
+ return Promise.resolve({
264
+ content: [{
265
+ type: "text",
266
+ text: JSON.stringify({
267
+ error: "renew_cancel_timer is not available on the HTTP transport. " +
268
+ "Timer state is process-local and only meaningful in stdio mode on a persistent local process.",
269
+ code: "TRANSPORT_NOT_SUPPORTED",
270
+ }),
271
+ }],
272
+ isError: true,
273
+ });
274
+ }
275
+ return Promise.resolve(handleRenewCancelTimer(args, client));
276
+ });
260
277
  server.tool(disarmToolSchema.name, disarmToolSchema.description, {
261
278
  market_id: z
262
279
  .string()
263
280
  .describe("Market ID whose timer should be disarmed (e.g. 'BTC-CLP')."),
264
- }, (args) => handleDisarmCancelTimer(args));
281
+ }, (args) => {
282
+ if (transport === "http") {
283
+ return Promise.resolve({
284
+ content: [{
285
+ type: "text",
286
+ text: JSON.stringify({
287
+ error: "disarm_cancel_timer is not available on the HTTP transport. " +
288
+ "Timer state is process-local and only meaningful in stdio mode on a persistent local process.",
289
+ code: "TRANSPORT_NOT_SUPPORTED",
290
+ }),
291
+ }],
292
+ isError: true,
293
+ });
294
+ }
295
+ return Promise.resolve(handleDisarmCancelTimer(args));
296
+ });
265
297
  }
266
298
  //# sourceMappingURL=dead_mans_switch.js.map
@@ -80,7 +80,7 @@ export async function handleGetDepositHistory(args, client) {
80
80
  }
81
81
  catch (err) {
82
82
  const msg = err instanceof BudaApiError
83
- ? { error: err.message, code: err.status, path: err.path }
83
+ ? { error: err.message, code: err.status }
84
84
  : { error: String(err), code: "UNKNOWN" };
85
85
  return {
86
86
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -144,7 +144,7 @@ export async function handleCreateFiatDeposit(args, client) {
144
144
  }
145
145
  catch (err) {
146
146
  const msg = err instanceof BudaApiError
147
- ? { error: err.message, code: err.status, path: err.path }
147
+ ? { error: err.message, code: err.status }
148
148
  : { error: String(err), code: "UNKNOWN" };
149
149
  return {
150
150
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -55,7 +55,7 @@ export async function handleGetNetworkFees(args, client) {
55
55
  }
56
56
  catch (err) {
57
57
  const msg = err instanceof BudaApiError
58
- ? { error: err.message, code: err.status, path: err.path }
58
+ ? { error: err.message, code: err.status }
59
59
  : { error: String(err), code: "UNKNOWN" };
60
60
  return {
61
61
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -49,7 +49,7 @@ type CreateLightningInvoiceArgs = {
49
49
  description?: string;
50
50
  expiry_seconds?: number;
51
51
  };
52
- export declare function handleLightningWithdrawal(args: LightningWithdrawalArgs, client: BudaClient): Promise<{
52
+ export declare function handleLightningWithdrawal(args: LightningWithdrawalArgs, client: BudaClient, transport?: "http" | "stdio"): Promise<{
53
53
  content: Array<{
54
54
  type: "text";
55
55
  text: string;
@@ -1 +1 @@
1
- {"version":3,"file":"lightning.d.ts","sourceRoot":"","sources":["../../src/tools/lightning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAIxD,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;CAuBzC,CAAC;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;CAwB5C,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,uBAAuB,EAC7B,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA+EhF;AAED,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,0BAA0B,EAChC,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE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gB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CA2CpE"}
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { BudaApiError } from "../client.js";
3
3
  import { flattenAmount } from "../utils.js";
4
+ import { logAudit } from "../audit.js";
4
5
  export const lightningWithdrawalToolSchema = {
5
6
  name: "lightning_withdrawal",
6
7
  description: "Pay a Bitcoin Lightning Network invoice from your Buda.com LN-BTC reserve. " +
@@ -47,7 +48,7 @@ export const createLightningInvoiceToolSchema = {
47
48
  required: ["amount_satoshis"],
48
49
  },
49
50
  };
50
- export async function handleLightningWithdrawal(args, client) {
51
+ export async function handleLightningWithdrawal(args, client, transport = "stdio") {
51
52
  const { invoice, confirmation_token } = args;
52
53
  if (confirmation_token !== "CONFIRM") {
53
54
  const preview = invoice.length > 20 ? invoice.substring(0, 20) + "..." : invoice;
@@ -66,7 +67,7 @@ export async function handleLightningWithdrawal(args, client) {
66
67
  isError: true,
67
68
  };
68
69
  }
69
- const BOLT11_RE = /^ln(bc|tb|bcrt)\d/i;
70
+ const BOLT11_RE = /^ln(bc|tb|bcrt)\d*[munp]?1[a-z0-9]{20,}$/i;
70
71
  if (!BOLT11_RE.test(invoice)) {
71
72
  return {
72
73
  content: [{
@@ -85,7 +86,7 @@ export async function handleLightningWithdrawal(args, client) {
85
86
  const lw = data.lightning_withdrawal;
86
87
  const amount = flattenAmount(lw.amount);
87
88
  const fee = flattenAmount(lw.fee);
88
- return {
89
+ const result = {
89
90
  content: [
90
91
  {
91
92
  type: "text",
@@ -102,15 +103,16 @@ export async function handleLightningWithdrawal(args, client) {
102
103
  },
103
104
  ],
104
105
  };
106
+ logAudit({ ts: new Date().toISOString(), tool: "lightning_withdrawal", transport, args_summary: {}, success: true });
107
+ return result;
105
108
  }
106
109
  catch (err) {
107
110
  const msg = err instanceof BudaApiError
108
- ? { error: err.message, code: err.status, path: err.path }
111
+ ? { error: err.message, code: err.status }
109
112
  : { error: String(err), code: "UNKNOWN" };
110
- return {
111
- content: [{ type: "text", text: JSON.stringify(msg) }],
112
- isError: true,
113
- };
113
+ const result = { content: [{ type: "text", text: JSON.stringify(msg) }], isError: true };
114
+ logAudit({ ts: new Date().toISOString(), tool: "lightning_withdrawal", transport, args_summary: {}, success: false, error_code: msg.code });
115
+ return result;
114
116
  }
115
117
  }
116
118
  export async function handleCreateLightningInvoice(args, client) {
@@ -143,7 +145,7 @@ export async function handleCreateLightningInvoice(args, client) {
143
145
  }
144
146
  catch (err) {
145
147
  const msg = err instanceof BudaApiError
146
- ? { error: err.message, code: err.status, path: err.path }
148
+ ? { error: err.message, code: err.status }
147
149
  : { error: String(err), code: "UNKNOWN" };
148
150
  return {
149
151
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -86,7 +86,7 @@ export async function handleMarketSentiment({ market_id }, client, cache) {
86
86
  }
87
87
  catch (err) {
88
88
  const msg = err instanceof BudaApiError
89
- ? { error: err.message, code: err.status, path: err.path }
89
+ ? { error: err.message, code: err.status }
90
90
  : { error: String(err), code: "UNKNOWN" };
91
91
  return {
92
92
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -63,7 +63,7 @@ export async function handleMarketSummary({ market_id }, client, cache) {
63
63
  }
64
64
  catch (err) {
65
65
  const msg = err instanceof BudaApiError
66
- ? { error: err.message, code: err.status, path: err.path }
66
+ ? { error: err.message, code: err.status }
67
67
  : { error: String(err), code: "UNKNOWN" };
68
68
  return {
69
69
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -47,7 +47,7 @@ export function register(server, client, cache) {
47
47
  }
48
48
  catch (err) {
49
49
  const msg = err instanceof BudaApiError
50
- ? { error: err.message, code: err.status, path: err.path }
50
+ ? { error: err.message, code: err.status }
51
51
  : { error: String(err), code: "UNKNOWN" };
52
52
  return {
53
53
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -76,7 +76,7 @@ export async function handleGetOrder(args, client) {
76
76
  }
77
77
  catch (err) {
78
78
  const msg = err instanceof BudaApiError
79
- ? { error: err.message, code: err.status, path: err.path }
79
+ ? { error: err.message, code: err.status }
80
80
  : { error: String(err), code: "UNKNOWN" };
81
81
  return {
82
82
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -93,7 +93,7 @@ export async function handleGetOrderByClientId(args, client) {
93
93
  }
94
94
  catch (err) {
95
95
  const msg = err instanceof BudaApiError
96
- ? { error: err.message, code: err.status, path: err.path }
96
+ ? { error: err.message, code: err.status }
97
97
  : { error: String(err), code: "UNKNOWN" };
98
98
  return {
99
99
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -66,7 +66,7 @@ export function register(server, client, cache) {
66
66
  }
67
67
  catch (err) {
68
68
  const msg = err instanceof BudaApiError
69
- ? { error: err.message, code: err.status, path: err.path }
69
+ ? { error: err.message, code: err.status }
70
70
  : { error: String(err), code: "UNKNOWN" };
71
71
  return {
72
72
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -117,7 +117,7 @@ export function register(server, client) {
117
117
  }
118
118
  catch (err) {
119
119
  const msg = err instanceof BudaApiError
120
- ? { error: err.message, code: err.status, path: err.path }
120
+ ? { error: err.message, code: err.status }
121
121
  : { error: String(err), code: "UNKNOWN" };
122
122
  return {
123
123
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -72,7 +72,7 @@ type PlaceOrderArgs = {
72
72
  stop_type?: ">=" | "<=";
73
73
  confirmation_token: string;
74
74
  };
75
- export declare function handlePlaceOrder(args: PlaceOrderArgs, client: BudaClient): Promise<{
75
+ export declare function handlePlaceOrder(args: PlaceOrderArgs, client: BudaClient, transport?: "http" | "stdio"): Promise<{
76
76
  content: Array<{
77
77
  type: "text";
78
78
  text: string;
@@ -1 +1 @@
1
- {"version":3,"file":"place_order.d.ts","sourceRoot":"","sources":["../../src/tools/place_order.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM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KAAK,cAAc,GAAG;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;IACpB,UAAU,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,UAAU,EAClB,SAAS,GAAE,MAAM,GAAG,OAAiB,GACpC,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAsLhF;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CA4DpE"}
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { BudaApiError } from "../client.js";
3
3
  import { validateMarketId } from "../validation.js";
4
+ import { logAudit } from "../audit.js";
4
5
  export const toolSchema = {
5
6
  name: "place_order",
6
7
  description: "Place a limit or market order on Buda.com. " +
@@ -66,7 +67,7 @@ export const toolSchema = {
66
67
  required: ["market_id", "type", "price_type", "amount", "confirmation_token"],
67
68
  },
68
69
  };
69
- export async function handlePlaceOrder(args, client) {
70
+ export async function handlePlaceOrder(args, client, transport = "stdio") {
70
71
  const { market_id, type, price_type, amount, limit_price, ioc, fok, post_only, gtd_timestamp, stop_price, stop_type, confirmation_token, } = args;
71
72
  if (confirmation_token !== "CONFIRM") {
72
73
  return {
@@ -194,18 +195,35 @@ export async function handlePlaceOrder(args, client) {
194
195
  payload.stop = { price: stop_price, type: stop_type };
195
196
  }
196
197
  const data = await client.post(`/markets/${market_id.toLowerCase()}/orders`, payload);
197
- return {
198
+ const result = {
198
199
  content: [{ type: "text", text: JSON.stringify(data.order, null, 2) }],
199
200
  };
201
+ logAudit({
202
+ ts: new Date().toISOString(),
203
+ tool: "place_order",
204
+ transport,
205
+ args_summary: { market_id, type, price_type, amount },
206
+ success: true,
207
+ });
208
+ return result;
200
209
  }
201
210
  catch (err) {
202
211
  const msg = err instanceof BudaApiError
203
- ? { error: err.message, code: err.status, path: err.path }
212
+ ? { error: err.message, code: err.status }
204
213
  : { error: String(err), code: "UNKNOWN" };
205
- return {
214
+ const result = {
206
215
  content: [{ type: "text", text: JSON.stringify(msg) }],
207
216
  isError: true,
208
217
  };
218
+ logAudit({
219
+ ts: new Date().toISOString(),
220
+ tool: "place_order",
221
+ transport,
222
+ args_summary: { market_id, type, price_type, amount },
223
+ success: false,
224
+ error_code: msg.code,
225
+ });
226
+ return result;
209
227
  }
210
228
  }
211
229
  export function register(server, client) {
@@ -85,7 +85,7 @@ export function register(server, client, _cache) {
85
85
  }
86
86
  catch (err) {
87
87
  const msg = err instanceof BudaApiError
88
- ? { error: err.message, code: err.status, path: err.path }
88
+ ? { error: err.message, code: err.status }
89
89
  : { error: String(err), code: "UNKNOWN" };
90
90
  return {
91
91
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -80,7 +80,7 @@ export async function handleGetRealQuotation(args, client) {
80
80
  }
81
81
  catch (err) {
82
82
  const msg = err instanceof BudaApiError
83
- ? { error: err.message, code: err.status, path: err.path }
83
+ ? { error: err.message, code: err.status }
84
84
  : { error: String(err), code: "UNKNOWN" };
85
85
  return {
86
86
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -72,7 +72,7 @@ export declare function handleGetReceiveAddress(args: {
72
72
  export declare function handleCreateReceiveAddress(args: {
73
73
  currency: string;
74
74
  confirmation_token: string;
75
- }, client: BudaClient): Promise<{
75
+ }, client: BudaClient, transport?: "http" | "stdio"): Promise<{
76
76
  content: Array<{
77
77
  type: "text";
78
78
  text: string;
@@ -1 +1 @@
1
- {"version":3,"file":"receive_addresses.d.ts","sourceRoot":"","sources":["../../src/tools/receive_addresses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAIxD,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;CAwB1C,CAAC;AAEF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;CAiB1C,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;CAoBvC,CAAC;AAYF,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC1B,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAqChF;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EACtC,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA4BhF;AAED,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,C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E,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA4BhF;AAED,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAA;CAAE,EACtD,MAAM,EAAE,UAAU,EAClB,SAAS,GAAE,MAAM,GAAG,OAAiB,GACpC,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA8ChF;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CA+BpE"}
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { BudaApiError } from "../client.js";
3
3
  import { validateCurrency } from "../validation.js";
4
+ import { logAudit } from "../audit.js";
4
5
  export const createReceiveAddressToolSchema = {
5
6
  name: "create_receive_address",
6
7
  description: "Generates a new receive address for a crypto currency. " +
@@ -93,7 +94,7 @@ export async function handleListReceiveAddresses(args, client) {
93
94
  }
94
95
  catch (err) {
95
96
  const msg = err instanceof BudaApiError
96
- ? { error: err.message, code: err.status, path: err.path }
97
+ ? { error: err.message, code: err.status }
97
98
  : { error: String(err), code: "UNKNOWN" };
98
99
  return {
99
100
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -118,7 +119,7 @@ export async function handleGetReceiveAddress(args, client) {
118
119
  }
119
120
  catch (err) {
120
121
  const msg = err instanceof BudaApiError
121
- ? { error: err.message, code: err.status, path: err.path }
122
+ ? { error: err.message, code: err.status }
122
123
  : { error: String(err), code: "UNKNOWN" };
123
124
  return {
124
125
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -126,7 +127,7 @@ export async function handleGetReceiveAddress(args, client) {
126
127
  };
127
128
  }
128
129
  }
129
- export async function handleCreateReceiveAddress(args, client) {
130
+ export async function handleCreateReceiveAddress(args, client, transport = "stdio") {
130
131
  const { currency, confirmation_token } = args;
131
132
  if (confirmation_token !== "CONFIRM") {
132
133
  return {
@@ -153,18 +154,17 @@ export async function handleCreateReceiveAddress(args, client) {
153
154
  }
154
155
  try {
155
156
  const data = await client.post(`/currencies/${currency.toUpperCase()}/receive_addresses`, {});
156
- return {
157
- content: [{ type: "text", text: JSON.stringify(normalizeAddress(data.receive_address), null, 2) }],
158
- };
157
+ const result = { content: [{ type: "text", text: JSON.stringify(normalizeAddress(data.receive_address), null, 2) }] };
158
+ logAudit({ ts: new Date().toISOString(), tool: "create_receive_address", transport, args_summary: { currency }, success: true });
159
+ return result;
159
160
  }
160
161
  catch (err) {
161
162
  const msg = err instanceof BudaApiError
162
- ? { error: err.message, code: err.status, path: err.path }
163
+ ? { error: err.message, code: err.status }
163
164
  : { error: String(err), code: "UNKNOWN" };
164
- return {
165
- content: [{ type: "text", text: JSON.stringify(msg) }],
166
- isError: true,
167
- };
165
+ const result = { content: [{ type: "text", text: JSON.stringify(msg) }], isError: true };
166
+ logAudit({ ts: new Date().toISOString(), tool: "create_receive_address", transport, args_summary: { currency }, success: false, error_code: msg.code });
167
+ return result;
168
168
  }
169
169
  }
170
170
  export function register(server, client) {
@@ -69,7 +69,7 @@ export async function handleListRemittanceRecipients(args, client) {
69
69
  }
70
70
  catch (err) {
71
71
  const msg = err instanceof BudaApiError
72
- ? { error: err.message, code: err.status, path: err.path }
72
+ ? { error: err.message, code: err.status }
73
73
  : { error: String(err), code: "UNKNOWN" };
74
74
  return {
75
75
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -86,7 +86,7 @@ export async function handleGetRemittanceRecipient(args, client) {
86
86
  }
87
87
  catch (err) {
88
88
  const msg = err instanceof BudaApiError
89
- ? { error: err.message, code: err.status, path: err.path }
89
+ ? { error: err.message, code: err.status }
90
90
  : { error: String(err), code: "UNKNOWN" };
91
91
  return {
92
92
  content: [{ type: "text", text: JSON.stringify(msg) }],
@@ -99,7 +99,7 @@ export declare function handleQuoteRemittance(args: {
99
99
  amount: number;
100
100
  recipient_id: number;
101
101
  confirmation_token: string;
102
- }, client: BudaClient): Promise<{
102
+ }, client: BudaClient, transport?: "http" | "stdio"): Promise<{
103
103
  content: Array<{
104
104
  type: "text";
105
105
  text: string;
@@ -109,7 +109,7 @@ export declare function handleQuoteRemittance(args: {
109
109
  export declare function handleAcceptRemittanceQuote(args: {
110
110
  id: number;
111
111
  confirmation_token: string;
112
- }, client: BudaClient): Promise<{
112
+ }, client: BudaClient, transport?: "http" | "stdio"): Promise<{
113
113
  content: Array<{
114
114
  type: "text";
115
115
  text: string;
@@ -1 +1 @@
1
- {"version":3,"file":"remittances.d.ts","sourceRoot":"","sources":["../../src/tools/remittances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAKxD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;CAoBrC,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;CAiCrC,CAAC;AAEF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;CAuB3C,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;CAiBnC,CAAC;AAgBF,wBAAsB,qBAAqB,CACzC,IAAI,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EACrC,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAoChF;AAED,wBAAsB,mBAAmB,CACvC,IAAI,E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